summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/installer/util/install_util.cc11
-rw-r--r--chrome/installer/util/install_util.h3
-rw-r--r--chrome/installer/util/util_constants.cc1
-rw-r--r--chrome/installer/util/util_constants.h1
-rw-r--r--chrome_frame/chrome_tab.cc25
-rw-r--r--chrome_frame/utils.cc47
-rw-r--r--chrome_frame/utils.h10
7 files changed, 95 insertions, 3 deletions
diff --git a/chrome/installer/util/install_util.cc b/chrome/installer/util/install_util.cc
index c5d3e80..25f3046b 100644
--- a/chrome/installer/util/install_util.cc
+++ b/chrome/installer/util/install_util.cc
@@ -15,6 +15,7 @@
#include "base/command_line.h"
#include "base/file_util.h"
#include "base/logging.h"
+#include "base/path_service.h"
#include "base/registry.h"
#include "base/scoped_ptr.h"
#include "base/string_util.h"
@@ -133,7 +134,15 @@ bool InstallUtil::IsChromeFrameProcess() {
CommandLine* command_line = CommandLine::ForCurrentProcess();
DCHECK(command_line)
<< "IsChromeFrameProcess() called before ComamandLine::Init()";
- return command_line->HasSwitch(installer_util::switches::kChromeFrame);
+
+ // Also assume this to be a ChromeFrame process if we are running inside
+ // the Chrome Frame DLL.
+ FilePath module_path;
+ PathService::Get(base::FILE_MODULE, &module_path);
+ std::wstring module_name(module_path.BaseName().value());
+
+ return command_line->HasSwitch(installer_util::switches::kChromeFrame) ||
+ module_name == installer_util::kChromeFrameDll;
}
bool InstallUtil::BuildDLLRegistrationList(const std::wstring& install_path,
diff --git a/chrome/installer/util/install_util.h b/chrome/installer/util/install_util.h
index 3ce4166..8f9e0d8 100644
--- a/chrome/installer/util/install_util.h
+++ b/chrome/installer/util/install_util.h
@@ -56,7 +56,8 @@ class InstallUtil {
static bool IsPerUserInstall(const wchar_t* const exe_path);
// Returns true if this is a Chrome Frame installation (as indicated by the
- // presence of --chrome-frame on the command line).
+ // presence of --chrome-frame on the command line) or if this is running
+ // inside of the Chrome Frame dll.
static bool IsChromeFrameProcess();
// Adds all DLLs in install_path whose names are given by dll_names to a
diff --git a/chrome/installer/util/util_constants.cc b/chrome/installer/util/util_constants.cc
index 046acfe..64544c4 100644
--- a/chrome/installer/util/util_constants.cc
+++ b/chrome/installer/util/util_constants.cc
@@ -113,6 +113,7 @@ const wchar_t kChromeExe[] = L"chrome.exe";
const wchar_t kChromeOldExe[] = L"old_chrome.exe";
const wchar_t kChromeNewExe[] = L"new_chrome.exe";
const wchar_t kChromeDll[] = L"chrome.dll";
+const wchar_t kChromeFrameDll[] = L"npchrome_tab.dll";
const wchar_t kSetupExe[] = L"setup.exe";
const wchar_t kInstallerDir[] = L"Installer";
diff --git a/chrome/installer/util/util_constants.h b/chrome/installer/util/util_constants.h
index d10a585..d781be2 100644
--- a/chrome/installer/util/util_constants.h
+++ b/chrome/installer/util/util_constants.h
@@ -79,6 +79,7 @@ extern const wchar_t kChromeExe[];
extern const wchar_t kChromeOldExe[];
extern const wchar_t kChromeNewExe[];
extern const wchar_t kChromeDll[];
+extern const wchar_t kChromeFrameDll[];
extern const wchar_t kSetupExe[];
extern const wchar_t kInstallerDir[];
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