summaryrefslogtreecommitdiffstats
path: root/chrome_frame
diff options
context:
space:
mode:
authorrobertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-11 20:39:18 +0000
committerrobertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-11 20:39:18 +0000
commitc41468f5e92ef7bcc7f223b809b9eab5ccf78635 (patch)
tree529f884cc317376e8972418a0e423603c303962c /chrome_frame
parentd62373fa58514f213ed116ae984eaae942dce018 (diff)
downloadchromium_src-c41468f5e92ef7bcc7f223b809b9eab5ccf78635.zip
chromium_src-c41468f5e92ef7bcc7f223b809b9eab5ccf78635.tar.gz
chromium_src-c41468f5e92ef7bcc7f223b809b9eab5ccf78635.tar.bz2
Add NPAPI plugin registration persistence code to chrome frame. If the DLL is already registered as an NPAPI plugin, keep that registration information up to date across updates.
Review URL: http://codereview.chromium.org/385015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31697 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame')
-rw-r--r--chrome_frame/chrome_tab.cc25
-rw-r--r--chrome_frame/utils.cc47
-rw-r--r--chrome_frame/utils.h10
3 files changed, 81 insertions, 1 deletions
diff --git a/chrome_frame/chrome_tab.cc b/chrome_frame/chrome_tab.cc
index 0c79b03..01d862a 100644
--- a/chrome_frame/chrome_tab.cc
+++ b/chrome_frame/chrome_tab.cc
@@ -126,9 +126,9 @@ extern "C" BOOL WINAPI DllMain(HINSTANCE instance,
ATL::CTrace::s_trace.ChangeCategory(atlTraceRegistrar, 0,
ATLTRACESTATUS_DISABLED);
#endif
+ g_exit_manager = new base::AtExitManager();
CommandLine::Init(0, NULL);
InitializeCrashReporting();
- g_exit_manager = new base::AtExitManager();
logging::InitLogging(NULL, logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG,
logging::LOCK_LOG_FILE, logging::DELETE_OLD_LOG_FILE);
} else if (reason == DLL_PROCESS_DETACH) {
@@ -281,6 +281,10 @@ STDAPI DllRegisterServer() {
hr = E_FAIL;
}
+ if (UtilIsPersistentNPAPIMarkerSet()) {
+ hr = _AtlModule.UpdateRegistryFromResourceS(IDR_CHROMEFRAME_NPAPI, TRUE);
+ }
+
return hr;
}
@@ -296,18 +300,37 @@ STDAPI DllUnregisterServer() {
if (!RegisterSecuredMimeHandler(false))
hr = E_FAIL;
}
+
+ if (UtilIsNPAPIPluginRegistered()) {
+ hr = _AtlModule.UpdateRegistryFromResourceS(IDR_CHROMEFRAME_NPAPI, FALSE);
+ }
+
return hr;
}
+// Registers the NPAPI plugin and sets the persistent marker that tells us
+// to re-register it through updates.
STDAPI RegisterNPAPIPlugin() {
HRESULT hr = _AtlModule.UpdateRegistryFromResourceS(IDR_CHROMEFRAME_NPAPI,
TRUE);
+ if (SUCCEEDED(hr)) {
+ if (!UtilChangePersistentNPAPIMarker(true)) {
+ hr = E_FAIL;
+ }
+ }
return hr;
}
+// Unregisters the NPAPI plugin and clears the persistent marker that tells us
+// to re-register it through updates.
STDAPI UnregisterNPAPIPlugin() {
HRESULT hr = _AtlModule.UpdateRegistryFromResourceS(IDR_CHROMEFRAME_NPAPI,
FALSE);
+ if (SUCCEEDED(hr)) {
+ if (!UtilChangePersistentNPAPIMarker(false)) {
+ hr = E_FAIL;
+ }
+ }
return hr;
}
diff --git a/chrome_frame/utils.cc b/chrome_frame/utils.cc
index 36200ae..aa24c1a 100644
--- a/chrome_frame/utils.cc
+++ b/chrome_frame/utils.cc
@@ -15,6 +15,7 @@
#include "base/scoped_comptr_win.h"
#include "base/string_util.h"
#include "chrome/common/url_constants.h"
+#include "chrome/installer/util/chrome_frame_distribution.h"
#include "googleurl/src/gurl.h"
#include "grit/chrome_frame_resources.h"
#include "chrome_frame/resource.h"
@@ -33,6 +34,10 @@ static const wchar_t kChromeFrameConfigKey[] =
L"Software\\Google\\ChromeFrame";
static const wchar_t kChromeFrameOptinUrlsKey[] = L"OptinUrls";
+static const wchar_t kChromeFrameNPAPIKey[] =
+ L"Software\\MozillaPlugins\\@google.com/ChromeFrame,version=1.0";
+static const wchar_t kChromeFramePersistNPAPIReg[] = L"PersistNPAPIReg";
+
// Used to isolate chrome frame builds from google chrome release channels.
const wchar_t kChromeFrameOmahaSuffix[] = L"-cf";
const wchar_t kDevChannelName[] = L"-dev";
@@ -145,6 +150,48 @@ HRESULT UtilUnRegisterTypeLib(ITypeLib* typelib,
return hr;
}
+bool UtilIsNPAPIPluginRegistered() {
+ std::wstring npapi_key_name(kChromeFrameNPAPIKey);
+ RegKey npapi_key(HKEY_LOCAL_MACHINE, npapi_key_name.c_str(), KEY_QUERY_VALUE);
+ return npapi_key.Valid();
+}
+
+bool UtilChangePersistentNPAPIMarker(bool set) {
+ BrowserDistribution* cf_dist = BrowserDistribution::GetDistribution();
+ std::wstring cf_state_key_path(cf_dist->GetStateKey());
+
+ RegKey cf_state_key(HKEY_LOCAL_MACHINE, cf_state_key_path.c_str(),
+ KEY_READ | KEY_WRITE);
+
+ bool success = false;
+ if (cf_state_key.Valid()) {
+ if (set) {
+ success = cf_state_key.WriteValue(kChromeFramePersistNPAPIReg, 1);
+ } else {
+ success = cf_state_key.DeleteValue(kChromeFramePersistNPAPIReg);
+ }
+ }
+ return success;
+}
+
+bool UtilIsPersistentNPAPIMarkerSet() {
+ BrowserDistribution* cf_dist = BrowserDistribution::GetDistribution();
+ std::wstring cf_state_key_path(cf_dist->GetStateKey());
+
+ RegKey cf_state_key(HKEY_LOCAL_MACHINE, cf_state_key_path.c_str(),
+ KEY_QUERY_VALUE);
+
+ bool success = false;
+ if (cf_state_key.Valid()) {
+ DWORD val = 0;
+ if (cf_state_key.ReadValueDW(kChromeFramePersistNPAPIReg, &val)) {
+ success = (val != 0);
+ }
+ }
+ return success;
+}
+
+
HRESULT UtilGetXUACompatContentValue(const std::wstring& html_string,
std::wstring* content_value) {
if (!content_value) {
diff --git a/chrome_frame/utils.h b/chrome_frame/utils.h
index fa6bec9..717ee4f 100644
--- a/chrome_frame/utils.h
+++ b/chrome_frame/utils.h
@@ -46,6 +46,16 @@ HRESULT UtilRegisterTypeLib(ITypeLib* typelib,
HRESULT UtilUnRegisterTypeLib(ITypeLib* typelib,
bool for_current_user_only);
+// Utility function to tell if the NPAPI plugin is registered.
+bool UtilIsNPAPIPluginRegistered();
+
+// Sets or clears a marker that causes NPAPI registration to persist across
+// updates. The marker is added if set is true and is deleted otherwise.
+bool UtilChangePersistentNPAPIMarker(bool set);
+
+// Returns true if the persistent NPAPI marker is set, false otherwise.
+bool UtilIsPersistentNPAPIMarkerSet();
+
// Given an HTML fragment, this function looks for the
// <meta http-equiv="X-UA-Compatible"> tag and extracts the value of the
// "content" attribute