summaryrefslogtreecommitdiffstats
path: root/chrome_frame/urlmon_url_request.cc
diff options
context:
space:
mode:
authorananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-20 23:27:29 +0000
committerananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-20 23:27:29 +0000
commit29c32f903806efbc167a417c170b896dfeecc33f (patch)
tree3c05f7208c27e1affa40d859b573f5a1a6bc66d8 /chrome_frame/urlmon_url_request.cc
parent735f05d9e40970195459ac9136e8e731edea4f32 (diff)
downloadchromium_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
Diffstat (limited to 'chrome_frame/urlmon_url_request.cc')
-rw-r--r--chrome_frame/urlmon_url_request.cc38
1 files changed, 25 insertions, 13 deletions
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;
}