diff options
-rw-r--r-- | chrome_frame/bho.cc | 28 | ||||
-rw-r--r-- | chrome_frame/bho.h | 5 | ||||
-rw-r--r-- | chrome_frame/chrome_tab.cc | 4 |
3 files changed, 24 insertions, 13 deletions
diff --git a/chrome_frame/bho.cc b/chrome_frame/bho.cc index f18cc3e..9fff456 100644 --- a/chrome_frame/bho.cc +++ b/chrome_frame/bho.cc @@ -247,19 +247,27 @@ Bho* Bho::GetCurrentThreadBhoInstance() { return bho_current_thread_instance_.Pointer()->Get(); } -void PatchHelper::InitializeAndPatchProtocolsIfNeeded() { - if (state_ != UNKNOWN) - return; +bool PatchHelper::InitializeAndPatchProtocolsIfNeeded() { + bool ret = false; - HttpNegotiatePatch::Initialize(); + _pAtlModule->m_csStaticDataInitAndTypeInfo.Lock(); - bool patch_protocol = GetConfigBool(true, kPatchProtocols); - if (patch_protocol) { - ProtocolSinkWrap::PatchProtocolHandlers(); - state_ = PATCH_PROTOCOL; - } else { - state_ = PATCH_IBROWSER; + if (state_ == UNKNOWN) { + HttpNegotiatePatch::Initialize(); + + bool patch_protocol = GetConfigBool(true, kPatchProtocols); + if (patch_protocol) { + ProtocolSinkWrap::PatchProtocolHandlers(); + state_ = PATCH_PROTOCOL; + } else { + state_ = PATCH_IBROWSER; + } + ret = true; } + + _pAtlModule->m_csStaticDataInitAndTypeInfo.Unlock(); + + return ret; } void PatchHelper::PatchBrowserService(IBrowserService* browser_service) { diff --git a/chrome_frame/bho.h b/chrome_frame/bho.h index b5b6ec5..2838fec 100644 --- a/chrome_frame/bho.h +++ b/chrome_frame/bho.h @@ -30,7 +30,10 @@ class PatchHelper { return state_; } - void InitializeAndPatchProtocolsIfNeeded(); + // Returns true if protocols were patched, false if patching has already + // been done. + bool InitializeAndPatchProtocolsIfNeeded(); + void PatchBrowserService(IBrowserService* p); void UnpatchIfNeeded(); protected: diff --git a/chrome_frame/chrome_tab.cc b/chrome_frame/chrome_tab.cc index 01d862a..39436f4 100644 --- a/chrome_frame/chrome_tab.cc +++ b/chrome_frame/chrome_tab.cc @@ -259,8 +259,8 @@ STDAPI DllCanUnloadNow() { // Returns a class factory to create an object of the requested type STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv) { - if (g_patch_helper.state() == PatchHelper::UNKNOWN) { - g_patch_helper.InitializeAndPatchProtocolsIfNeeded(); + if (g_patch_helper.InitializeAndPatchProtocolsIfNeeded()) { + // We should only get here once. UrlMkSetSessionOption(URLMON_OPTION_USERAGENT_REFRESH, NULL, 0, 0); } |