diff options
author | tommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-02 04:45:33 +0000 |
---|---|---|
committer | tommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-02 04:45:33 +0000 |
commit | 2da0f01d254f14e4497e8d197078ca7297839aa9 (patch) | |
tree | 574c946bac6719c061442ff9b6620f88af3f1868 /chrome_frame | |
parent | 96acdf132ef5c70a39cb79f41c58beca6167dd82 (diff) | |
download | chromium_src-2da0f01d254f14e4497e8d197078ca7297839aa9.zip chromium_src-2da0f01d254f14e4497e8d197078ca7297839aa9.tar.gz chromium_src-2da0f01d254f14e4497e8d197078ca7297839aa9.tar.bz2 |
Enable optinurls regardless of PatchHelper::state().
Also refactored the OptinUrls code into a separate function.
TEST=The OptinUrls feature should work.
BUG=none
Review URL: http://codereview.chromium.org/561002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37796 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame')
-rw-r--r-- | chrome_frame/bho.cc | 48 | ||||
-rw-r--r-- | chrome_frame/bho.h | 2 |
2 files changed, 28 insertions, 22 deletions
diff --git a/chrome_frame/bho.cc b/chrome_frame/bho.cc index ec6942a..6802236 100644 --- a/chrome_frame/bho.cc +++ b/chrome_frame/bho.cc @@ -91,34 +91,14 @@ STDMETHODIMP Bho::BeforeNavigate2(IDispatch* dispatch, VARIANT* url, if (dispatch) web_browser2.QueryFrom(dispatch); - if (!web_browser2) { + if (!web_browser2 || url->vt != VT_BSTR) { NOTREACHED() << "Can't find WebBrowser2 with given dispatch"; return S_OK; // Return success, we operate on best effort basis. } DLOG(INFO) << "BeforeNavigate2: " << url->bstrVal; - if (g_patch_helper.state() == PatchHelper::PATCH_IBROWSER) { - VARIANT_BOOL is_top_level = VARIANT_FALSE; - web_browser2->get_TopLevelContainer(&is_top_level); - - std::wstring current_url; - bool is_chrome_protocol = false; - if (is_top_level && IsValidUrlScheme(url->bstrVal, false)) { - current_url.assign(url->bstrVal, SysStringLen(url->bstrVal)); - is_chrome_protocol = StartsWith(current_url, kChromeProtocolPrefix, - false); - - if (!is_chrome_protocol && IsOptInUrl(current_url.c_str())) { - DLOG(INFO) << "Opt-in URL. Switching to cf."; - ScopedComPtr<IBrowserService> browser_service; - DoQueryService(SID_SShellBrowser, web_browser2, - browser_service.Receive()); - DCHECK(browser_service) << "DoQueryService - SID_SShellBrowser failed."; - MarkBrowserOnThreadForCFNavigation(browser_service); - } - } - } + ProcessOptInUrls(web_browser2, url->bstrVal); referrer_.clear(); @@ -324,6 +304,30 @@ Bho* Bho::GetCurrentThreadBhoInstance() { return bho_current_thread_instance_.Pointer()->Get(); } +// static +void Bho::ProcessOptInUrls(IWebBrowser2* browser, BSTR url) { + if (!browser || !url) { + NOTREACHED(); + return; + } + + VARIANT_BOOL is_top_level = VARIANT_FALSE; + browser->get_TopLevelContainer(&is_top_level); + if (is_top_level) { + std::wstring current_url(url, SysStringLen(url)); + if (IsValidUrlScheme(current_url, false)) { + bool cf_protocol = StartsWith(current_url, kChromeProtocolPrefix, false); + if (!cf_protocol && IsOptInUrl(current_url.c_str())) { + DLOG(INFO) << "Opt-in URL. Switching to cf."; + ScopedComPtr<IBrowserService> browser_service; + DoQueryService(SID_SShellBrowser, browser, browser_service.Receive()); + DCHECK(browser_service) << "DoQueryService - SID_SShellBrowser failed."; + MarkBrowserOnThreadForCFNavigation(browser_service); + } + } + } +} + namespace { // Utility function that prevents the current module from ever being unloaded. void PinModule() { diff --git a/chrome_frame/bho.h b/chrome_frame/bho.h index e25ebdf..54bdc99 100644 --- a/chrome_frame/bho.h +++ b/chrome_frame/bho.h @@ -102,6 +102,8 @@ END_SINK_MAP() // TLS. static Bho* GetCurrentThreadBhoInstance(); + static void ProcessOptInUrls(IWebBrowser2* browser, BSTR url); + protected: bool PatchProtocolHandler(const CLSID& handler_clsid); |