summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-04 03:39:22 +0000
committercpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-04 03:39:22 +0000
commit4512f3acc3dab73e7fdcb8371d13f7bf46d8484b (patch)
treeb422b0d7be3ae72a1b53ce5822054a440bcc668f
parent3002a3d7dd1cf42d481c8fd626d872e93677a789 (diff)
downloadchromium_src-4512f3acc3dab73e7fdcb8371d13f7bf46d8484b.zip
chromium_src-4512f3acc3dab73e7fdcb8371d13f7bf46d8484b.tar.gz
chromium_src-4512f3acc3dab73e7fdcb8371d13f7bf46d8484b.tar.bz2
Rewrite of chrome.exe startup code
A lot of cruft and repeated code has deposited over the years on chrome's initialization code. This CL makes it all much more clear and straightforward. There is no fundamental change of behavior except the order of certain things is different but it should not alter the observed operation. - chrome's and chromium load is fundamentally the same but most of the code was repeated - chrome's way to load the dll was incorrect: using a relative path with LOAD_WITH_ALTERED_SEARCH_PATH - Use of SearchPath() was dangerous and not needed - removed google_update_client.cc and .h - removed bunch of #ifdefs TEST=all convered by UI tests already except [1] BUG=none [1] The only thing I don't see convered by test is the restart dialog ('woa! chrome crashed'). Review URL: http://codereview.chromium.org/345036 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30934 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/app/breakpad_win.cc2
-rw-r--r--chrome/app/chrome_exe_main.cc95
-rw-r--r--chrome/app/client_util.cc231
-rw-r--r--chrome/app/client_util.h68
-rw-r--r--chrome/app/google_update_client.cc135
-rw-r--r--chrome/app/google_update_client.h81
-rw-r--r--chrome/browser/google_update.cc1
-rwxr-xr-xchrome/chrome.gyp3
8 files changed, 225 insertions, 391 deletions
diff --git a/chrome/app/breakpad_win.cc b/chrome/app/breakpad_win.cc
index 1793535..82122bb 100644
--- a/chrome/app/breakpad_win.cc
+++ b/chrome/app/breakpad_win.cc
@@ -16,7 +16,6 @@
#include "base/registry.h"
#include "base/string_util.h"
#include "base/win_util.h"
-#include "chrome/app/google_update_client.h"
#include "chrome/app/hard_error_handler_win.h"
#include "chrome/common/env_vars.h"
#include "chrome/common/result_codes.h"
@@ -53,7 +52,6 @@ std::wstring TrimToBreakpadMax(const std::wstring& str) {
// Returns the custom info structure based on the dll in parameter and the
// process type.
-static google_breakpad::CustomClientInfo* custom_info = NULL;
google_breakpad::CustomClientInfo* GetCustomInfo(const std::wstring& dll_path,
const std::wstring& type) {
scoped_ptr<FileVersionInfo>
diff --git a/chrome/app/chrome_exe_main.cc b/chrome/app/chrome_exe_main.cc
index 33fc669..c0d1769 100644
--- a/chrome/app/chrome_exe_main.cc
+++ b/chrome/app/chrome_exe_main.cc
@@ -6,103 +6,46 @@
#include <tchar.h>
#include "base/at_exit.h"
-#include "base/base_switches.h"
#include "base/command_line.h"
-#include "base/debug_on_start.h"
-#include "base/process_util.h"
#include "base/win_util.h"
#include "chrome/app/breakpad_win.h"
#include "chrome/app/client_util.h"
-#include "chrome/app/google_update_client.h"
-#include "chrome/common/chrome_switches.h"
#include "chrome/common/result_codes.h"
-#include "sandbox/src/sandbox_factory.h"
#include "sandbox/src/dep.h"
+#include "sandbox/src/sandbox_factory.h"
-// Generataed header containing the Google Update appid.
-#include "appid.h"
-int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE prev_instance,
- wchar_t* command_line, int) {
+int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t*, int) {
base::EnableTerminationOnHeapCorruption();
// The exit manager is in charge of calling the dtors of singletons.
base::AtExitManager exit_manager;
- win_util::WinVersion win_version = win_util::GetWinVersion();
- if (win_version < win_util::WINVERSION_VISTA) {
- // On Vista, this is unnecessary since it is controlled through the
- // /NXCOMPAT linker flag.
- // Enforces strong DEP support.
- sandbox::SetCurrentProcessDEP(sandbox::DEP_ENABLED);
+ bool exit_now = true;
+ // We restarted because of a previous crash. Ask user if we should relaunch.
+ if (ShowRestartDialogIfCrashed(&exit_now)) {
+ if (exit_now)
+ return ResultCodes::NORMAL_EXIT;
}
- // Get the interface pointer to the BrokerServices or TargetServices,
- // depending who we are.
+ // Initialize the commandline singleton from the environment.
+ CommandLine::Init(0, NULL);
+
+ // Initialize the sandbox services.
sandbox::SandboxInterfaceInfo sandbox_info = {0};
sandbox_info.broker_services = sandbox::SandboxFactory::GetBrokerServices();
if (!sandbox_info.broker_services)
sandbox_info.target_services = sandbox::SandboxFactory::GetTargetServices();
- CommandLine::Init(0, NULL);
-
- const wchar_t* dll_name = L"chrome.dll";
- std::wstring dll_full_path;
- std::wstring versionned_path;
-
-#if defined(GOOGLE_CHROME_BUILD)
- google_update::GoogleUpdateClient client;
-
- // TODO(erikkay): verify client.Init() return value for official builds
- client.Init(google_update::kChromeGuid, dll_name);
- dll_full_path = client.GetDLLFullPath();
- versionned_path = client.GetDLLPath();
-#else
- std::wstring exe_path = client_util::GetExecutablePath();
- wchar_t *version;
- if (client_util::GetChromiumVersion(exe_path.c_str(), L"Software\\Chromium",
- &version)) {
- versionned_path = exe_path;
- versionned_path.append(version);
- delete[] version;
- }
-
- dll_full_path = client_util::GetDLLPath(dll_name, versionned_path);
-#endif
-
- // If the versionned path exists, we set the current directory to this path.
- if (client_util::FileExists(versionned_path)) {
- ::SetCurrentDirectory(versionned_path.c_str());
- }
-
- HINSTANCE dll_handle = ::LoadLibraryEx(dll_name, NULL,
- LOAD_WITH_ALTERED_SEARCH_PATH);
-
- // Initialize the crash reporter.
- InitCrashReporterWithDllPath(dll_full_path);
-
- bool exit_now = true;
- if (ShowRestartDialogIfCrashed(&exit_now)) {
- // We have restarted because of a previous crash. The user might
- // decide that he does not want to continue.
- if (exit_now)
- return ResultCodes::NORMAL_EXIT;
+ if (win_util::GetWinVersion() < win_util::WINVERSION_VISTA) {
+ // Enforces strong DEP support. Vista uses the NXCOMPAT flag in the exe.
+ sandbox::SetCurrentProcessDEP(sandbox::DEP_ENABLED);
}
-#if defined(GOOGLE_CHROME_BUILD)
- int ret = 0;
- if (client.Launch(instance, &sandbox_info, command_line, "ChromeMain",
- &ret)) {
- return ret;
- }
-#else
- if (NULL != dll_handle) {
- client_util::DLL_MAIN entry = reinterpret_cast<client_util::DLL_MAIN>(
- ::GetProcAddress(dll_handle, "ChromeMain"));
- if (NULL != entry)
- return (entry)(instance, &sandbox_info, command_line);
- }
-#endif
+ // Load and launch the chrome dll. *Everything* happens inside.
+ MainDllLoader* loader = MakeMainDllLoader();
+ int rc = loader->Launch(instance, &sandbox_info);
+ delete loader;
- return ResultCodes::GOOGLE_UPDATE_LAUNCH_FAILED;
+ return rc;
}
diff --git a/chrome/app/client_util.cc b/chrome/app/client_util.cc
index 0fd1c94..9f8716f 100644
--- a/chrome/app/client_util.cc
+++ b/chrome/app/client_util.cc
@@ -2,96 +2,201 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <windows.h>
+#include <shlwapi.h>
+
+#include "chrome/app/breakpad_win.h"
#include "chrome/app/client_util.h"
+#include "chrome/common/result_codes.h"
#include "chrome/installer/util/install_util.h"
-
#include "chrome/installer/util/google_update_constants.h"
#include "chrome/installer/util/util_constants.h"
namespace {
-bool ReadStrValueFromRegistry(const HKEY reg_key,
- const wchar_t* const value_name,
- wchar_t** value) {
- DWORD size = 0;
- if (::RegQueryValueEx(reg_key, value_name, NULL, NULL, NULL,
- &size) != ERROR_SUCCESS) {
- return false;
- }
+// The entry point signature of chrome.dll.
+typedef int (*DLL_MAIN)(HINSTANCE, sandbox::SandboxInterfaceInfo*, wchar_t*);
- *value = new wchar_t[1 + (size / sizeof(wchar_t))];
- if (::RegQueryValueEx(reg_key, value_name, NULL, NULL,
- reinterpret_cast<BYTE*>(*value),
- &size) != ERROR_SUCCESS) {
- delete[] *value;
+// Not generic, we only handle strings up to 128 chars.
+bool ReadRegistryStr(HKEY key, const wchar_t* name, std::wstring* value) {
+ BYTE out[128 * sizeof(wchar_t)];
+ DWORD size = sizeof(out);
+ DWORD type = 0;
+ if (ERROR_SUCCESS != ::RegQueryValueExW(key, name, NULL, &type, out, &size))
return false;
- }
-
+ if (type != REG_SZ)
+ return false;
+ value->assign(reinterpret_cast<wchar_t*>(out));
return true;
}
-}
-
-namespace client_util {
-bool FileExists(const std::wstring& file_path) {
- WIN32_FILE_ATTRIBUTE_DATA attrs;
- return ::GetFileAttributesEx(
- file_path.c_str(), GetFileExInfoStandard, &attrs) != 0;
-}
-bool GetChromiumVersion(const wchar_t* const exe_path,
- const wchar_t* const reg_key_path,
- wchar_t** version) {
+// Gets chrome version according to the load path. |exe_path| must be the
+// backslash terminated directory of the current chrome.exe.
+bool GetVersion(const wchar_t* exe_path, const wchar_t* key_path,
+ std::wstring* version) {
HKEY reg_root = InstallUtil::IsPerUserInstall(exe_path) ? HKEY_CURRENT_USER :
HKEY_LOCAL_MACHINE;
- HKEY reg_key;
- if (::RegOpenKeyEx(reg_root, reg_key_path, 0,
- KEY_READ, &reg_key) != ERROR_SUCCESS) {
+ HKEY key;
+ if (::RegOpenKeyEx(reg_root, key_path, 0, KEY_READ, &key) != ERROR_SUCCESS)
return false;
- }
+ // If 'new_chrome.exe' is present it means chrome was auto-updated while
+ // running. We need to consult the opv value so we can load the old dll.
+ // TODO(cpu) : This is solving the same problem as the environment variable
+ // so one of them will eventually be deprecated.
std::wstring new_chrome_exe(exe_path);
new_chrome_exe.append(installer_util::kChromeNewExe);
- if (FileExists(new_chrome_exe) &&
- ReadStrValueFromRegistry(reg_key, google_update::kRegOldVersionField,
- version)) {
- ::RegCloseKey(reg_key);
+ if (::PathFileExistsW(new_chrome_exe.c_str()) &&
+ ReadRegistryStr(key, google_update::kRegOldVersionField, version)) {
+ ::RegCloseKey(key);
return true;
}
- bool ret = ReadStrValueFromRegistry(reg_key,
- google_update::kRegVersionField,
- version);
- ::RegCloseKey(reg_key);
+ bool ret = ReadRegistryStr(key, google_update::kRegVersionField, version);
+ ::RegCloseKey(key);
return ret;
}
-std::wstring GetDLLPath(const std::wstring& dll_name,
- const std::wstring& dll_path) {
- if (!dll_path.empty() && FileExists(dll_path))
- return dll_path + L"\\" + dll_name;
-
- // This is not an official build. Find the dll using the default
- // path order in LoadLibrary.
- wchar_t path[MAX_PATH] = {0};
- wchar_t* file_part = NULL;
- DWORD result = ::SearchPath(NULL, dll_name.c_str(), NULL, MAX_PATH,
- path, &file_part);
- if (result == 0 || result > MAX_PATH)
+// Gets the path of the current exe with a trailing backslash.
+std::wstring GetExecutablePath() {
+ wchar_t path[MAX_PATH];
+ ::GetModuleFileNameW(NULL, path, MAX_PATH);
+ if (!::PathRemoveFileSpecW(path))
return std::wstring();
+ std::wstring exe_path(path);
+ return exe_path.append(L"\\");
+}
- return path;
+// Not generic, we only handle strings up to 128 chars.
+bool EnvQueryStr(const wchar_t* key_name, std::wstring* value) {
+ wchar_t out[128];
+ DWORD count = sizeof(out)/sizeof(out[0]);
+ DWORD rv = ::GetEnvironmentVariableW(key_name, out, count);
+ if ((rv == 0) || (rv >= count))
+ return false;
+ *value = out;
+ return true;
}
-std::wstring GetExecutablePath() {
- wchar_t exe_path[MAX_PATH];
- DWORD len = ::GetModuleFileName(NULL, exe_path, MAX_PATH);
- wchar_t* tmp = exe_path + len - 1;
- while (tmp >= exe_path && *tmp != L'\\')
- tmp--;
- if (tmp > exe_path) {
- tmp++;
- *tmp = 0;
+// Expects that |dir| has a trailing backslash. |dir| is modified so it
+// contains the full path that was tried. Caller must check for the return
+// value not being null to dermine if this path contains a valid dll.
+HMODULE LoadChromeWithDirectory(std::wstring* dir) {
+ ::SetCurrentDirectoryW(dir->c_str());
+ dir->append(installer_util::kChromeDll);
+ return ::LoadLibraryExW(dir->c_str(), NULL,
+ LOAD_WITH_ALTERED_SEARCH_PATH);
+}
+
+// record did_run "dr" in client state.
+bool RecordDidRun(const wchar_t* guid) {
+ std::wstring key_path(google_update::kRegPathClientState);
+ key_path.append(L"\\").append(guid);
+ HKEY reg_key;
+ if (::RegCreateKeyExW(HKEY_CURRENT_USER, key_path.c_str(), 0, NULL,
+ REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL,
+ &reg_key, NULL) == ERROR_SUCCESS) {
+ const wchar_t kVal[] = L"1";
+ ::RegSetValueExW(reg_key, google_update::kRegDidRunField, 0, REG_SZ,
+ reinterpret_cast<const BYTE *>(kVal), sizeof(kVal));
+ ::RegCloseKey(reg_key);
+ return true;
+ }
+ return false;
+}
+}
+
+//=============================================================================
+
+MainDllLoader::MainDllLoader() : dll_(NULL) {
+}
+
+MainDllLoader::~MainDllLoader() {
+#ifdef PURIFY
+ // We should never unload the dll. There is only risk and no gain from
+ // doing so. The singleton dtors have been already run by AtExitManager.
+ ::FreeLibrary(dll_);
+#endif
+}
+
+// Loading chrome is an interesting afair. First we try loading from the current
+// directory to support run-what-you-compile and other development scenarios.
+// If that fails then we look at the 'CHROME_VERSION' env variable to determine
+// if we should stick with an older dll version even if a new one is available
+// to support upgrade-in-place scenarios, and if that fails we finally we look
+// at the registry which should point us to the latest version.
+HMODULE MainDllLoader::Load(std::wstring* version, std::wstring* file) {
+ std::wstring dir(GetExecutablePath());
+ *file = dir;
+ HMODULE dll = LoadChromeWithDirectory(file);
+ if (dll)
+ return dll;
+
+ if (!EnvQueryStr(google_update::kEnvProductVersionKey, version)) {
+ std::wstring reg_path(GetRegistryPath());
+ // Look into the registry to find the latest version.
+ if (!GetVersion(dir.c_str(), reg_path.c_str(), version))
+ return NULL;
}
- return exe_path;
+
+ *file = dir;
+ file->append(*version);
+ return LoadChromeWithDirectory(file);
}
-} // namespace client_util
+// Launching is a matter of loading the right dll, setting the CHROME_VERSION
+// environment variable and just calling the entry point. Derived classes can
+// add custom code in the OnBeforeLaunch callback.
+int MainDllLoader::Launch(HINSTANCE instance,
+ sandbox::SandboxInterfaceInfo* sbox_info) {
+ std::wstring version;
+ std::wstring file;
+ dll_ = Load(&version, &file);
+ if (!dll_)
+ return ResultCodes::MISSING_DATA;
+
+ ::SetEnvironmentVariableW(google_update::kEnvProductVersionKey,
+ version.c_str());
+
+ InitCrashReporterWithDllPath(file);
+
+ OnBeforeLaunch(version);
+
+ DLL_MAIN entry_point =
+ reinterpret_cast<DLL_MAIN>(::GetProcAddress(dll_, "ChromeMain"));
+ if (!entry_point)
+ return ResultCodes::BAD_PROCESS_TYPE;
+
+ return entry_point(instance, sbox_info, ::GetCommandLineW());
+}
+
+//=============================================================================
+
+class ChromeDllLoader : public MainDllLoader {
+ public:
+ virtual std::wstring GetRegistryPath() {
+ std::wstring key(google_update::kRegPathClients);
+ key.append(L"\\").append(google_update::kChromeGuid);
+ return key;
+ }
+
+ virtual void OnBeforeLaunch(const std::wstring& version) {
+ RecordDidRun(google_update::kChromeGuid);
+ }
+};
+
+//=============================================================================
+
+class ChromiumDllLoader : public MainDllLoader {
+ public:
+ virtual std::wstring GetRegistryPath() {
+ return L"Software\\Chromium";
+ }
+};
+
+MainDllLoader* MakeMainDllLoader() {
+#if defined(GOOGLE_CHROME_BUILD)
+ return new ChromeDllLoader();
+#else
+ return new ChromiumDllLoader();
+#endif
+}
diff --git a/chrome/app/client_util.h b/chrome/app/client_util.h
index b3ab7e7..c4d74d2 100644
--- a/chrome/app/client_util.h
+++ b/chrome/app/client_util.h
@@ -9,37 +9,45 @@
#define CHROME_APP_CLIENT_UTIL_H_
#include <windows.h>
-
#include <string>
-#include "sandbox/src/sandbox_factory.h"
-
-namespace client_util {
-typedef int (*DLL_MAIN)(HINSTANCE instance, sandbox::SandboxInterfaceInfo*,
- TCHAR*);
-
-extern const wchar_t kProductVersionKey[];
-
-// Returns true if file specified by file_path exists
-bool FileExists(const std::wstring& file_path);
-
-// Returns Chromium version after reading it from reg_key registry key. Uses
-// exe_path to detemine registry root key (HKLM/HKCU). Note it is the
-// responsibility of caller to free *version when function is successful.
-bool GetChromiumVersion(const wchar_t* const exe_path,
- const wchar_t* const reg_key_path,
- wchar_t** version);
-
-// Get path to DLL specified by dll_name. If dll_path is specified and it
-// exists we assume DLL is in that directory and return that. Else we search
-// for that DLL by calling Windows API.
-std::wstring GetDLLPath(const std::wstring& dll_name,
- const std::wstring& dll_path);
-
-// Returns the path to the exe (without the file name) that called this
-// function.
-std::wstring GetExecutablePath();
-
-} // namespace client_util
+namespace sandbox {
+ union SandboxInterfaceInfo;
+}
+
+// Implements the common aspects of loading chrome.dll for both chrome and
+// chromium scenarios, which are in charge of implementing two abstract
+// methods: GetRegistryPath() and OnBeforeLaunch().
+class MainDllLoader {
+ public:
+ MainDllLoader();
+ virtual ~MainDllLoader();
+
+ // Loads and calls the entry point of chrome.dll. |instance| is the exe
+ // instance retrieved from wWinMain and the |sbox_info| is the broker or
+ // target services interface pointer.
+ // The return value is what the main entry point of chrome.dll returns
+ // upon termination.
+ int Launch(HINSTANCE instance, sandbox::SandboxInterfaceInfo* sbox_info);
+
+ // Derived classes must return the relative registry path that holds the
+ // most current version of chrome.dll.
+ virtual std::wstring GetRegistryPath() = 0;
+
+ // Called after chrome.dll has beem loaded but before the entry point
+ // is invoked. Derived classes can implement custom actions here.
+ virtual void OnBeforeLaunch(const std::wstring& version) {}
+
+ protected:
+ HMODULE Load(std::wstring* version, std::wstring* file);
+
+ private:
+ // Chrome.dll handle.
+ HMODULE dll_;
+};
+
+// Factory for the MainDllLoader. Caller owns the pointer and should call
+// delete to free it.
+MainDllLoader* MakeMainDllLoader();
#endif // CHROME_APP_CLIENT_UTIL_H_
diff --git a/chrome/app/google_update_client.cc b/chrome/app/google_update_client.cc
deleted file mode 100644
index 3194f65..0000000
--- a/chrome/app/google_update_client.cc
+++ /dev/null
@@ -1,135 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/app/google_update_client.h"
-
-#include <shlobj.h>
-#include <strsafe.h>
-
-#include "chrome/app/client_util.h"
-#include "chrome/installer/util/google_update_constants.h"
-#include "chrome/installer/util/install_util.h"
-
-namespace {
-// Allocates the out param on success.
-bool GoogleUpdateEnvQueryStr(const wchar_t* key_name, wchar_t** out) {
- DWORD count = ::GetEnvironmentVariableW(key_name, NULL, 0);
- if (!count) {
- return false;
- }
- wchar_t* value = new wchar_t[count + 1];
- if (!::GetEnvironmentVariableW(key_name, value, count)) {
- delete[] value;
- return false;
- }
- *out = value;
- return true;
-}
-} // anonymous namespace
-
-namespace google_update {
-
-GoogleUpdateClient::GoogleUpdateClient() : version_(NULL) {
-}
-
-GoogleUpdateClient::~GoogleUpdateClient() {
- delete[] version_;
-}
-
-std::wstring GoogleUpdateClient::GetDLLFullPath() {
- return client_util::GetDLLPath(dll_, dll_path_);
-}
-
-std::wstring GoogleUpdateClient::GetDLLPath() {
- return dll_path_;
-}
-
-const wchar_t* GoogleUpdateClient::GetVersion() const {
- return version_;
-}
-
-bool GoogleUpdateClient::Launch(HINSTANCE instance,
- sandbox::SandboxInterfaceInfo* sandbox,
- wchar_t* command_line,
- const char* entry_name,
- int* ret) {
- if (client_util::FileExists(dll_path_)) {
- // Setting the version on the environment block is a 'best effort' deal.
- // It enables Google Update running on a child to load the same DLL version.
- ::SetEnvironmentVariableW(google_update::kEnvProductVersionKey, version_);
- }
-
- // The dll can be in the exe's directory or in the current directory.
- // Use the alternate search path to be sure that it's not trying to load it
- // calling application's directory.
- HINSTANCE dll_handle = ::LoadLibraryEx(dll_.c_str(), NULL,
- LOAD_WITH_ALTERED_SEARCH_PATH);
- if (NULL == dll_handle) {
- unsigned long err = GetLastError();
- if (err) {
- WCHAR message[500] = {0};
- FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, 0,
- reinterpret_cast<LPWSTR>(&message), 500, NULL);
- ::OutputDebugStringW(message);
- }
- return false;
- }
-
- bool did_launch = false;
- client_util::DLL_MAIN entry = reinterpret_cast<client_util::DLL_MAIN>(
- ::GetProcAddress(dll_handle, entry_name));
- if (NULL != entry) {
- // record did_run "dr" in client state
- std::wstring key_path(google_update::kRegPathClientState);
- key_path.append(L"\\" + guid_);
- HKEY reg_key;
- if (::RegCreateKeyEx(HKEY_CURRENT_USER, key_path.c_str(), 0, NULL,
- REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL,
- &reg_key, NULL) == ERROR_SUCCESS) {
- const wchar_t kVal[] = L"1";
- ::RegSetValueEx(reg_key, google_update::kRegDidRunField, 0, REG_SZ,
- reinterpret_cast<const BYTE *>(kVal), sizeof(kVal));
- ::RegCloseKey(reg_key);
- }
-
- int rc = (entry)(instance, sandbox, command_line);
- if (ret) {
- *ret = rc;
- }
- did_launch = true;
- }
-#ifdef PURIFY
- // We should never unload the dll. There is only risk and no gain from
- // doing so. The singleton dtors have been already run by AtExitManager.
- ::FreeLibrary(dll_handle);
-#endif
- return did_launch;
-}
-
-bool GoogleUpdateClient::Init(const wchar_t* client_guid,
- const wchar_t* client_dll) {
- dll_path_ = client_util::GetExecutablePath();
- guid_.assign(client_guid);
- dll_.assign(client_dll);
- bool ret = false;
- if (!guid_.empty()) {
- if (GoogleUpdateEnvQueryStr(google_update::kEnvProductVersionKey,
- &version_)) {
- ret = true;
- } else {
- std::wstring key(google_update::kRegPathClients);
- key.append(L"\\" + guid_);
- if (client_util::GetChromiumVersion(dll_path_.c_str(),
- key.c_str(),
- &version_))
- ret = true;
- }
- }
-
- if (version_) {
- dll_path_.append(version_);
- }
- return ret;
-}
-} // namespace google_update
diff --git a/chrome/app/google_update_client.h b/chrome/app/google_update_client.h
deleted file mode 100644
index 82f7d43..0000000
--- a/chrome/app/google_update_client.h
+++ /dev/null
@@ -1,81 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-// This is the Chrome-GoogleUpdater integration glue. Current features of this
-// code include:
-// * checks to ensure that client is properly registered with GoogleUpdater
-// * versioned directory launcher to allow for completely transparent silent
-// autoupdates
-
-
-#ifndef CHROME_APP_GOOGLE_UPDATE_CLIENT_H_
-#define CHROME_APP_GOOGLE_UPDATE_CLIENT_H_
-
-#include <windows.h>
-#include <tchar.h>
-
-#include <string>
-
-#include "sandbox/src/sandbox_factory.h"
-
-namespace google_update {
-
-class GoogleUpdateClient {
- public:
- GoogleUpdateClient();
- virtual ~GoogleUpdateClient();
-
- // Returns the full path of the DLL that is going to be loaded.
- // This function can be called only after Init().
- std::wstring GetDLLFullPath();
-
- // Returns the path containing the DLL that is going to be loaded.
- // This function can be called only after Init().
- std::wstring GetDLLPath();
-
- // For the client guid, returns the associated version string, or NULL
- // if Init() was unable to obtain one.
- const wchar_t* GetVersion() const;
-
- // Init must be called prior to other methods.
- // client_guid is the guid that you registered with Google Update when you
- // installed.
- // Returns false if client is not properly registered with GoogleUpdate. If
- // not registered, autoupdates won't be performed for this client.
- bool Init(const wchar_t* client_guid, const wchar_t* client_dll);
-
- // Launches your app's main code and initializes Google Update services.
- // - looks up the registered version via GoogleUpdate, loads dll from version
- // dir (e.g. Program Files/Google/1.0.101.0/chrome.dll) and calls the
- // entry_name. If chrome.dll is found in this path the version is stored
- // in the environment block such that subsequent launches invoke the
- // save dll version.
- // - instance is handle to the current instance of application
- // - sandbox provides information about sandbox services
- // - command_line contains command line parameters
- // - entry_name is the function of type DLL_MAIN that is called
- // from chrome.dll
- // - ret is an out param with the return value of entry
- // Returns false if unable to load the dll or find entry_name's proc addr.
- bool Launch(HINSTANCE instance, sandbox::SandboxInterfaceInfo* sandbox,
- wchar_t* command_line, const char* entry_name, int* ret);
-
- private:
- // disallow copy ctor and operator=
- GoogleUpdateClient(const GoogleUpdateClient&);
- void operator=(const GoogleUpdateClient&);
-
- // The GUID that this client has registered with GoogleUpdate for autoupdate.
- std::wstring guid_;
- // The name of the dll to load.
- std::wstring dll_;
- // The current version of this client registered with GoogleUpdate.
- wchar_t* version_;
- // The location of current chrome.dll.
- std::wstring dll_path_;
-};
-
-} // namespace google_update
-
-#endif // CHROME_APP_GOOGLE_UPDATE_CLIENT_H_
diff --git a/chrome/browser/google_update.cc b/chrome/browser/google_update.cc
index b56ea1e..db00a71 100644
--- a/chrome/browser/google_update.cc
+++ b/chrome/browser/google_update.cc
@@ -14,7 +14,6 @@
#include "base/task.h"
#include "base/thread.h"
#include "base/win_util.h"
-#include "chrome/app/client_util.h"
#include "chrome/browser/chrome_thread.h"
#include "chrome/installer/util/google_update_constants.h"
#include "chrome/installer/util/helper.h"
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index e8c92f5..c2f061c 100755
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -3436,8 +3436,6 @@
'app/chrome_exe_resource.h',
'app/client_util.cc',
'app/client_util.h',
- 'app/google_update_client.cc',
- 'app/google_update_client.h',
'app/hard_error_handler_win.cc',
'app/hard_error_handler_win.h',
'app/scoped_ole_initializer.h',
@@ -3882,7 +3880,6 @@
'sources!': [
'app/chrome_exe_main.cc',
'app/client_util.cc',
- 'app/google_update_client.cc',
]
}],
['OS=="linux" or OS=="freebsd"', {