| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #include <shobjidl.h> | 8 #include <shobjidl.h> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/registry.h" | 11 #include "base/registry.h" |
| 12 #include "base/scoped_bstr_win.h" | 12 #include "base/scoped_bstr_win.h" |
| 13 #include "base/scoped_comptr_win.h" | 13 #include "base/scoped_comptr_win.h" |
| 14 #include "base/scoped_variant_win.h" | 14 #include "base/scoped_variant_win.h" |
| 15 #include "base/string_util.h" | 15 #include "base/string_util.h" |
| 16 #include "chrome_tab.h" // NOLINT | 16 #include "chrome_tab.h" // NOLINT |
| 17 #include "chrome_frame/protocol_sink_wrap.h" | 17 #include "chrome_frame/protocol_sink_wrap.h" |
| 18 #include "chrome_frame/utils.h" | 18 #include "chrome_frame/utils.h" |
| 19 #include "chrome_frame/vtable_patch_manager.h" | 19 #include "chrome_frame/vtable_patch_manager.h" |
| 20 | 20 |
| 21 const wchar_t kUrlMonDllName[] = L"urlmon.dll"; | |
| 22 const wchar_t kPatchProtocols[] = L"PatchProtocols"; | 21 const wchar_t kPatchProtocols[] = L"PatchProtocols"; |
| 23 static const int kIBrowserServiceOnHttpEquivIndex = 30; | 22 static const int kIBrowserServiceOnHttpEquivIndex = 30; |
| 24 | 23 |
| 25 PatchHelper g_patch_helper; | 24 PatchHelper g_patch_helper; |
| 26 | 25 |
| 27 BEGIN_VTABLE_PATCHES(IBrowserService) | 26 BEGIN_VTABLE_PATCHES(IBrowserService) |
| 28 VTABLE_PATCH_ENTRY(kIBrowserServiceOnHttpEquivIndex, Bho::OnHttpEquiv) | 27 VTABLE_PATCH_ENTRY(kIBrowserServiceOnHttpEquivIndex, Bho::OnHttpEquiv) |
| 29 END_VTABLE_PATCHES() | 28 END_VTABLE_PATCHES() |
| 30 | 29 |
| 31 _ATL_FUNC_INFO Bho::kBeforeNavigate2Info = { | 30 _ATL_FUNC_INFO Bho::kBeforeNavigate2Info = { |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 | 209 |
| 211 return S_OK; | 210 return S_OK; |
| 212 } | 211 } |
| 213 | 212 |
| 214 void PatchHelper::InitializeAndPatchProtocolsIfNeeded() { | 213 void PatchHelper::InitializeAndPatchProtocolsIfNeeded() { |
| 215 if (state_ != UNKNOWN) | 214 if (state_ != UNKNOWN) |
| 216 return; | 215 return; |
| 217 | 216 |
| 218 bool patch_protocol = GetConfigBool(true, kPatchProtocols); | 217 bool patch_protocol = GetConfigBool(true, kPatchProtocols); |
| 219 if (patch_protocol) { | 218 if (patch_protocol) { |
| 220 ProtocolSinkWrap::PatchProtocolHandler(kUrlMonDllName, CLSID_HttpProtocol); | 219 ProtocolSinkWrap::PatchProtocolHandlers(); |
| 221 ProtocolSinkWrap::PatchProtocolHandler(kUrlMonDllName, CLSID_HttpSProtocol); | |
| 222 state_ = PATCH_PROTOCOL; | 220 state_ = PATCH_PROTOCOL; |
| 223 } else { | 221 } else { |
| 224 state_ = PATCH_IBROWSER; | 222 state_ = PATCH_IBROWSER; |
| 225 } | 223 } |
| 226 } | 224 } |
| 227 | 225 |
| 228 void PatchHelper::PatchBrowserService(IBrowserService* browser_service) { | 226 void PatchHelper::PatchBrowserService(IBrowserService* browser_service) { |
| 229 DCHECK(state_ == PATCH_IBROWSER); | 227 DCHECK(state_ == PATCH_IBROWSER); |
| 230 state_ = PATCH_IBROWSER_OK; | 228 state_ = PATCH_IBROWSER_OK; |
| 231 vtable_patch::PatchInterfaceMethods(browser_service, | 229 vtable_patch::PatchInterfaceMethods(browser_service, |
| 232 IBrowserService_PatchInfo); | 230 IBrowserService_PatchInfo); |
| 233 } | 231 } |
| 234 | 232 |
| 235 extern vtable_patch::MethodPatchInfo IInternetProtocol_PatchInfo[]; | |
| 236 extern vtable_patch::MethodPatchInfo IInternetProtocolEx_PatchInfo[]; | |
| 237 void PatchHelper::UnpatchIfNeeded() { | 233 void PatchHelper::UnpatchIfNeeded() { |
| 238 if (state_ == PATCH_PROTOCOL) { | 234 if (state_ == PATCH_PROTOCOL) { |
| 239 vtable_patch::UnpatchInterfaceMethods(IInternetProtocol_PatchInfo); | 235 ProtocolSinkWrap::UnpatchProtocolHandlers(); |
| 240 vtable_patch::UnpatchInterfaceMethods(IInternetProtocolEx_PatchInfo); | |
| 241 } else if (state_ == PATCH_IBROWSER_OK) { | 236 } else if (state_ == PATCH_IBROWSER_OK) { |
| 242 vtable_patch::UnpatchInterfaceMethods(IBrowserService_PatchInfo); | 237 vtable_patch::UnpatchInterfaceMethods(IBrowserService_PatchInfo); |
| 243 } | 238 } |
| 244 | 239 |
| 245 state_ = UNKNOWN; | 240 state_ = UNKNOWN; |
| 246 } | 241 } |
| 247 | 242 |
| OLD | NEW |