diff options
author | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-19 17:34:57 +0000 |
---|---|---|
committer | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-19 17:34:57 +0000 |
commit | b36a9f99e21193b08a58336a1a974893ac46a31a (patch) | |
tree | eb3c80709ae56c234454fe7388fe32f54a2ce1b5 /chrome_frame/bho.cc | |
parent | 5779bad3e1753ca61a0de9fa28ce44df63f08579 (diff) | |
download | chromium_src-b36a9f99e21193b08a58336a1a974893ac46a31a.zip chromium_src-b36a9f99e21193b08a58336a1a974893ac46a31a.tar.gz chromium_src-b36a9f99e21193b08a58336a1a974893ac46a31a.tar.bz2 |
When Chrome hands off a URL to be opened by the external host by the ViewHostMsg_OpenURL IPC, it
needs to pass the referrer as well. The Chrome fixes in this CL are mostly related to passing the
HTTP referer off to the browser and from there to the ExternalTabContainer to ChromeFrame and back.
The ChromeFrame changes are basically around the same lines with one exception. When we handle the
AutomationMsg_OpenURL IPC in the activex and the active document we pass the referer if applicable
to the WebBrowser2::Navigate2 interface, which is then read by the BHO in BeforeNavigate2. We then
save away an AddRef'ed BHO pointer in TLS which is then referenced by the Active document for reading
the referer and passing it off to Chrome in the NavigateInExternalTab message.
Added a unit test in ChromeFrame which tests this case.
This fixes http://code.google.com/p/chromium/issues/detail?id=22994
Bug=22994
Review URL: http://codereview.chromium.org/274071
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29420 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame/bho.cc')
-rw-r--r-- | chrome_frame/bho.cc | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/chrome_frame/bho.cc b/chrome_frame/bho.cc index e83c8ba..f18cc3e 100644 --- a/chrome_frame/bho.cc +++ b/chrome_frame/bho.cc @@ -18,10 +18,14 @@ #include "chrome_frame/protocol_sink_wrap.h" #include "chrome_frame/utils.h" #include "chrome_frame/vtable_patch_manager.h" +#include "net/http/http_util.h" const wchar_t kPatchProtocols[] = L"PatchProtocols"; static const int kIBrowserServiceOnHttpEquivIndex = 30; +base::LazyInstance<base::ThreadLocalPointer<Bho> > + Bho::bho_current_thread_instance_(base::LINKER_INITIALIZED); + PatchHelper g_patch_helper; BEGIN_VTABLE_PATCHES(IBrowserService) @@ -64,6 +68,14 @@ STDMETHODIMP Bho::SetSite(IUnknown* site) { << " Site: " << site << " Error: " << hr; } } + // Save away our BHO instance in TLS which enables it to be referenced by + // our active document/activex instances to query referrer and other + // information for a URL. + AddRef(); + bho_current_thread_instance_.Pointer()->Set(this); + } else { + bho_current_thread_instance_.Pointer()->Set(NULL); + Release(); } return IObjectWithSiteImpl<Bho>::SetSite(site); @@ -113,6 +125,25 @@ STDMETHODIMP Bho::BeforeNavigate2(IDispatch* dispatch, VARIANT* url, } } } + + referrer_.clear(); + + // Save away the referrer in case our active document needs it to initiate + // navigation in chrome. + if (headers && V_VT(headers) == VT_BSTR && headers->bstrVal != NULL) { + std::string raw_headers_utf8 = WideToUTF8(headers->bstrVal); + std::string http_headers = + net::HttpUtil::AssembleRawHeaders(raw_headers_utf8.c_str(), + raw_headers_utf8.length()); + net::HttpUtil::HeadersIterator it(http_headers.begin(), http_headers.end(), + "\r\n"); + while (it.GetNext()) { + if (LowerCaseEqualsASCII(it.name(), "referer")) { + referrer_ = it.values(); + break; + } + } + } return S_OK; } @@ -211,6 +242,11 @@ HRESULT Bho::SwitchRenderer(IWebBrowser2* web_browser2, return S_OK; } +Bho* Bho::GetCurrentThreadBhoInstance() { + DCHECK(bho_current_thread_instance_.Pointer()->Get() != NULL); + return bho_current_thread_instance_.Pointer()->Get(); +} + void PatchHelper::InitializeAndPatchProtocolsIfNeeded() { if (state_ != UNKNOWN) return; |