diff options
author | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-30 21:41:25 +0000 |
---|---|---|
committer | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-30 21:41:25 +0000 |
commit | 9ae7b9195f0e06b64664bba52e9cc0e8b3470f56 (patch) | |
tree | c6cbd94204f2fb5fc8f758616b04feef455781a7 /chrome_frame/chrome_active_document.cc | |
parent | 48a96abb2464e6341d876c0a9c952764ce4a7a2e (diff) | |
download | chromium_src-9ae7b9195f0e06b64664bba52e9cc0e8b3470f56.zip chromium_src-9ae7b9195f0e06b64664bba52e9cc0e8b3470f56.tar.gz chromium_src-9ae7b9195f0e06b64664bba52e9cc0e8b3470f56.tar.bz2 |
ChromeFrame should report anchor navigations to Chrome. Currently this does not work as expected if
a navigation is first attempted to a ChromeFrame URL without the anchor followed by a navigation to
the same url with an anchor. In this case IE first sends an unload request to the currently loaded
CF document which causes a lot of grief as we run unload handlers on the page. The navigation never
proceeds to the new url though.
The proposed fix is to handle this in the onunload handler in CF by validating whether the new url
without the anchor is the same as the current url. If yes we just initiate a new navigation in Chrome.
Fixes bug http://code.google.com/p/chromium/issues/detail?id=85617
BUG=85617
Review URL: http://codereview.chromium.org/7290015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@91204 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame/chrome_active_document.cc')
-rw-r--r-- | chrome_frame/chrome_active_document.cc | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/chrome_frame/chrome_active_document.cc b/chrome_frame/chrome_active_document.cc index dc005c4..f06a53a 100644 --- a/chrome_frame/chrome_active_document.cc +++ b/chrome_frame/chrome_active_document.cc @@ -930,6 +930,43 @@ void ChromeActiveDocument::OnUnload(const GUID* cmd_group_guid, VARIANT* in_args, VARIANT* out_args) { if (IsValid() && out_args) { + // If the navigation is attempted to the url loaded in CF, with the only + // difference being the addition of an anchor, IE will attempt to unload + // the currently loaded document which basically would end up running + // unload handlers on the currently loaded document thus rendering it non + // functional. We handle this as below:- + // The BHO receives the new url in the BeforeNavigate event. + // We compare the non anchor portions of the url in the BHO with the loaded + // url and if they match, we initiate a Chrome navigation to the url with + // the anchor which works nicely. + // We don't want to continue processing the unload in this case. + // Note:- + // IE handles these navigations by querying the loaded document for + // IHTMLDocument which then handles the new navigation. That won't work for + // us as we don't implement IHTMLDocument. + NavigationManager* mgr = NavigationManager::GetThreadInstance(); + DLOG_IF(ERROR, !mgr) << "Couldn't get instance of NavigationManager"; + if (mgr) { + ChromeFrameUrl url; + url.Parse(mgr->url()); + if (url.gurl().has_ref()) { + url_canon::Replacements<char> replacements; + replacements.ClearRef(); + + if (url.gurl().ReplaceComponents(replacements) == + GURL(static_cast<BSTR>(url_))) { + // We want to reuse the existing automation client and channel for + // initiating the new navigation. Setting the + // is_automation_client_reused_ flag to true before calling the + // LaunchUrl function achieves that. + is_automation_client_reused_ = true; + LaunchUrl(url, mgr->referrer()); + out_args->vt = VT_BOOL; + out_args->boolVal = VARIANT_FALSE; + return; + } + } + } bool should_unload = true; automation_client_->OnUnload(&should_unload); out_args->vt = VT_BOOL; |