diff options
author | stoyan@chromium.org <stoyan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-21 15:52:24 +0000 |
---|---|---|
committer | stoyan@chromium.org <stoyan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-21 15:52:24 +0000 |
commit | ee54aec9e32601ca65bafc22d296ab778e85d17b (patch) | |
tree | fba28c455e2c690139159db9f45e882661c3901e /chrome_frame/chrome_tab.cc | |
parent | 6d22a976f77187252164baa27100e472d5a924b5 (diff) | |
download | chromium_src-ee54aec9e32601ca65bafc22d296ab778e85d17b.zip chromium_src-ee54aec9e32601ca65bafc22d296ab778e85d17b.tar.gz chromium_src-ee54aec9e32601ca65bafc22d296ab778e85d17b.tar.bz2 |
Fine grained registration for various Chrome Frame objects.
BUG=48987
Review URL: http://codereview.chromium.org/3010018
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@53191 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame/chrome_tab.cc')
-rw-r--r-- | chrome_frame/chrome_tab.cc | 106 |
1 files changed, 78 insertions, 28 deletions
diff --git a/chrome_frame/chrome_tab.cc b/chrome_frame/chrome_tab.cc index aa404b2..920adfd 100644 --- a/chrome_frame/chrome_tab.cc +++ b/chrome_frame/chrome_tab.cc @@ -300,54 +300,104 @@ STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv) { // that: if (g_dll_get_class_object_redir_ptr) { return g_dll_get_class_object_redir_ptr(rclsid, riid, ppv); - } else { + } + + // Enable sniffing and switching only if asked for BHO + // (we use BHO to get loaded in IE). + if (rclsid == CLSID_ChromeFrameBHO) { g_patch_helper.InitializeAndPatchProtocolsIfNeeded(); - return _AtlModule.DllGetClassObject(rclsid, riid, ppv); } + + return _AtlModule.DllGetClassObject(rclsid, riid, ppv); } -// DllRegisterServer - Adds entries to the system registry -STDAPI DllRegisterServer() { - // registers objects, typelib and all interfaces in typelib - HRESULT hr = _AtlModule.DllRegisterServer(TRUE); +enum RegistrationFlags { + ACTIVEX = 0x0001, + ACTIVEDOC = 0x0002, + GCF_PROTOCOL = 0x0004, + BHO_CLSID = 0x0008, + BHO_REGISTRATION = 0x0010, + TYPELIB = 0x0020, - if (SUCCEEDED(hr)) { - // Best effort attempt to register the BHO. At this point we silently - // ignore any errors during registration. There are some traces emitted - // to the debug log. - _AtlModule.UpdateRegistryFromResourceS(IDR_REGISTER_BHO, TRUE); - if (!RegisterSecuredMimeHandler(true)) - hr = E_FAIL; - SetupRunOnce(); + NPAPI_PLUGIN = 0x1000, + + ALL = 0xFFFF +}; + +STDAPI CustomRegistration(UINT reg_flags, BOOL reg) { + UINT flags = reg_flags; + + if (reg && (flags & (ACTIVEDOC | ACTIVEX))) + flags |= (TYPELIB |GCF_PROTOCOL); + + HRESULT hr = S_OK; + + if ((hr == S_OK) && (flags & ACTIVEDOC)) { + if (!RegisterSecuredMimeHandler(reg? true : false)) + return E_FAIL; + hr = ChromeActiveDocument::UpdateRegistry(reg); } - if (UtilIsPersistentNPAPIMarkerSet()) { - hr = _AtlModule.UpdateRegistryFromResourceS(IDR_CHROMEFRAME_NPAPI, TRUE); + if ((hr == S_OK) && (flags & ACTIVEX)) { + // We have to call the static T::UpdateRegistry function instead of + // _AtlModule.UpdateRegistryFromResourceS(IDR_CHROMEFRAME_ACTIVEX, reg) + // because there is specific OLEMISC replacement. + hr = ChromeFrameActivex::UpdateRegistry(reg); + } + + if ((hr == S_OK) && (flags & GCF_PROTOCOL)) { + hr = _AtlModule.UpdateRegistryFromResourceS(IDR_CHROMEPROTOCOL, reg); + } + + if ((hr == S_OK) && (flags & BHO_CLSID)) { + hr = Bho::UpdateRegistry(reg); + } + + if ((hr == S_OK) && (flags & BHO_REGISTRATION)) { + _AtlModule.UpdateRegistryFromResourceS(IDR_REGISTER_BHO, reg); + } + + if ((hr == S_OK) && (flags & TYPELIB)) { + hr = (reg)? _AtlComModule.RegisterTypeLib(): + _AtlComModule.UnRegisterTypeLib(); + } + + if ((hr == S_OK) && (flags & NPAPI_PLUGIN)) { + hr = _AtlModule.UpdateRegistryFromResourceS(IDR_CHROMEFRAME_NPAPI, reg); + } + + if (hr == S_OK) { + hr = _AtlModule.UpdateRegistryAppId(reg); } return hr; } -// DllUnregisterServer - Removes entries from the system registry -STDAPI DllUnregisterServer() { - HRESULT hr = _AtlModule.DllUnregisterServer(TRUE); - if (SUCCEEDED(hr)) { - // Best effort attempt to unregister the BHO. At this point we silently - // ignore any errors during unregistration. There are some traces emitted - // to the debug log. - _AtlModule.UpdateRegistryFromResourceS(IDR_REGISTER_BHO, FALSE); - if (!RegisterSecuredMimeHandler(false)) - hr = E_FAIL; + +// DllRegisterServer - Adds entries to the system registry +STDAPI DllRegisterServer() { + UINT flags = ACTIVEX | ACTIVEDOC | TYPELIB | GCF_PROTOCOL | + BHO_CLSID | BHO_REGISTRATION; + + if (UtilIsPersistentNPAPIMarkerSet()) { + flags |= IDR_CHROMEFRAME_NPAPI; } - if (UtilIsNPAPIPluginRegistered()) { - hr = _AtlModule.UpdateRegistryFromResourceS(IDR_CHROMEFRAME_NPAPI, FALSE); + HRESULT hr = CustomRegistration(flags, TRUE); + if (SUCCEEDED(hr)) { + SetupRunOnce(); } return hr; } +// DllUnregisterServer - Removes entries from the system registry +STDAPI DllUnregisterServer() { + HRESULT hr = CustomRegistration(ALL, FALSE); + return hr; +} + // Registers the NPAPI plugin and sets the persistent marker that tells us // to re-register it through updates. STDAPI RegisterNPAPIPlugin() { |