summaryrefslogtreecommitdiffstats
path: root/chrome_frame/protocol_sink_wrap.cc
diff options
context:
space:
mode:
authortommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-03 01:14:45 +0000
committertommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-03 01:14:45 +0000
commitc9555c02cfaa69a50eff610edad10bbab938976a (patch)
treea58159189529a195f808da586683dfe8a95893e8 /chrome_frame/protocol_sink_wrap.cc
parentaca3e9b6ab27f5606b8b4ad6fcc27f0f0bc91f6e (diff)
downloadchromium_src-c9555c02cfaa69a50eff610edad10bbab938976a.zip
chromium_src-c9555c02cfaa69a50eff610edad10bbab938976a.tar.gz
chromium_src-c9555c02cfaa69a50eff610edad10bbab938976a.tar.bz2
Don't switch to CF's active document for frames or iframes.This fixes an issue where a page that uses CF would be loaded in an IFRAME on Google Images.Instead of attempting to load CF (not supported), we now defer to the host browser. Previously a blank page was displayed.TEST=Run new unit tests: FullTabModeIE_SubIFrame and FullTabModeIE_SubFrameBUG=22989
Review URL: http://codereview.chromium.org/343086 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30782 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame/protocol_sink_wrap.cc')
-rw-r--r--chrome_frame/protocol_sink_wrap.cc59
1 files changed, 40 insertions, 19 deletions
diff --git a/chrome_frame/protocol_sink_wrap.cc b/chrome_frame/protocol_sink_wrap.cc
index 287cd36..9888209 100644
--- a/chrome_frame/protocol_sink_wrap.cc
+++ b/chrome_frame/protocol_sink_wrap.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include <htiframe.h>
+#include <mshtml.h>
#include "chrome_frame/protocol_sink_wrap.h"
@@ -609,31 +610,51 @@ scoped_refptr<ProtocolSinkWrap> ProtocolSinkWrap::InstanceFromProtocol(
return instance;
}
-HRESULT ProtocolSinkWrap::WebBrowserFromProtocolSink(
- IInternetProtocolSink* sink, IWebBrowser2** web_browser) {
- // TODO(tommi): GUID_NULL doesn't work when loading from history.
- // asking for IID_IHttpNegotiate as the service id works, but
- // getting the IWebBrowser2 interface still doesn't work.
- ScopedComPtr<IHttpNegotiate> http_negotiate;
- HRESULT hr = DoQueryService(GUID_NULL, sink, http_negotiate.Receive());
- if (http_negotiate)
- hr = DoQueryService(IID_ITargetFrame2, http_negotiate, web_browser);
-
- return hr;
-}
-
ScopedComPtr<IInternetProtocolSink> ProtocolSinkWrap::MaybeWrapSink(
IInternetProtocol* protocol, IInternetProtocolSink* prot_sink,
const wchar_t* url) {
ScopedComPtr<IInternetProtocolSink> sink_to_use(prot_sink);
ScopedComPtr<IWebBrowser2> web_browser;
- WebBrowserFromProtocolSink(prot_sink, web_browser.Receive());
+
+ // FYI: GUID_NULL doesn't work when the URL is being loaded from history.
+ // asking for IID_IHttpNegotiate as the service id works, but
+ // getting the IWebBrowser2 interface still doesn't work.
+ ScopedComPtr<IHttpNegotiate> http_negotiate;
+ HRESULT hr = DoQueryService(GUID_NULL, prot_sink, http_negotiate.Receive());
+ if (http_negotiate) {
+ hr = DoQueryService(IID_ITargetFrame2, http_negotiate,
+ web_browser.Receive());
+ }
+
if (web_browser) {
- CComObject<ProtocolSinkWrap>* wrap = NULL;
- CComObject<ProtocolSinkWrap>::CreateInstance(&wrap);
- DCHECK(wrap);
- if (wrap->Initialize(protocol, prot_sink, url)) {
- sink_to_use = wrap;
+ // Do one more check to make sure we don't wrap requests that are
+ // targeted to sub frames.
+ // For a use case, see FullTabModeIE_SubIFrame and FullTabModeIE_SubFrame
+ // unit tests.
+
+ // Default should_wrap to true in case no window is available.
+ // In that case this request is a top level request.
+ bool should_wrap = true;
+
+ ScopedComPtr<IHTMLWindow2> current_frame, parent_frame;
+ hr = DoQueryService(IID_IHTMLWindow2, http_negotiate,
+ current_frame.Receive());
+ if (current_frame) {
+ // Only the top level window will return self when get_parent is called.
+ current_frame->get_parent(parent_frame.Receive());
+ if (parent_frame != current_frame) {
+ DLOG(INFO) << "Sub frame detected";
+ should_wrap = false;
+ }
+ }
+
+ if (should_wrap) {
+ CComObject<ProtocolSinkWrap>* wrap = NULL;
+ CComObject<ProtocolSinkWrap>::CreateInstance(&wrap);
+ DCHECK(wrap);
+ if (wrap->Initialize(protocol, prot_sink, url)) {
+ sink_to_use = wrap;
+ }
}
}