summaryrefslogtreecommitdiffstats
path: root/chrome_frame
diff options
context:
space:
mode:
authorrobertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-01 17:30:35 +0000
committerrobertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-01 17:30:35 +0000
commit59b34a7cac370c6f92f6acbb1b121b245acd56a7 (patch)
tree5fad61a21d9e669a0be8416d3c24d5235d26aaef /chrome_frame
parent47dbcd4e357f14f23ff42ffdd17a1711ee3d97f7 (diff)
downloadchromium_src-59b34a7cac370c6f92f6acbb1b121b245acd56a7.zip
chromium_src-59b34a7cac370c6f92f6acbb1b121b245acd56a7.tar.gz
chromium_src-59b34a7cac370c6f92f6acbb1b121b245acd56a7.tar.bz2
Add two new entry points to the Chrome Frame DLL to allow for non-admin registration.
BUG=53127 TEST=Can register the CF DLL with non-admin privileges when calling into the alternate registration entry points. Review URL: http://codereview.chromium.org/3190005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58197 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame')
-rw-r--r--chrome_frame/bho.rgs2
-rw-r--r--chrome_frame/chrome_active_document.rgs4
-rw-r--r--chrome_frame/chrome_frame_activex.rgs2
-rw-r--r--chrome_frame/chrome_frame_npapi.rgs2
-rw-r--r--chrome_frame/chrome_protocol.rgs4
-rw-r--r--chrome_frame/chrome_tab.cc82
-rw-r--r--chrome_frame/chrome_tab.def20
-rw-r--r--chrome_frame/chrome_tab.rgs2
8 files changed, 86 insertions, 32 deletions
diff --git a/chrome_frame/bho.rgs b/chrome_frame/bho.rgs
index ba057a6..25116e9 100644
--- a/chrome_frame/bho.rgs
+++ b/chrome_frame/bho.rgs
@@ -1,4 +1,4 @@
-HKLM {
+%HIVE% {
NoRemove SOFTWARE {
NoRemove Classes {
ChromeFrame.Bho.1 = s 'Bho Class' {
diff --git a/chrome_frame/chrome_active_document.rgs b/chrome_frame/chrome_active_document.rgs
index db44572..9890e05 100644
--- a/chrome_frame/chrome_active_document.rgs
+++ b/chrome_frame/chrome_active_document.rgs
@@ -1,4 +1,4 @@
-HKLM {
+%HIVE% {
NoRemove Software {
NoRemove Classes {
ChromeTab.ChromeActiveDocument.1 = s 'ChromeActiveDocument Class' {
@@ -34,7 +34,7 @@ HKLM {
}
}
-HKLM {
+%HIVE% {
NoRemove Software {
NoRemove Classes {
NoRemove MIME {
diff --git a/chrome_frame/chrome_frame_activex.rgs b/chrome_frame/chrome_frame_activex.rgs
index 342f520..94b5a51 100644
--- a/chrome_frame/chrome_frame_activex.rgs
+++ b/chrome_frame/chrome_frame_activex.rgs
@@ -1,4 +1,4 @@
-HKLM {
+%HIVE% {
NoRemove Software {
NoRemove Classes {
ChromeTab.ChromeFrame.1 = s 'Chrome Frame' {
diff --git a/chrome_frame/chrome_frame_npapi.rgs b/chrome_frame/chrome_frame_npapi.rgs
index 0841365..406c8c7 100644
--- a/chrome_frame/chrome_frame_npapi.rgs
+++ b/chrome_frame/chrome_frame_npapi.rgs
@@ -1,4 +1,4 @@
-HKLM {
+%HIVE% {
NoRemove Software {
NoRemove MozillaPlugins {
ForceRemove '@google.com/ChromeFrame,version=1.0' {
diff --git a/chrome_frame/chrome_protocol.rgs b/chrome_frame/chrome_protocol.rgs
index 9546973..289022e 100644
--- a/chrome_frame/chrome_protocol.rgs
+++ b/chrome_frame/chrome_protocol.rgs
@@ -1,4 +1,4 @@
-HKLM {
+%HIVE% {
NoRemove Software {
NoRemove Classes {
ChromeTab.ChromeProtocol.1 = s 'ChromeProtocol Class' {
@@ -24,7 +24,7 @@ HKLM {
}
}
-HKLM {
+%HIVE% {
NoRemove Software {
NoRemove Classes {
NoRemove Protocols {
diff --git a/chrome_frame/chrome_tab.cc b/chrome_frame/chrome_tab.cc
index ec6954b..d58c599 100644
--- a/chrome_frame/chrome_tab.cc
+++ b/chrome_frame/chrome_tab.cc
@@ -43,7 +43,7 @@
namespace {
// This function has the side effect of initializing an unprotected
// vector pointer inside GoogleUrl. If this is called during DLL loading,
-// it has the effect of avoiding an initializiation race on that pointer.
+// it has the effect of avoiding an initialization race on that pointer.
// TODO(siggi): fix GoogleUrl.
void InitGoogleUrl() {
static const char kDummyUrl[] = "http://www.google.com";
@@ -88,6 +88,8 @@ class ChromeTabModule : public CAtlDllModuleT<ChromeTabModule> {
public:
typedef CAtlDllModuleT<ChromeTabModule> ParentClass;
+ ChromeTabModule() : do_system_registration_(true) {}
+
DECLARE_LIBID(LIBID_ChromeTabLib)
DECLARE_REGISTRY_APPID_RESOURCEID(IDR_CHROMETAB,
"{FD9B1B31-F4D8-436A-8F4F-D3C2E36733D3}")
@@ -151,14 +153,32 @@ class ChromeTabModule : public CAtlDllModuleT<ChromeTabModule> {
DCHECK(SUCCEEDED(hr));
}
+ if (SUCCEEDED(hr)) {
+ // Add the registry hive to use.
+ // Note: This is ugly as hell. I'd rather use the pMapEntries parameter
+ // to CAtlModule::UpdateRegistryFromResource, unfortunately we have a
+ // few components that are registered by calling their
+ // static T::UpdateRegistry() methods directly, which doesn't allow
+ // pMapEntries to be passed through :-(
+ if (do_system_registration_) {
+ hr = registrar->AddReplacement(L"HIVE", L"HKLM");
+ } else {
+ hr = registrar->AddReplacement(L"HIVE", L"HKCU");
+ }
+ DCHECK(SUCCEEDED(hr));
+ }
+
return hr;
}
+
+ // See comments in AddCommonRGSReplacements
+ bool do_system_registration_;
};
ChromeTabModule _AtlModule;
base::AtExitManager* g_exit_manager = NULL;
-bool RegisterSecuredMimeHandler(bool enable); // forward
+bool RegisterSecuredMimeHandler(bool enable, bool is_system); // forward
// DLL Entry Point
extern "C" BOOL WINAPI DllMain(HINSTANCE instance,
@@ -325,7 +345,7 @@ enum RegistrationFlags {
ALL = 0xFFFF
};
-STDAPI CustomRegistration(UINT reg_flags, BOOL reg) {
+STDAPI CustomRegistration(UINT reg_flags, BOOL reg, bool is_system) {
UINT flags = reg_flags;
if (reg && (flags & (ACTIVEDOC | ACTIVEX)))
@@ -333,8 +353,15 @@ STDAPI CustomRegistration(UINT reg_flags, BOOL reg) {
HRESULT hr = S_OK;
+ // Set the flag that gets checked in AddCommonRGSReplacements before doing
+ // registration work.
+ _AtlModule.do_system_registration_ = is_system;
+
if ((hr == S_OK) && (flags & ACTIVEDOC)) {
- if (!RegisterSecuredMimeHandler(reg? true : false))
+ // Don't fail to unregister if we can't undo the secure mime
+ // handler registration. This was observed getting hit during
+ // uninstallation.
+ if (!RegisterSecuredMimeHandler(reg ? true : false, is_system) && reg)
return E_FAIL;
hr = ChromeActiveDocument::UpdateRegistry(reg);
}
@@ -357,13 +384,14 @@ STDAPI CustomRegistration(UINT reg_flags, BOOL reg) {
hr = Bho::UpdateRegistry(reg);
}
- if ((hr == S_OK) && (flags & BHO_REGISTRATION)) {
+ if ((hr == S_OK) && (flags & BHO_REGISTRATION) && !is_system) {
_AtlModule.UpdateRegistryFromResourceS(IDR_REGISTER_BHO, reg);
}
if ((hr == S_OK) && (flags & TYPELIB)) {
- hr = (reg)? _AtlComModule.RegisterTypeLib():
- _AtlComModule.UnRegisterTypeLib();
+ hr = (reg)?
+ UtilRegisterTypeLib(_AtlComModule.m_hInstTypeLib, NULL, !is_system) :
+ UtilUnRegisterTypeLib(_AtlComModule.m_hInstTypeLib, NULL, !is_system);
}
if ((hr == S_OK) && (flags & NPAPI_PLUGIN)) {
@@ -388,7 +416,7 @@ STDAPI DllRegisterServer() {
flags |= IDR_CHROMEFRAME_NPAPI;
}
- HRESULT hr = CustomRegistration(flags, TRUE);
+ HRESULT hr = CustomRegistration(flags, TRUE, true);
if (SUCCEEDED(hr)) {
SetupRunOnce();
}
@@ -398,7 +426,29 @@ STDAPI DllRegisterServer() {
// DllUnregisterServer - Removes entries from the system registry
STDAPI DllUnregisterServer() {
- HRESULT hr = CustomRegistration(ALL, FALSE);
+ HRESULT hr = CustomRegistration(ALL, FALSE, true);
+ return hr;
+}
+
+// DllRegisterServer - Adds entries to the HKCU hive in the registry
+STDAPI DllRegisterUserServer() {
+ UINT flags = ACTIVEX | ACTIVEDOC | TYPELIB | GCF_PROTOCOL | BHO_CLSID;
+
+ if (UtilIsPersistentNPAPIMarkerSet()) {
+ flags |= IDR_CHROMEFRAME_NPAPI;
+ }
+
+ HRESULT hr = CustomRegistration(flags, TRUE, false);
+ if (SUCCEEDED(hr)) {
+ SetupRunOnce();
+ }
+
+ return hr;
+}
+
+// DllRegisterServer - Removes entries from the HKCU hive in the registry.
+STDAPI DllUnregisterUserServer() {
+ HRESULT hr = CustomRegistration(ALL, FALSE, false);
return hr;
}
@@ -542,10 +592,10 @@ struct TokenWithPrivileges {
CSid user_;
};
-static bool SetOrDeleteMimeHandlerKey(bool set) {
+static bool SetOrDeleteMimeHandlerKey(bool set, HKEY root_key) {
std::wstring key_name = kInternetSettings;
key_name.append(L"\\Secure Mime Handlers");
- RegKey key(HKEY_LOCAL_MACHINE, key_name.c_str(), KEY_READ | KEY_WRITE);
+ RegKey key(root_key, key_name.c_str(), KEY_READ | KEY_WRITE);
if (!key.Valid())
return false;
@@ -561,9 +611,11 @@ static bool SetOrDeleteMimeHandlerKey(bool set) {
return result;
}
-bool RegisterSecuredMimeHandler(bool enable) {
- if (win_util::GetWinVersion() < win_util::WINVERSION_VISTA) {
- return SetOrDeleteMimeHandlerKey(enable);
+bool RegisterSecuredMimeHandler(bool enable, bool is_system) {
+ if (!is_system) {
+ return SetOrDeleteMimeHandlerKey(enable, HKEY_CURRENT_USER);
+ } else if (win_util::GetWinVersion() < win_util::WINVERSION_VISTA) {
+ return SetOrDeleteMimeHandlerKey(enable, HKEY_LOCAL_MACHINE);
}
std::wstring mime_key = kInternetSettings;
@@ -597,7 +649,7 @@ bool RegisterSecuredMimeHandler(bool enable) {
sd.GetDacl(&new_dacl);
new_dacl.AddAllowedAce(token_.GetUser(), GENERIC_WRITE | GENERIC_READ);
if (AtlSetDacl(object_name.c_str(), SE_REGISTRY_KEY, new_dacl)) {
- result = SetOrDeleteMimeHandlerKey(enable);
+ result = SetOrDeleteMimeHandlerKey(enable, HKEY_LOCAL_MACHINE);
}
}
diff --git a/chrome_frame/chrome_tab.def b/chrome_frame/chrome_tab.def
index cbea59f..6eea89e 100644
--- a/chrome_frame/chrome_tab.def
+++ b/chrome_frame/chrome_tab.def
@@ -3,12 +3,14 @@
LIBRARY "npchrome_frame.dll"
EXPORTS
- DllCanUnloadNow PRIVATE
- DllGetClassObject PRIVATE
- DllRegisterServer PRIVATE
- DllUnregisterServer PRIVATE
- NP_Initialize PRIVATE
- NP_GetEntryPoints PRIVATE
- NP_Shutdown PRIVATE
- RegisterNPAPIPlugin PRIVATE
- UnregisterNPAPIPlugin PRIVATE
+ DllCanUnloadNow PRIVATE
+ DllGetClassObject PRIVATE
+ DllRegisterServer PRIVATE
+ DllUnregisterServer PRIVATE
+ DllRegisterUserServer PRIVATE
+ DllUnregisterUserServer PRIVATE
+ NP_Initialize PRIVATE
+ NP_GetEntryPoints PRIVATE
+ NP_Shutdown PRIVATE
+ RegisterNPAPIPlugin PRIVATE
+ UnregisterNPAPIPlugin PRIVATE
diff --git a/chrome_frame/chrome_tab.rgs b/chrome_frame/chrome_tab.rgs
index 5e571ab..bea69ef 100644
--- a/chrome_frame/chrome_tab.rgs
+++ b/chrome_frame/chrome_tab.rgs
@@ -1,4 +1,4 @@
-HKLM {
+%HIVE% {
NoRemove Software {
NoRemove Classes {
NoRemove AppID {