diff options
author | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-20 23:27:29 +0000 |
---|---|---|
committer | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-20 23:27:29 +0000 |
commit | 29c32f903806efbc167a417c170b896dfeecc33f (patch) | |
tree | 3c05f7208c27e1affa40d859b573f5a1a6bc66d8 | |
parent | 735f05d9e40970195459ac9136e8e731edea4f32 (diff) | |
download | chromium_src-29c32f903806efbc167a417c170b896dfeecc33f.zip chromium_src-29c32f903806efbc167a417c170b896dfeecc33f.tar.gz chromium_src-29c32f903806efbc167a417c170b896dfeecc33f.tar.bz2 |
In ChromeFrame with the IMoniker patch on, we should save away the redirect information received for the initial pending request. This
is to ensure that we inform Chrome about this redirect which can then be followed correctly from Chrome.
The other change is to save away the URL being navigated to in the bind context context object. This is also updated if we receive a redirect
notification in our callback wrapper. The active document refers this URL if it is available and falls back to the old mechanism of retrieving
the URL from the moniker if not.
This ensures that optin urls continue to work correctly if the initial page is redirected.
Review URL: http://codereview.chromium.org/1523028
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45114 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome_frame/bind_context_info.h | 9 | ||||
-rw-r--r-- | chrome_frame/chrome_active_document.cc | 20 | ||||
-rw-r--r-- | chrome_frame/urlmon_bind_status_callback.cc | 7 | ||||
-rw-r--r-- | chrome_frame/urlmon_url_request.cc | 38 |
4 files changed, 55 insertions, 19 deletions
diff --git a/chrome_frame/bind_context_info.h b/chrome_frame/bind_context_info.h index ff409f0..b6dca88 100644 --- a/chrome_frame/bind_context_info.h +++ b/chrome_frame/bind_context_info.h @@ -52,11 +52,20 @@ class BindContextInfo : public IUnknown, public CComObjectRoot { return cache_; } + void set_url(const std::wstring& url) { + url_ = url; + } + + const std::wstring url() const { + return url_; + } + private: ScopedComPtr<IStream> cache_; bool no_cache_; bool chrome_request_; bool is_switching_; + std::wstring url_; DISALLOW_COPY_AND_ASSIGN(BindContextInfo); }; diff --git a/chrome_frame/chrome_active_document.cc b/chrome_frame/chrome_active_document.cc index d31b2a8..caa4ffd 100644 --- a/chrome_frame/chrome_active_document.cc +++ b/chrome_frame/chrome_active_document.cc @@ -35,6 +35,7 @@ #include "chrome/test/automation/browser_proxy.h" #include "chrome/test/automation/tab_proxy.h" #include "chrome_frame/bho.h" +#include "chrome_frame/bind_context_info.h" #include "chrome_frame/utils.h" const wchar_t kChromeAttachExternalTabPrefix[] = L"attach_external_tab"; @@ -233,11 +234,20 @@ STDMETHODIMP ChromeActiveDocument::Load(BOOL fully_avalable, NavigationManager* mgr = NavigationManager::GetThreadInstance(); DCHECK(mgr); - // If the original URL contains an anchor, then the URL queried - // from the moniker does not contain the anchor. To workaround - // this we retrieve the URL from our BHO. - std::wstring url(GetActualUrlFromMoniker( - moniker_name, bind_context, mgr ? mgr->url(): std::wstring())); + std::wstring url; + + scoped_refptr<BindContextInfo> info = + BindContextInfo::FromBindContext(bind_context); + DCHECK(info); + if (info && !info->url().empty()) { + url = info->url(); + } else { + // If the original URL contains an anchor, then the URL queried + // from the moniker does not contain the anchor. To workaround + // this we retrieve the URL from our BHO. + url = GetActualUrlFromMoniker(moniker_name, bind_context, + mgr ? mgr->url(): std::wstring()); + } // The is_new_navigation variable indicates if this a navigation initiated // by typing in a URL for e.g. in the IE address bar, or from Chrome by diff --git a/chrome_frame/urlmon_bind_status_callback.cc b/chrome_frame/urlmon_bind_status_callback.cc index c870f7ad..8d724f4 100644 --- a/chrome_frame/urlmon_bind_status_callback.cc +++ b/chrome_frame/urlmon_bind_status_callback.cc @@ -88,7 +88,6 @@ bool SniffData::InitializeCache(const std::wstring& url) { NOTREACHED(); return false; } - return true; } @@ -213,6 +212,12 @@ STDMETHODIMP BSCBStorageBind::OnProgress(ULONG progress, ULONG progress_max, Progress new_progress = { progress, progress_max, status_code, status_text ? status_text : std::wstring() }; saved_progress_.push_back(new_progress); + if (status_code == BINDSTATUS_REDIRECTING) { + scoped_refptr<BindContextInfo> info = + BindContextInfo::FromBindContext(bind_ctx_); + DCHECK(info); + info->set_url(status_text); + } } else { hr = CallbackImpl::OnProgress(progress, progress_max, status_code, status_text); diff --git a/chrome_frame/urlmon_url_request.cc b/chrome_frame/urlmon_url_request.cc index b1d082f..2a1d28d 100644 --- a/chrome_frame/urlmon_url_request.cc +++ b/chrome_frame/urlmon_url_request.cc @@ -196,21 +196,31 @@ STDMETHODIMP UrlmonUrlRequest::OnProgress(ULONG progress, ULONG max_progress, return S_OK; } - // Ignore any notifications received while we are in the pending state waiting - // for the request to be initiated by Chrome. - if (pending_) + // Ignore any notifications received while we are in the pending state + // waiting for the request to be initiated by Chrome. + if (pending_ && status_code != BINDSTATUS_REDIRECTING) return S_OK; switch (status_code) { case BINDSTATUS_REDIRECTING: { - DLOG(INFO) << "URL: " << url() << " redirected to " << status_text; - // Fetch the redirect status as they aren't all equal (307 in particular - // retains the HTTP request verb). - int http_code = GetHttpResponseStatusFromBinding(binding_); - status_.SetRedirected(http_code, WideToUTF8(status_text)); - // Abort. We will inform Chrome in OnStopBinding callback. - binding_->Abort(); - return E_ABORT; + // If we receive a redirect for the initial pending request initiated + // when our document loads we should stash it away and inform Chrome + // accordingly when it requests data for the original URL. + scoped_refptr<BindContextInfo> info = + BindContextInfo::FromBindContext(bind_context_); + DCHECK(info); + GURL previously_redirected(info ? info->url() : std::wstring()); + if (GURL(status_text) != previously_redirected) { + DLOG(INFO) << "URL: " << url() << " redirected to " << status_text; + // Fetch the redirect status as they aren't all equal (307 in particular + // retains the HTTP request verb). + int http_code = GetHttpResponseStatusFromBinding(binding_); + status_.SetRedirected(http_code, WideToUTF8(status_text)); + // Abort. We will inform Chrome in OnStopBinding callback. + binding_->Abort(); + return E_ABORT; + } + break; } case BINDSTATUS_COOKIE_SENT: @@ -313,8 +323,10 @@ STDMETHODIMP UrlmonUrlRequest::OnStopBinding(HRESULT result, LPCWSTR error) { if (status_.was_redirected()) { // Just release bindings here. Chrome will issue EndRequest(request_id) // after processing headers we had provided. - std::string headers = GetHttpHeadersFromBinding(binding_); - OnResponse(0, UTF8ToWide(headers).c_str(), NULL, NULL); + if (!pending_) { + std::string headers = GetHttpHeadersFromBinding(binding_); + OnResponse(0, UTF8ToWide(headers).c_str(), NULL, NULL); + } ReleaseBindings(); return S_OK; } |