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(); |