diff options
author | robertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-14 13:35:42 +0000 |
---|---|---|
committer | robertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-14 13:35:42 +0000 |
commit | 44a69f56d13585d17d3356d2a8b212a75fd14271 (patch) | |
tree | 5e4ee8be0799c1874fb72acc9e4132f3d5075cd7 /chrome_frame/chrome_tab.cc | |
parent | b7b1b932e27cf50c0b1dccb8c27eb2d689e2d262 (diff) | |
download | chromium_src-44a69f56d13585d17d3356d2a8b212a75fd14271.zip chromium_src-44a69f56d13585d17d3356d2a8b212a75fd14271.tar.gz chromium_src-44a69f56d13585d17d3356d2a8b212a75fd14271.tar.bz2 |
Add multi-version delegation to Chrome Frame such that CF will scan for older versions on load and delegate to them. This is to support clean upgrade scenarios whereby a new version is registered while IE is running.
BUG=40117
TEST=Register a new CF version while an old one is loaded in IE. Open a few new tabs and observe nothing bad happening.
Review URL: http://codereview.chromium.org/1562018
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44473 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame/chrome_tab.cc')
-rw-r--r-- | chrome_frame/chrome_tab.cc | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/chrome_frame/chrome_tab.cc b/chrome_frame/chrome_tab.cc index d8deec4..08e8a84 100644 --- a/chrome_frame/chrome_tab.cc +++ b/chrome_frame/chrome_tab.cc @@ -13,6 +13,7 @@ #include "base/command_line.h" #include "base/file_util.h" #include "base/file_version_info.h" +#include "base/lock.h" #include "base/logging.h" #include "base/logging_win.h" #include "base/path_service.h" @@ -30,6 +31,7 @@ #include "chrome_frame/chrome_frame_reporting.h" #include "chrome_frame/chrome_launcher.h" #include "chrome_frame/chrome_protocol.h" +#include "chrome_frame/module_utils.h" #include "chrome_frame/resource.h" #include "chrome_frame/utils.h" #include "googleurl/src/url_util.h" @@ -45,7 +47,6 @@ void InitGoogleUrl() { url_util::IsStandard(kDummyUrl, url_parse::MakeRange(0, arraysize(kDummyUrl))); } - } static const wchar_t kBhoRegistryPath[] = @@ -72,6 +73,11 @@ OBJECT_ENTRY_AUTO(__uuidof(ChromeActiveDocument), ChromeActiveDocument) OBJECT_ENTRY_AUTO(__uuidof(ChromeFrame), ChromeFrameActivex) OBJECT_ENTRY_AUTO(__uuidof(ChromeProtocol), ChromeProtocol) + +// See comments in DllGetClassObject. +DllRedirector g_dll_redirector; +Lock g_redirector_lock; + class ChromeTabModule : public AtlPerUserModule<CAtlDllModuleT<ChromeTabModule> > { public: @@ -316,12 +322,29 @@ 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.InitializeAndPatchProtocolsIfNeeded()) { - // We should only get here once. - UrlMkSetSessionOption(URLMON_OPTION_USERAGENT_REFRESH, NULL, 0, 0); + // On first call, we scan the loaded module list to see if an older version + // of Chrome Frame is already loaded. If it is, then we delegate all calls + // to DllGetClassObject to it. This is to avoid having instances of + // different versions of e.g. the BHO through an upgrade. It also prevents + // us from repeatedly patching. + LPFNGETCLASSOBJECT redir_ptr = NULL; + { + AutoLock lock(g_redirector_lock); + g_dll_redirector.EnsureInitialized(L"npchrome_frame.dll", + CLSID_ChromeActiveDocument); + redir_ptr = g_dll_redirector.get_dll_get_class_object_ptr(); } - return _AtlModule.DllGetClassObject(rclsid, riid, ppv); + if (redir_ptr) { + return redir_ptr(rclsid, riid, ppv); + } else { + if (g_patch_helper.InitializeAndPatchProtocolsIfNeeded()) { + // We should only get here once. + UrlMkSetSessionOption(URLMON_OPTION_USERAGENT_REFRESH, NULL, 0, 0); + } + + return _AtlModule.DllGetClassObject(rclsid, riid, ppv); + } } // DllRegisterServer - Adds entries to the system registry |