OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome_frame/bho.h" | 5 #include "chrome_frame/bho.h" |
6 | 6 |
7 #include <shlguid.h> | 7 #include <shlguid.h> |
8 | 8 |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 | 111 |
112 ScopedComPtr<IWebBrowser2> web_browser2; | 112 ScopedComPtr<IWebBrowser2> web_browser2; |
113 if (dispatch) | 113 if (dispatch) |
114 web_browser2.QueryFrom(dispatch); | 114 web_browser2.QueryFrom(dispatch); |
115 | 115 |
116 if (!web_browser2) { | 116 if (!web_browser2) { |
117 NOTREACHED() << "Can't find WebBrowser2 with given dispatch"; | 117 NOTREACHED() << "Can't find WebBrowser2 with given dispatch"; |
118 return S_OK; | 118 return S_OK; |
119 } | 119 } |
120 | 120 |
121 DLOG(INFO) << "BeforeNavigate2: " << url->bstrVal; | 121 DVLOG(1) << "BeforeNavigate2: " << url->bstrVal; |
122 | 122 |
123 ScopedComPtr<IBrowserService> browser_service; | 123 ScopedComPtr<IBrowserService> browser_service; |
124 DoQueryService(SID_SShellBrowser, web_browser2, browser_service.Receive()); | 124 DoQueryService(SID_SShellBrowser, web_browser2, browser_service.Receive()); |
125 if (!browser_service || !CheckForCFNavigation(browser_service, false)) { | 125 if (!browser_service || !CheckForCFNavigation(browser_service, false)) { |
126 // TODO(tommi): Remove? Isn't this done below by calling set_referrer("")? | 126 // TODO(tommi): Remove? Isn't this done below by calling set_referrer("")? |
127 referrer_.clear(); | 127 referrer_.clear(); |
128 } | 128 } |
129 | 129 |
130 VARIANT_BOOL is_top_level = VARIANT_FALSE; | 130 VARIANT_BOOL is_top_level = VARIANT_FALSE; |
131 web_browser2->get_TopLevelContainer(&is_top_level); | 131 web_browser2->get_TopLevelContainer(&is_top_level); |
132 if (is_top_level) { | 132 if (is_top_level) { |
133 set_url(url->bstrVal); | 133 set_url(url->bstrVal); |
134 set_referrer(""); | 134 set_referrer(""); |
135 if (IsIBrowserServicePatchEnabled()) { | 135 if (IsIBrowserServicePatchEnabled()) { |
136 ProcessOptInUrls(web_browser2, url->bstrVal); | 136 ProcessOptInUrls(web_browser2, url->bstrVal); |
137 } | 137 } |
138 } | 138 } |
139 return S_OK; | 139 return S_OK; |
140 } | 140 } |
141 | 141 |
142 STDMETHODIMP_(void) Bho::NavigateComplete2(IDispatch* dispatch, VARIANT* url) { | 142 STDMETHODIMP_(void) Bho::NavigateComplete2(IDispatch* dispatch, VARIANT* url) { |
143 DLOG(INFO) << __FUNCTION__; | 143 DVLOG(1) << __FUNCTION__; |
144 } | 144 } |
145 | 145 |
146 STDMETHODIMP_(void) Bho::DocumentComplete(IDispatch* dispatch, VARIANT* url) { | 146 STDMETHODIMP_(void) Bho::DocumentComplete(IDispatch* dispatch, VARIANT* url) { |
147 DLOG(INFO) << __FUNCTION__; | 147 DVLOG(1) << __FUNCTION__; |
148 | 148 |
149 ScopedComPtr<IWebBrowser2> web_browser2; | 149 ScopedComPtr<IWebBrowser2> web_browser2; |
150 if (dispatch) | 150 if (dispatch) |
151 web_browser2.QueryFrom(dispatch); | 151 web_browser2.QueryFrom(dispatch); |
152 | 152 |
153 if (web_browser2) { | 153 if (web_browser2) { |
154 VARIANT_BOOL is_top_level = VARIANT_FALSE; | 154 VARIANT_BOOL is_top_level = VARIANT_FALSE; |
155 web_browser2->get_TopLevelContainer(&is_top_level); | 155 web_browser2->get_TopLevelContainer(&is_top_level); |
156 if (is_top_level) { | 156 if (is_top_level) { |
157 CrashMetricsReporter::GetInstance()->IncrementMetric( | 157 CrashMetricsReporter::GetInstance()->IncrementMetric( |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 } | 238 } |
239 | 239 |
240 return has_embedded_items; | 240 return has_embedded_items; |
241 } | 241 } |
242 | 242 |
243 } // end namespace | 243 } // end namespace |
244 | 244 |
245 HRESULT Bho::OnHttpEquiv(IBrowserService_OnHttpEquiv_Fn original_httpequiv, | 245 HRESULT Bho::OnHttpEquiv(IBrowserService_OnHttpEquiv_Fn original_httpequiv, |
246 IBrowserService* browser, IShellView* shell_view, BOOL done, | 246 IBrowserService* browser, IShellView* shell_view, BOOL done, |
247 VARIANT* in_arg, VARIANT* out_arg) { | 247 VARIANT* in_arg, VARIANT* out_arg) { |
248 DLOG(INFO) << __FUNCTION__ << " done:" << done; | 248 DVLOG(1) << __FUNCTION__ << " done:" << done; |
249 | 249 |
250 // OnHttpEquiv with 'done' set to TRUE is called for all pages. | 250 // OnHttpEquiv with 'done' set to TRUE is called for all pages. |
251 // 0 or more calls with done set to FALSE are made. | 251 // 0 or more calls with done set to FALSE are made. |
252 // When done is FALSE, the current moniker may not represent the page | 252 // When done is FALSE, the current moniker may not represent the page |
253 // being navigated to so we always have to wait for done to be TRUE | 253 // being navigated to so we always have to wait for done to be TRUE |
254 // before re-initiating the navigation. | 254 // before re-initiating the navigation. |
255 | 255 |
256 if (!done && in_arg && VT_BSTR == V_VT(in_arg)) { | 256 if (!done && in_arg && VT_BSTR == V_VT(in_arg)) { |
257 if (StrStrI(V_BSTR(in_arg), kChromeContentPrefix)) { | 257 if (StrStrI(V_BSTR(in_arg), kChromeContentPrefix)) { |
258 // OnHttpEquiv is invoked for meta tags within sub frames as well. | 258 // OnHttpEquiv is invoked for meta tags within sub frames as well. |
259 // We want to switch renderers only for the top level frame. | 259 // We want to switch renderers only for the top level frame. |
260 // The theory here is that if there are any existing embedded items | 260 // The theory here is that if there are any existing embedded items |
261 // (frames or iframes) in the current document, then the http-equiv | 261 // (frames or iframes) in the current document, then the http-equiv |
262 // notification is coming from those and not the top level document. | 262 // notification is coming from those and not the top level document. |
263 // The embedded items should only be created once the top level | 263 // The embedded items should only be created once the top level |
264 // doc has been created. | 264 // doc has been created. |
265 if (!DocumentHasEmbeddedItems(browser)) { | 265 if (!DocumentHasEmbeddedItems(browser)) { |
266 NavigationManager* mgr = NavigationManager::GetThreadInstance(); | 266 NavigationManager* mgr = NavigationManager::GetThreadInstance(); |
267 DCHECK(mgr); | 267 DCHECK(mgr); |
268 DLOG(INFO) << "Found tag in page. Marking browser." << | 268 DVLOG(1) << "Found tag in page. Marking browser." |
269 base::StringPrintf(" tid=0x%08X", ::GetCurrentThreadId()); | 269 << base::StringPrintf(" tid=0x%08X", ::GetCurrentThreadId()); |
270 if (mgr) { | 270 if (mgr) { |
271 // TODO(tommi): See if we can't figure out a cleaner way to avoid | 271 // TODO(tommi): See if we can't figure out a cleaner way to avoid |
272 // this. For some documents we can hit a problem here. When we | 272 // this. For some documents we can hit a problem here. When we |
273 // attempt to navigate the document again in CF, mshtml can "complete" | 273 // attempt to navigate the document again in CF, mshtml can "complete" |
274 // the current navigation (if all data is available) and fire off | 274 // the current navigation (if all data is available) and fire off |
275 // script events such as onload and even render the page. | 275 // script events such as onload and even render the page. |
276 // This will happen inside NavigateBrowserToMoniker below. | 276 // This will happen inside NavigateBrowserToMoniker below. |
277 // To work around this, we clear the contents of the document before | 277 // To work around this, we clear the contents of the document before |
278 // opening it up in CF. | 278 // opening it up in CF. |
279 ClearDocumentContents(browser); | 279 ClearDocumentContents(browser); |
(...skipping 17 matching lines...) Expand all Loading... |
297 // This check must already have been made. | 297 // This check must already have been made. |
298 VARIANT_BOOL is_top_level = VARIANT_FALSE; | 298 VARIANT_BOOL is_top_level = VARIANT_FALSE; |
299 browser->get_TopLevelContainer(&is_top_level); | 299 browser->get_TopLevelContainer(&is_top_level); |
300 DCHECK(is_top_level); | 300 DCHECK(is_top_level); |
301 #endif | 301 #endif |
302 | 302 |
303 std::wstring current_url(url, SysStringLen(url)); | 303 std::wstring current_url(url, SysStringLen(url)); |
304 if (IsValidUrlScheme(GURL(current_url), false)) { | 304 if (IsValidUrlScheme(GURL(current_url), false)) { |
305 bool cf_protocol = StartsWith(current_url, kChromeProtocolPrefix, false); | 305 bool cf_protocol = StartsWith(current_url, kChromeProtocolPrefix, false); |
306 if (!cf_protocol && IsChrome(RendererTypeForUrl(current_url))) { | 306 if (!cf_protocol && IsChrome(RendererTypeForUrl(current_url))) { |
307 DLOG(INFO) << "Opt-in URL. Switching to cf."; | 307 DVLOG(1) << "Opt-in URL. Switching to cf."; |
308 ScopedComPtr<IBrowserService> browser_service; | 308 ScopedComPtr<IBrowserService> browser_service; |
309 DoQueryService(SID_SShellBrowser, browser, browser_service.Receive()); | 309 DoQueryService(SID_SShellBrowser, browser, browser_service.Receive()); |
310 DCHECK(browser_service) << "DoQueryService - SID_SShellBrowser failed."; | 310 DCHECK(browser_service) << "DoQueryService - SID_SShellBrowser failed."; |
311 MarkBrowserOnThreadForCFNavigation(browser_service); | 311 MarkBrowserOnThreadForCFNavigation(browser_service); |
312 } | 312 } |
313 } | 313 } |
314 } | 314 } |
315 | 315 |
316 bool PatchHelper::InitializeAndPatchProtocolsIfNeeded() { | 316 bool PatchHelper::InitializeAndPatchProtocolsIfNeeded() { |
317 bool ret = false; | 317 bool ret = false; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 } else if (state_ == PATCH_IBROWSER) { | 355 } else if (state_ == PATCH_IBROWSER) { |
356 vtable_patch::UnpatchInterfaceMethods(IBrowserService_PatchInfo); | 356 vtable_patch::UnpatchInterfaceMethods(IBrowserService_PatchInfo); |
357 MonikerPatch::Uninitialize(); | 357 MonikerPatch::Uninitialize(); |
358 HttpNegotiatePatch::Uninitialize(); | 358 HttpNegotiatePatch::Uninitialize(); |
359 } else { | 359 } else { |
360 HttpNegotiatePatch::Uninitialize(); | 360 HttpNegotiatePatch::Uninitialize(); |
361 } | 361 } |
362 | 362 |
363 state_ = UNKNOWN; | 363 state_ = UNKNOWN; |
364 } | 364 } |
OLD | NEW |