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: rebase and address comments Created April 13, 2015, 7:31 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
« src/engine/Main.cpp ('K') | « 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..bfca0c1e9b07d4247317692c820496904a55a182 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> browserParentDispatch;
Eric 2015/05/14 17:07:26 I'd call this 'parentDispatch' here, in analogy wi
sergei 2015/05/15 11:55:55 renamed
+ if (FAILED(browser.get_Parent(&browserParentDispatch)) || !browserParentDispatch)
+ {
+ return nullptr;
+ }
+ // The InternetExplorer application always returns a pointer to itself.
+ if (browserParentDispatch.IsEqualObject(&browser))
+ {
+ return nullptr;
+ }
+ ATL::CComQIPtr<IServiceProvider> parentDocumentServiceProvider = browserParentDispatch;
+ 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;
+ for(frame = GetParent(*frame); frame; 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();
« src/engine/Main.cpp ('K') | « src/plugin/AdblockPlusClient.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld