summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorrahulk@google.com <rahulk@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-22 21:16:47 +0000
committerrahulk@google.com <rahulk@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-22 21:16:47 +0000
commitc9349d08ebc302d91d695f7abef4750d64a5dc31 (patch)
tree3c1e7a1e47a3efa2e1882230b8e03b118a14366f /chrome
parent2d5cdce4c2389657ad844a2456f00759806c2371 (diff)
downloadchromium_src-c9349d08ebc302d91d695f7abef4750d64a5dc31.zip
chromium_src-c9349d08ebc302d91d695f7abef4750d64a5dc31.tar.gz
chromium_src-c9349d08ebc302d91d695f7abef4750d64a5dc31.tar.bz2
Make chrome.exe read version from Software\Chromium instead of Google Update keys when running Chromium. With this change
now we can build a Chromium release that gets installed under Application Data\Chromium and actually runs. - Added a new file that has common functions used by google update client and chromium - Did some minor cleanup based on readability guidelines (alphabatical order etc). - We seem to be trying to avoid std::wstring at some places but are using it at other places. In future we should be just able to use std::wstring and get rid of StringCchDup. BUG=1296800 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1243 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/app/chrome_exe.vcproj8
-rw-r--r--chrome/app/chrome_exe_main.cc48
-rw-r--r--chrome/app/client_util.cc90
-rw-r--r--chrome/app/client_util.h65
-rw-r--r--chrome/app/google_update_client.cc222
-rw-r--r--chrome/app/google_update_client.h43
6 files changed, 279 insertions, 197 deletions
diff --git a/chrome/app/chrome_exe.vcproj b/chrome/app/chrome_exe.vcproj
index 2591503..1112e5b 100644
--- a/chrome/app/chrome_exe.vcproj
+++ b/chrome/app/chrome_exe.vcproj
@@ -197,6 +197,14 @@
>
</File>
<File
+ RelativePath=".\client_util.cc"
+ >
+ </File>
+ <File
+ RelativePath=".\client_util.h"
+ >
+ </File>
+ <File
RelativePath="..\common\env_vars.cc"
>
</File>
diff --git a/chrome/app/chrome_exe_main.cc b/chrome/app/chrome_exe_main.cc
index c124db3..728218f 100644
--- a/chrome/app/chrome_exe_main.cc
+++ b/chrome/app/chrome_exe_main.cc
@@ -35,6 +35,7 @@
#include "base/command_line.h"
#include "base/debug_on_start.h"
#include "chrome/app/breakpad.h"
+#include "chrome/app/client_util.h"
#include "chrome/app/google_update_client.h"
#include "chrome/app/result_codes.h"
#include "chrome/common/chrome_switches.h"
@@ -46,8 +47,6 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE prev_instance,
// The exit manager is in charge of calling the dtors of singletons.
base::AtExitManager exit_manager;
- google_update::GoogleUpdateClient client;
-
// Note that std::wstring and CommandLine got linked anyway because of
// breakpad.
CommandLine parsed_command_line;
@@ -70,6 +69,16 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE prev_instance,
sandbox::SetCurrentProcessDEP(sandbox::DEP_ENABLED);
}
+ // Get the interface pointer to the BrokerServices or TargetServices,
+ // depending who we are.
+ sandbox::SandboxInterfaceInfo sandbox_info = {0};
+ sandbox_info.broker_services = sandbox::SandboxFactory::GetBrokerServices();
+ if (!sandbox_info.broker_services)
+ sandbox_info.target_services = sandbox::SandboxFactory::GetTargetServices();
+
+#if defined(GOOGLE_CHROME_BUILD)
+ google_update::GoogleUpdateClient client;
+
// TODO(erikkay): Get guid from build macros rather than hardcoding.
// TODO(erikkay): verify client.Init() return value for official builds
client.Init(L"{8A69D345-D564-463c-AFF1-A69D9E530F96}", dll_name);
@@ -85,23 +94,32 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE prev_instance,
return ResultCodes::NORMAL_EXIT;
}
- // Get the interface pointer to the BrokerServices or TargetServices,
- // depending who we are.
- sandbox::SandboxInterfaceInfo sandbox_info = {0};
- sandbox_info.broker_services = sandbox::SandboxFactory::GetBrokerServices();
- if (!sandbox_info.broker_services)
- sandbox_info.target_services = sandbox::SandboxFactory::GetTargetServices();
-
- // HACK. We need to tell chrome.dll the address of the interface. We are
- // passing it in prev_instance because this is never used. In the future we
- // need to modify Google Update to add a new parameter to the Launch command.
- prev_instance = reinterpret_cast<HINSTANCE>(&sandbox_info);
-
int ret = 0;
- if (client.Launch(instance, prev_instance, command_line, show_command,
+ if (client.Launch(instance, &sandbox_info, command_line, show_command,
"ChromeMain", &ret)) {
return ret;
}
+#else
+ wchar_t exe_path[MAX_PATH] = {0};
+ client_util::GetExecutablePath(exe_path);
+ wchar_t *version;
+ if (client_util::GetChromiumVersion(exe_path, L"Software\\Chromium",
+ &version)) {
+ std::wstring dll_path(exe_path);
+ dll_path.append(version);
+ if (client_util::FileExists(dll_path.c_str()))
+ ::SetCurrentDirectory(dll_path.c_str());
+ delete[] version;
+ }
+ HINSTANCE dll_handle = ::LoadLibraryEx(dll_name, NULL,
+ LOAD_WITH_ALTERED_SEARCH_PATH);
+ 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, show_command);
+ }
+#endif
return ResultCodes::GOOGLE_UPDATE_LAUNCH_FAILED;
}
diff --git a/chrome/app/client_util.cc b/chrome/app/client_util.cc
new file mode 100644
index 0000000..4a34085
--- /dev/null
+++ b/chrome/app/client_util.cc
@@ -0,0 +1,90 @@
+// Copyright 2008, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#include "chrome/app/client_util.h"
+
+#include <shlobj.h>
+
+namespace client_util {
+const wchar_t kProductVersionKey[] = L"pv";
+
+bool FileExists(const wchar_t* const file_path) {
+ WIN32_FILE_ATTRIBUTE_DATA attrs;
+ return ::GetFileAttributesEx(file_path, GetFileExInfoStandard, &attrs) != 0;
+}
+
+bool GetChromiumVersion(const wchar_t* const exe_path,
+ const wchar_t* const reg_key_path,
+ wchar_t** version) {
+ HKEY reg_root = IsUserModeInstall(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) {
+ return false;
+ }
+ DWORD size = 0;
+ bool ret = false;
+ if (::RegQueryValueEx(reg_key, client_util::kProductVersionKey, NULL, NULL,
+ NULL, &size) == ERROR_SUCCESS) {
+ *version = new wchar_t[1 + (size / sizeof(wchar_t))];
+ if (::RegQueryValueEx(reg_key, client_util::kProductVersionKey,
+ NULL, NULL, reinterpret_cast<BYTE*>(*version),
+ &size) == ERROR_SUCCESS) {
+ ret = true;
+ } else {
+ delete[] *version;
+ }
+ }
+ ::RegCloseKey(reg_key);
+ return ret;
+}
+
+void GetExecutablePath(wchar_t* exe_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;
+ }
+}
+
+bool IsUserModeInstall(const wchar_t* const exe_path) {
+ wchar_t buffer[MAX_PATH] = {0};
+ if (!FAILED(SHGetFolderPath(NULL, CSIDL_PROGRAM_FILES, NULL,
+ SHGFP_TYPE_CURRENT, buffer))) {
+ if (exe_path == wcsstr(exe_path, buffer)) {
+ return false;
+ }
+ }
+ return true;
+}
+} // namespace client_util
diff --git a/chrome/app/client_util.h b/chrome/app/client_util.h
new file mode 100644
index 0000000..58cc207
--- /dev/null
+++ b/chrome/app/client_util.h
@@ -0,0 +1,65 @@
+// Copyright 2008, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// This file defines utility functions that can report details about the
+// host operating environment.
+
+#ifndef CHROME_APP_CLIENT_UTIL_H_
+#define CHROME_APP_CLIENT_UTIL_H_
+
+#include <windows.h>
+
+#include "sandbox/src/sandbox_factory.h"
+
+namespace client_util {
+typedef int (*DLL_MAIN)(HINSTANCE instance, sandbox::SandboxInterfaceInfo*,
+ TCHAR*, int);
+
+extern const wchar_t kProductVersionKey[];
+
+// Returns true if file specified by file_path exists
+bool FileExists(const wchar_t* const 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);
+
+// Returns the path to the exe (without the file name) that called this
+// function. The buffer should already be allocated (ideally of MAX_PATH size).
+void GetExecutablePath(wchar_t* exe_path);
+
+// Returns false if this is system level install (exe_path is same as
+// Program Files path) else returns true.
+bool IsUserModeInstall(const wchar_t* const exe_path);
+} // namespace client_util
+
+#endif // CHROME_APP_CLIENT_UTIL_H_
diff --git a/chrome/app/google_update_client.cc b/chrome/app/google_update_client.cc
index a8cd8af..8001916 100644
--- a/chrome/app/google_update_client.cc
+++ b/chrome/app/google_update_client.cc
@@ -32,67 +32,19 @@
#include <shlobj.h>
#include <strsafe.h>
-namespace google_update {
+#include "chrome/app/client_util.h"
+namespace {
const wchar_t kRegistryClients[] = L"Software\\Google\\Update\\Clients\\";
const wchar_t kRegistryClientState[] =
L"Software\\Google\\Update\\ClientState\\";
-const wchar_t kRequestParamProductVersion[] = L"pv";
const wchar_t kRequestParamDidRun[] = L"dr";
const wchar_t kRegistryUpdate[] = L"Software\\Google\\Update\\";
const wchar_t kRegistryValueCrashReportPath[] = L"CrashReportPath";
const wchar_t kEnvProductVersionKey[] = L"CHROME_VERSION";
-// We're using raw wchar_t everywhere rather than relying on CString or wstring
-// to reduce dependencies and make it easier for different apps and libraries
-// to use this source code. For similar reasons, we're avoiding using msvcrt
-// functions. This is also why this is implemented rather than just using
-// _tcsdup.
-// TODO(erikkay): add unit test for this function
-static HRESULT StringCchDup(wchar_t** dst, const wchar_t* src) {
- // TODO(erikkay): ASSERT(src), ASSERT(dst)
- size_t len = 0;
- *dst = NULL;
- HRESULT hr = ::StringCchLength(src, STRSAFE_MAX_CCH, &len);
- if (SUCCEEDED(hr)) {
- len++;
- *dst = new wchar_t[len];
- hr = ::StringCchCopy(*dst, len, src);
- if (FAILED(hr)) {
- delete[] *dst;
- *dst = NULL;
- }
- }
- return hr;
-}
-
-static bool FileExists(const wchar_t* filename) {
- WIN32_FILE_ATTRIBUTE_DATA attrs;
- return ::GetFileAttributesEx(filename, GetFileExInfoStandard, &attrs) != 0;
-}
-
-// Allocates the out param on success.
-static bool GoogleUpdateRegQueryStr(HKEY key, const wchar_t* val,
- wchar_t** out) {
- DWORD size = 0;
- LONG ret;
- ret = ::RegQueryValueEx(key, val, NULL, NULL, NULL, &size);
- if (ERROR_SUCCESS == ret) {
- DWORD len = 1 + (size / sizeof(wchar_t));
- *out = new wchar_t[len];
- ret = ::RegQueryValueEx(key, val, NULL, NULL,
- reinterpret_cast<BYTE* >(*out), &size);
- if (ERROR_SUCCESS == ret) {
- return true;
- } else {
- delete[] *out;
- }
- }
- return false;
-}
-
// Allocates the out param on success.
-static bool GoogleUpdateEnvQueryStr(const wchar_t* key_name, wchar_t** out) {
+bool GoogleUpdateEnvQueryStr(const wchar_t* key_name, wchar_t** out) {
DWORD count = ::GetEnvironmentVariableW(key_name, NULL, 0);
if (!count) {
return false;
@@ -105,57 +57,44 @@ static bool GoogleUpdateEnvQueryStr(const wchar_t* key_name, wchar_t** out) {
*out = value;
return true;
}
+} // anonymous namespace
-const wchar_t* GoogleUpdateClient::GetVersion() const {
- return version_;
-}
+namespace google_update {
-void GoogleUpdateClient::GetExePathAndInstallMode() {
- dll_path_[0] = 0;
- user_mode_ = true;
+GoogleUpdateClient::GoogleUpdateClient() : version_(NULL) {
+}
- wchar_t buffer[MAX_PATH] = {0};
- DWORD len = ::GetModuleFileName(NULL, dll_path_, MAX_PATH);
- if (!FAILED(SHGetFolderPath(NULL, CSIDL_PROGRAM_FILES, NULL,
- SHGFP_TYPE_CURRENT, buffer))) {
- if (dll_path_ == wcsstr(dll_path_, buffer)) {
- user_mode_ = false;
- }
- }
- // TODO(erikkay): ASSERT on len == 0
- wchar_t* t = dll_path_ + len - 1;
- while (t >= dll_path_ && *t != L'\\') {
- t--;
- }
- if (t > dll_path_) {
- t++;
- *t = 0;
- }
+GoogleUpdateClient::~GoogleUpdateClient() {
+ delete[] version_;
}
std::wstring GoogleUpdateClient::GetDLLPath() {
- if (FileExists(dll_path_))
+ if (client_util::FileExists(dll_path_))
return std::wstring(dll_path_) + L"\\" + dll_;
// 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_, NULL, MAX_PATH, path, &file_part);
+ DWORD result = ::SearchPath(NULL, dll_.c_str(), NULL, MAX_PATH,
+ path, &file_part);
if (result == 0 || result > MAX_PATH)
return std::wstring();
return path;
}
-bool GoogleUpdateClient::Launch(HINSTANCE instance, HINSTANCE prev_instance,
- wchar_t* command_line, int show_command,
- const char* entry_name, int* ret) {
- // TODO(erikkay): ASSERT(guid_)
+const wchar_t* GoogleUpdateClient::GetVersion() const {
+ return version_;
+}
- bool did_launch = false;
- if (FileExists(dll_path_)) {
- const size_t dll_path_len = wcslen(dll_path_);
+bool GoogleUpdateClient::Launch(HINSTANCE instance,
+ sandbox::SandboxInterfaceInfo* sandbox,
+ wchar_t* command_line,
+ int show_command,
+ const char* entry_name,
+ int* ret) {
+ if (client_util::FileExists(dll_path_)) {
::SetCurrentDirectory(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.
@@ -165,46 +104,9 @@ bool GoogleUpdateClient::Launch(HINSTANCE instance, HINSTANCE prev_instance,
// 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_, NULL,
+ HINSTANCE dll_handle = ::LoadLibraryEx(dll_.c_str(), NULL,
LOAD_WITH_ALTERED_SEARCH_PATH);
- if (NULL != dll_handle) {
- GoogleUpdateEntry entry = reinterpret_cast<GoogleUpdateEntry>
- (::GetProcAddress(dll_handle, entry_name));
- if (NULL != entry) {
- // record did_run in client state
- HKEY reg_client_state;
- HKEY reg_root = HKEY_LOCAL_MACHINE;
- if (user_mode_) {
- reg_root = HKEY_CURRENT_USER;
- }
-
- if (::RegOpenKeyEx(reg_root, kRegistryClientState, 0,
- KEY_READ, &reg_client_state) == ERROR_SUCCESS) {
- HKEY reg_client;
- if (::RegOpenKeyEx(reg_client_state, guid_, 0,
- KEY_WRITE, &reg_client) == ERROR_SUCCESS) {
- const wchar_t kVal[] = L"1";
- const size_t len = sizeof(kVal); // we want the size in bytes
- const BYTE *bytes = reinterpret_cast<const BYTE *>(kVal);
- ::RegSetValueEx(reg_client, kRequestParamDidRun, 0, REG_SZ,
- bytes, len);
- ::RegCloseKey(reg_client);
- }
- ::RegCloseKey(reg_client_state);
- }
-
- int rc = (entry)(instance, prev_instance, command_line, show_command);
- 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
- } else {
+ if (NULL == dll_handle) {
unsigned long err = GetLastError();
if (err) {
WCHAR message[500] = {0};
@@ -212,40 +114,55 @@ bool GoogleUpdateClient::Launch(HINSTANCE instance, HINSTANCE prev_instance,
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
+ HKEY reg_root = (user_mode_) ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE;
+ std::wstring key_path = kRegistryClientState + guid_;
+ HKEY reg_key;
+ if (::RegOpenKeyEx(reg_root, key_path.c_str(), 0,
+ KEY_WRITE, &reg_key) == ERROR_SUCCESS) {
+ const wchar_t kVal[] = L"1";
+ ::RegSetValueEx(reg_key, kRequestParamDidRun, 0, REG_SZ,
+ reinterpret_cast<const BYTE *>(kVal), sizeof(kVal));
+ ::RegCloseKey(reg_key);
+ }
+
+ int rc = (entry)(instance, sandbox, command_line, show_command);
+ 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) {
- GetExePathAndInstallMode();
+bool GoogleUpdateClient::Init(const wchar_t* client_guid,
+ const wchar_t* client_dll) {
+ client_util::GetExecutablePath(dll_path_);
+ user_mode_ = client_util::IsUserModeInstall(dll_path_);
- StringCchDup(&guid_, client_guid);
- StringCchDup(&dll_, client_dll);
- // TODO(erikkay): ASSERT(guid_)
+ guid_.assign(client_guid);
+ dll_.assign(client_dll);
bool ret = false;
- if (guid_) {
+ if (!guid_.empty()) {
if (GoogleUpdateEnvQueryStr(kEnvProductVersionKey, &version_)) {
ret = true;
} else {
- // Look up the version from Google Update registry.
- HKEY reg_clients;
- HKEY reg_root = HKEY_LOCAL_MACHINE;
- if (user_mode_) {
- reg_root = HKEY_CURRENT_USER;
- }
- if (::RegOpenKeyEx(reg_root, kRegistryClients, 0,
- KEY_READ, &reg_clients) == ERROR_SUCCESS) {
- HKEY reg_client;
- if (::RegOpenKeyEx(reg_clients, guid_, 0, KEY_READ, &reg_client) ==
- ERROR_SUCCESS) {
- if (GoogleUpdateRegQueryStr(reg_client, kRequestParamProductVersion,
- &version_)) {
- ret = true;
- }
- ::RegCloseKey(reg_client);
- }
- ::RegCloseKey(reg_clients);
- }
+ std::wstring key(kRegistryClients);
+ key.append(guid_);
+ if (client_util::GetChromiumVersion(dll_path_, key.c_str(), &version_))
+ ret = true;
}
}
@@ -254,15 +171,4 @@ bool GoogleUpdateClient::Init(const wchar_t* client_guid, const wchar_t* client_
}
return ret;
}
-
-GoogleUpdateClient::GoogleUpdateClient()
- : guid_(NULL), dll_(NULL), version_(NULL) {
-}
-
-GoogleUpdateClient::~GoogleUpdateClient() {
- delete[] guid_;
- delete[] dll_;
- delete[] version_;
-}
-
} // namespace google_update
diff --git a/chrome/app/google_update_client.h b/chrome/app/google_update_client.h
index 684b073..4170b5d 100644
--- a/chrome/app/google_update_client.h
+++ b/chrome/app/google_update_client.h
@@ -42,17 +42,23 @@
#include <string>
+#include "sandbox/src/sandbox_factory.h"
+
namespace google_update {
class GoogleUpdateClient {
public:
- // callback prototype for GoogleUpdateClient::Launch entry_name
- typedef int (*GoogleUpdateEntry)(HINSTANCE instance, HINSTANCE prev_instance,
- wchar_t* command_line, int show_command);
-
GoogleUpdateClient();
virtual ~GoogleUpdateClient();
+ // Returns the path of 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.
@@ -66,38 +72,27 @@ class GoogleUpdateClient {
// 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.
- // The first four arguments are simply WinMain args passed through.
- // - entry_name is the (typedef) GoogleUpdateEntry that is called
+ // - instance is handle to the current instance of application
+ // - sandbox provides information about sandbox services
+ // - command_line contains command line parameters
+ // - show_command specifies how the window is to be shown
+ // - 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, HINSTANCE prev_instance,
+ bool Launch(HINSTANCE instance, sandbox::SandboxInterfaceInfo* sandbox,
wchar_t* command_line, int show_command, const char* entry_name,
int* ret);
- // For the client guid, fills in the path to the dir for the exe that
- // calls this function. (e.g. Program Files/Google/Chrome/ or
- // Documents and Settings\user\Local Settings\Application Data\Google\Chrome)
- // It also sets the user_mode_ depending on whether the exe was called
- // from Program Files location (user_mode_ = false) or not.
- void GetExePathAndInstallMode();
-
- // Returns the path of 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;
-
private:
// disallow copy ctor and operator=
GoogleUpdateClient(const GoogleUpdateClient&);
void operator=(const GoogleUpdateClient&);
// The GUID that this client has registered with GoogleUpdate for autoupdate.
- wchar_t* guid_;
+ std::wstring guid_;
// The name of the dll to load.
- wchar_t* dll_;
+ std::wstring dll_;
// The current version of this client registered with GoogleUpdate.
wchar_t* version_;
// The location of current chrome.dll.