Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: src/plugin/PluginTabBase.cpp

Issue 5447868882092032: Issue 1793 - check whether the frame is whitelisted before injecting CSS (Closed)
Patch Set: fix according to comments Created May 15, 2015, 11:55 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/plugin/AdblockPlusClient.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/plugin/PluginTabBase.cpp
diff --git a/src/plugin/PluginTabBase.cpp b/src/plugin/PluginTabBase.cpp
index 7422d417c812d2f3c586d4e359a39502c0a96f02..ede52235f9dc117bd84713756b42c9486f1ce642 100644
--- a/src/plugin/PluginTabBase.cpp
+++ b/src/plugin/PluginTabBase.cpp
@@ -177,6 +177,51 @@ void CPluginTabBase::InjectABP(IWebBrowser2* browser)
}
}
+namespace
+{
+ ATL::CComPtr<IWebBrowser2> GetParent(IWebBrowser2& browser)
+ {
+ ATL::CComPtr<IDispatch> parentDispatch;
+ if (FAILED(browser.get_Parent(&parentDispatch)) || !parentDispatch)
+ {
+ return nullptr;
+ }
+ // The InternetExplorer application always returns a pointer to itself.
+ if (parentDispatch.IsEqualObject(&browser))
+ {
+ return nullptr;
+ }
+ ATL::CComQIPtr<IServiceProvider> parentDocumentServiceProvider = parentDispatch;
+ if (!parentDocumentServiceProvider)
+ {
+ return nullptr;
+ }
+ ATL::CComPtr<IWebBrowserApp> webBrowserApp;
+ if (FAILED(parentDocumentServiceProvider->QueryService(IID_IWebBrowserApp, &webBrowserApp)) || !webBrowserApp)
+ {
+ return nullptr;
+ }
+ return ATL::CComQIPtr<IWebBrowser2>(webBrowserApp);
+ }
+
+ bool IsFrameWhiteListed(ATL::CComPtr<IWebBrowser2> frame)
+ {
+ if (!frame)
+ {
+ return false;
+ }
+ auto url = GetLocationUrl(*frame);
+ std::vector<std::string> frameHierarchy;
+ while(frame = GetParent(*frame))
+ {
+ frameHierarchy.push_back(ToUtf8String(GetLocationUrl(*frame)));
+ }
+ CPluginClient* client = CPluginClient::GetInstance();
+ return client->IsWhitelistedUrl(url, frameHierarchy)
+ || client->IsElemhideWhitelistedOnDomain(url, frameHierarchy);
+ }
+}
+
void CPluginTabBase::OnDownloadComplete(IWebBrowser2* browser)
{
CPluginClient* client = CPluginClient::GetInstance();
« no previous file with comments | « src/plugin/AdblockPlusClient.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld