From e4e141d03e82e4918285711b7658e824e33b5107 Mon Sep 17 00:00:00 2001 From: "tommi@chromium.org" Date: Thu, 4 Feb 2010 21:34:50 +0000 Subject: Handle a case where the document is being served up from cache. In that case we have to get to the browser service object via a different set of QS calls. TEST=This is a part of the onhttpequiv effort. For now there won't be any visible changes since onhttpequiv is disabled but once it becomes enabled again, CF will be detected for cached pages as well as non-cached. BUG=none Review URL: http://codereview.chromium.org/573012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38132 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome_frame/http_negotiate.cc | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'chrome_frame') diff --git a/chrome_frame/http_negotiate.cc b/chrome_frame/http_negotiate.cc index 240d9ff..b8a1b9a 100644 --- a/chrome_frame/http_negotiate.cc +++ b/chrome_frame/http_negotiate.cc @@ -6,6 +6,7 @@ #include #include +#include #include "base/logging.h" #include "base/scoped_ptr.h" @@ -52,6 +53,8 @@ BEGIN_VTABLE_PATCHES(IInternetProtocolSink) HttpNegotiatePatch::ReportProgress) END_VTABLE_PATCHES() +namespace { + class SimpleBindStatusCallback : public CComObjectRootEx, public IBindStatusCallback { public: @@ -92,6 +95,28 @@ class SimpleBindStatusCallback : public CComObjectRootEx, } }; +// Attempts to get to the associated browser service for an active request. +HRESULT GetBrowserServiceFromProtocolSink(IInternetProtocolSink* sink, + IBrowserService** browser_service) { + DCHECK(browser_service); + // When fetching a page for the first time (not cached), we can query the + // sink directly for IID_IShellBrowser to get the browser service. + HRESULT hr = DoQueryService(IID_IShellBrowser, sink, browser_service); + if (FAILED(hr)) { + // When the request is being served up from the cache, we have to take + // a different route via IID_ITargetFrame2. + ScopedComPtr browser2; + hr = DoQueryService(IID_ITargetFrame2, sink, browser2.Receive()); + if (browser2) { + hr = DoQueryService(IID_IShellBrowser, browser2, browser_service); + } + } + + return hr; +} + +} // end namespace + HttpNegotiatePatch::HttpNegotiatePatch() { } @@ -286,7 +311,7 @@ HRESULT HttpNegotiatePatch::ReportProgress( if (is_top_level_request) { ScopedComPtr browser; - DoQueryService(IID_IShellBrowser, me, browser.Receive()); + GetBrowserServiceFromProtocolSink(me, browser.Receive()); if (browser) { render_in_chrome_frame = CheckForCFNavigation(browser, true); } -- cgit v1.1