summaryrefslogtreecommitdiffstats
path: root/chrome_frame/chrome_tab.cc
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/chrome_tab.cc
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/chrome_tab.cc')
-rw-r--r--chrome_frame/chrome_tab.cc82
1 files changed, 67 insertions, 15 deletions
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);
}
}