summaryrefslogtreecommitdiffstats
path: root/chrome_frame
diff options
context:
space:
mode:
Diffstat (limited to 'chrome_frame')
-rw-r--r--chrome_frame/bind_context_info.h9
-rw-r--r--chrome_frame/chrome_active_document.cc20
-rw-r--r--chrome_frame/urlmon_bind_status_callback.cc7
-rw-r--r--chrome_frame/urlmon_url_request.cc38
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;
}