| 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/urlmon_moniker.h" | 5 #include "chrome_frame/urlmon_moniker.h" |
| 6 | 6 |
| 7 #include <shlguid.h> | 7 #include <shlguid.h> |
| 8 | 8 |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 BEGIN_VTABLE_PATCHES(IMoniker) | 27 BEGIN_VTABLE_PATCHES(IMoniker) |
| 28 VTABLE_PATCH_ENTRY(kMonikerBindToObject, MonikerPatch::BindToObject) | 28 VTABLE_PATCH_ENTRY(kMonikerBindToObject, MonikerPatch::BindToObject) |
| 29 VTABLE_PATCH_ENTRY(kMonikerBindToStorage, MonikerPatch::BindToStorage) | 29 VTABLE_PATCH_ENTRY(kMonikerBindToStorage, MonikerPatch::BindToStorage) |
| 30 END_VTABLE_PATCHES() | 30 END_VTABLE_PATCHES() |
| 31 | 31 |
| 32 //////////////////////////// | 32 //////////////////////////// |
| 33 | 33 |
| 34 HRESULT NavigationManager::NavigateToCurrentUrlInCF(IBrowserService* browser) { | 34 HRESULT NavigationManager::NavigateToCurrentUrlInCF(IBrowserService* browser) { |
| 35 DCHECK(browser); | 35 DCHECK(browser); |
| 36 DLOG(INFO) << __FUNCTION__ << " " << url(); | 36 DVLOG(1) << __FUNCTION__ << " " << url(); |
| 37 | 37 |
| 38 MarkBrowserOnThreadForCFNavigation(browser); | 38 MarkBrowserOnThreadForCFNavigation(browser); |
| 39 | 39 |
| 40 HRESULT hr = S_OK; | 40 HRESULT hr = S_OK; |
| 41 ScopedComPtr<IShellBrowser> shell_browser; | 41 ScopedComPtr<IShellBrowser> shell_browser; |
| 42 ScopedComPtr<IBindCtx> bind_context; | 42 ScopedComPtr<IBindCtx> bind_context; |
| 43 hr = ::CreateAsyncBindCtxEx(NULL, 0, NULL, NULL, bind_context.Receive(), 0); | 43 hr = ::CreateAsyncBindCtxEx(NULL, 0, NULL, NULL, bind_context.Receive(), 0); |
| 44 | 44 |
| 45 ScopedComPtr<IMoniker> moniker; | 45 ScopedComPtr<IMoniker> moniker; |
| 46 DCHECK(bind_context); | 46 DCHECK(bind_context); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 57 | 57 |
| 58 // Pass in URL fragments if applicable. | 58 // Pass in URL fragments if applicable. |
| 59 std::wstring fragment; | 59 std::wstring fragment; |
| 60 GURL parsed_moniker_url(url_); | 60 GURL parsed_moniker_url(url_); |
| 61 if (parsed_moniker_url.has_ref()) { | 61 if (parsed_moniker_url.has_ref()) { |
| 62 fragment = UTF8ToWide(parsed_moniker_url.ref()); | 62 fragment = UTF8ToWide(parsed_moniker_url.ref()); |
| 63 } | 63 } |
| 64 | 64 |
| 65 hr = NavigateBrowserToMoniker(browser, moniker, headers.c_str(), | 65 hr = NavigateBrowserToMoniker(browser, moniker, headers.c_str(), |
| 66 bind_context, fragment.c_str()); | 66 bind_context, fragment.c_str()); |
| 67 DLOG(INFO) << base::StringPrintf("NavigateBrowserToMoniker: 0x%08X", hr); | 67 DVLOG(1) << base::StringPrintf("NavigateBrowserToMoniker: 0x%08X", hr); |
| 68 } | 68 } |
| 69 } | 69 } |
| 70 | 70 |
| 71 return hr; | 71 return hr; |
| 72 } | 72 } |
| 73 | 73 |
| 74 bool NavigationManager::IsTopLevelUrl(const wchar_t* url) { | 74 bool NavigationManager::IsTopLevelUrl(const wchar_t* url) { |
| 75 return CompareUrlsWithoutFragment(url_.c_str(), url); | 75 return CompareUrlsWithoutFragment(url_.c_str(), url); |
| 76 } | 76 } |
| 77 | 77 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 | 115 |
| 116 // static | 116 // static |
| 117 void MonikerPatch::Uninitialize() { | 117 void MonikerPatch::Uninitialize() { |
| 118 vtable_patch::UnpatchInterfaceMethods(IMoniker_PatchInfo); | 118 vtable_patch::UnpatchInterfaceMethods(IMoniker_PatchInfo); |
| 119 } | 119 } |
| 120 | 120 |
| 121 bool ShouldWrapCallback(IMoniker* moniker, REFIID iid, IBindCtx* bind_context) { | 121 bool ShouldWrapCallback(IMoniker* moniker, REFIID iid, IBindCtx* bind_context) { |
| 122 CComHeapPtr<WCHAR> url; | 122 CComHeapPtr<WCHAR> url; |
| 123 HRESULT hr = moniker->GetDisplayName(bind_context, NULL, &url); | 123 HRESULT hr = moniker->GetDisplayName(bind_context, NULL, &url); |
| 124 if (!url) { | 124 if (!url) { |
| 125 DLOG(INFO) << __FUNCTION__ << base::StringPrintf( | 125 DVLOG(1) << __FUNCTION__ |
| 126 " GetDisplayName failed. Error: 0x%x", hr); | 126 << base::StringPrintf(" GetDisplayName failed. Error: 0x%x", hr); |
| 127 return false; | 127 return false; |
| 128 } | 128 } |
| 129 | 129 |
| 130 if (!IsEqualIID(IID_IStream, iid)) { | 130 if (!IsEqualIID(IID_IStream, iid)) { |
| 131 DLOG(INFO) << __FUNCTION__ << " Url: " << url << | 131 DVLOG(1) << __FUNCTION__ << " Url: " << url |
| 132 " Not wrapping: IID is not IStream."; | 132 << " Not wrapping: IID is not IStream."; |
| 133 return false; | 133 return false; |
| 134 } | 134 } |
| 135 | 135 |
| 136 ScopedComPtr<BindContextInfo> info; | 136 ScopedComPtr<BindContextInfo> info; |
| 137 BindContextInfo::FromBindContext(bind_context, info.Receive()); | 137 BindContextInfo::FromBindContext(bind_context, info.Receive()); |
| 138 DCHECK(info); | 138 DCHECK(info); |
| 139 if (info && info->chrome_request()) { | 139 if (info && info->chrome_request()) { |
| 140 DLOG(INFO) << __FUNCTION__ << " Url: " << url << | 140 DVLOG(1) << __FUNCTION__ << " Url: " << url |
| 141 " Not wrapping: request from chrome frame."; | 141 << " Not wrapping: request from chrome frame."; |
| 142 return false; | 142 return false; |
| 143 } | 143 } |
| 144 | 144 |
| 145 NavigationManager* mgr = NavigationManager::GetThreadInstance(); | 145 NavigationManager* mgr = NavigationManager::GetThreadInstance(); |
| 146 if (!mgr) { | 146 if (!mgr) { |
| 147 DLOG(INFO) << __FUNCTION__ << " Url: " << url << | 147 DVLOG(1) << __FUNCTION__ << " Url: " << url |
| 148 " No navigation manager to wrap"; | 148 << " No navigation manager to wrap"; |
| 149 return false; | 149 return false; |
| 150 } | 150 } |
| 151 | 151 |
| 152 // Check whether request comes from MSHTML by checking for IInternetBindInfo. | 152 // Check whether request comes from MSHTML by checking for IInternetBindInfo. |
| 153 // We prefer to avoid wrapping if BindToStorage is called from AcroPDF.dll | 153 // We prefer to avoid wrapping if BindToStorage is called from AcroPDF.dll |
| 154 // (as a result of OnObjectAvailable) | 154 // (as a result of OnObjectAvailable) |
| 155 ScopedComPtr<IUnknown> bscb_holder; | 155 ScopedComPtr<IUnknown> bscb_holder; |
| 156 if (S_OK == bind_context->GetObjectParam(L"_BSCB_Holder_", | 156 if (S_OK == bind_context->GetObjectParam(L"_BSCB_Holder_", |
| 157 bscb_holder.Receive())) { | 157 bscb_holder.Receive())) { |
| 158 ScopedComPtr<IBindStatusCallback> bscb; | 158 ScopedComPtr<IBindStatusCallback> bscb; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 176 // if (bscb_holder) { | 176 // if (bscb_holder) { |
| 177 // ScopedComPtr<IHttpNegotiate> http_negotiate; | 177 // ScopedComPtr<IHttpNegotiate> http_negotiate; |
| 178 // http_negotiate.QueryFrom(bscb_holder); | 178 // http_negotiate.QueryFrom(bscb_holder); |
| 179 // if (http_negotiate && !IsSubFrameRequest(http_negotiate)) | 179 // if (http_negotiate && !IsSubFrameRequest(http_negotiate)) |
| 180 // return true; | 180 // return true; |
| 181 // } | 181 // } |
| 182 // There are some cases where the IsSubFrameRequest function can return | 182 // There are some cases where the IsSubFrameRequest function can return |
| 183 // incorrect results. | 183 // incorrect results. |
| 184 bool should_wrap = mgr->IsTopLevelUrl(url); | 184 bool should_wrap = mgr->IsTopLevelUrl(url); |
| 185 if (!should_wrap) { | 185 if (!should_wrap) { |
| 186 DLOG(INFO) << __FUNCTION__ << " Url: " << url << | 186 DVLOG(1) << __FUNCTION__ << " Url: " << url |
| 187 " Not wrapping: Not top level url."; | 187 << " Not wrapping: Not top level url."; |
| 188 } | 188 } |
| 189 return should_wrap; | 189 return should_wrap; |
| 190 } | 190 } |
| 191 | 191 |
| 192 // static | 192 // static |
| 193 HRESULT MonikerPatch::BindToObject(IMoniker_BindToObject_Fn original, | 193 HRESULT MonikerPatch::BindToObject(IMoniker_BindToObject_Fn original, |
| 194 IMoniker* me, IBindCtx* bind_ctx, | 194 IMoniker* me, IBindCtx* bind_ctx, |
| 195 IMoniker* to_left, REFIID iid, void** obj) { | 195 IMoniker* to_left, REFIID iid, void** obj) { |
| 196 DLOG(INFO) << __FUNCTION__; | 196 DVLOG(1) << __FUNCTION__; |
| 197 DCHECK(to_left == NULL); | 197 DCHECK(to_left == NULL); |
| 198 | 198 |
| 199 ExceptionBarrierReportOnlyModule barrier; | 199 ExceptionBarrierReportOnlyModule barrier; |
| 200 | 200 |
| 201 HRESULT hr = S_OK; | 201 HRESULT hr = S_OK; |
| 202 // Bind context is marked for switch when we sniff data in BSCBStorageBind | 202 // Bind context is marked for switch when we sniff data in BSCBStorageBind |
| 203 // and determine that the renderer to be used is Chrome. | 203 // and determine that the renderer to be used is Chrome. |
| 204 ScopedComPtr<BindContextInfo> info; | 204 ScopedComPtr<BindContextInfo> info; |
| 205 BindContextInfo::FromBindContext(bind_ctx, info.Receive()); | 205 BindContextInfo::FromBindContext(bind_ctx, info.Receive()); |
| 206 DCHECK(info); | 206 DCHECK(info); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 | 249 |
| 250 // If the binding terminates before the data could be played back | 250 // If the binding terminates before the data could be played back |
| 251 // now is the chance. Sometimes OnStopBinding happens after this returns | 251 // now is the chance. Sometimes OnStopBinding happens after this returns |
| 252 // and then it's too late. | 252 // and then it's too late. |
| 253 if ((S_OK == hr) && callback) | 253 if ((S_OK == hr) && callback) |
| 254 callback->MayPlayBack(BSCF_LASTDATANOTIFICATION); | 254 callback->MayPlayBack(BSCF_LASTDATANOTIFICATION); |
| 255 | 255 |
| 256 return hr; | 256 return hr; |
| 257 } | 257 } |
| 258 | 258 |
| OLD | NEW |