diff options
author | erikwright@chromium.org <erikwright@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-21 18:49:29 +0000 |
---|---|---|
committer | erikwright@chromium.org <erikwright@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-21 18:49:29 +0000 |
commit | 3227e09afc75fe5c3dca8e109969e0535331ba17 (patch) | |
tree | 6015c4003dde228c9829db420fa8fc1cf30e20ef /cloud_print | |
parent | b8d40382752651e5d0922f3417c4e2cae01467c3 (diff) | |
download | chromium_src-3227e09afc75fe5c3dca8e109969e0535331ba17.zip chromium_src-3227e09afc75fe5c3dca8e109969e0535331ba17.tar.gz chromium_src-3227e09afc75fe5c3dca8e109969e0535331ba17.tar.bz2 |
Factor out logic to find chrome.exe from Omaha client state.
Besides these two clients, will also be used by the Chrome Application Host stub.
R=robertshield,abodenha
CC=grt
BUG=None
TEST=None
Review URL: https://chromiumcodereview.appspot.com/10546149
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@143423 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cloud_print')
-rw-r--r-- | cloud_print/service/DEPS | 1 | ||||
-rw-r--r-- | cloud_print/service/service.gyp | 9 | ||||
-rw-r--r-- | cloud_print/service/win/chrome_launcher.cc | 63 | ||||
-rw-r--r-- | cloud_print/service/win/chrome_launcher.h | 3 | ||||
-rw-r--r-- | cloud_print/service/win/cloud_print_service.cc | 5 |
5 files changed, 15 insertions, 66 deletions
diff --git a/cloud_print/service/DEPS b/cloud_print/service/DEPS index 8fa9d48..33757a3 100644 --- a/cloud_print/service/DEPS +++ b/cloud_print/service/DEPS @@ -1,3 +1,4 @@ include_rules = [ + "+chrome/installer/launcher_support", "+net", ] diff --git a/cloud_print/service/service.gyp b/cloud_print/service/service.gyp index 096e0d8..35c448d 100644 --- a/cloud_print/service/service.gyp +++ b/cloud_print/service/service.gyp @@ -26,7 +26,14 @@ 'service_switches.h', 'win/chrome_launcher.cc', 'win/chrome_launcher.h', - ] + ], + 'conditions': [ + ['OS=="win"', { + 'dependencies': [ + '<(DEPTH)/chrome/chrome.gyp:launcher_support', + ], + }], + ], }, { 'target_name': 'cloud_print_service', diff --git a/cloud_print/service/win/chrome_launcher.cc b/cloud_print/service/win/chrome_launcher.cc index 5921fd0..5df9bae 100644 --- a/cloud_print/service/win/chrome_launcher.cc +++ b/cloud_print/service/win/chrome_launcher.cc @@ -5,28 +5,15 @@ #include "cloud_print/service/win/chrome_launcher.h" #include "base/command_line.h" -#include "base/file_util.h" -#include "base/path_service.h" #include "base/process.h" #include "base/process_util.h" -#include "base/win/registry.h" #include "base/win/scoped_handle.h" #include "base/win/scoped_process_information.h" +#include "chrome/installer/launcher_support/chrome_launcher_support.h" #include "cloud_print/service/service_switches.h" namespace { -const wchar_t kChromeRegClientStateKey[] = - L"Software\\Google\\Update\\ClientState\\" - L"{8A69D345-D564-463c-AFF1-A69D9E530F96}"; - -const wchar_t kGoogleChromeExePath[] = - L"Google\\Chrome\\Application\\chrome.exe"; - -const wchar_t kUninstallStringField[] = L"UninstallString"; - -const wchar_t kChromeExe[] = L"chrome.exe"; - const int kShutdownTimeoutMs = 30 * 1000; void ShutdownChrome(HANDLE process, DWORD thread_id) { @@ -62,21 +49,6 @@ bool LaunchProcess(const CommandLine& cmdline, return true; } -FilePath GetAnyChromePath() { - FilePath chrome_path = ChromeLauncher::GetChromePath(HKEY_LOCAL_MACHINE); - if (!chrome_path.empty()) - return chrome_path; - chrome_path = ChromeLauncher::GetChromePath(HKEY_CURRENT_USER); - if (!chrome_path.empty()) - return chrome_path; - if (PathService::Get(base::DIR_PROGRAM_FILES, &chrome_path)) { - chrome_path.Append(kGoogleChromeExePath); - if (file_util::PathExists(chrome_path)) - return chrome_path; - } - return FilePath(); -} - } // namespace ChromeLauncher::ChromeLauncher(const FilePath& user_data) @@ -106,7 +78,7 @@ void ChromeLauncher::Run() { for (base::TimeDelta time_out = default_time_out;; time_out = std::min(time_out * 2, max_time_out)) { - FilePath chrome_path = GetAnyChromePath(); + FilePath chrome_path = chrome_launcher_support::GetAnyChromePath(); if (!chrome_path.empty()) { CommandLine cmd(chrome_path); @@ -138,35 +110,4 @@ void ChromeLauncher::Run() { } } -FilePath ChromeLauncher::GetChromePath(HKEY key) { - using base::win::RegKey; - RegKey reg_key(key, kChromeRegClientStateKey, KEY_QUERY_VALUE); - - FilePath chrome_exe_path; - - if (reg_key.Valid()) { - // Now grab the uninstall string from the appropriate ClientState key - // and use that as the base for a path to chrome.exe. - string16 uninstall; - if (reg_key.ReadValue(kUninstallStringField, &uninstall) == ERROR_SUCCESS) { - // The uninstall path contains the path to setup.exe which is two levels - // down from chrome.exe. Move up two levels (plus one to drop the file - // name) and look for chrome.exe from there. - FilePath uninstall_path(uninstall); - chrome_exe_path = - uninstall_path.DirName().DirName().DirName().Append(kChromeExe); - if (!file_util::PathExists(chrome_exe_path)) { - // By way of mild future proofing, look up one to see if there's a - // chrome.exe in the version directory - chrome_exe_path = - uninstall_path.DirName().DirName().Append(kChromeExe); - } - } - } - - if (file_util::PathExists(chrome_exe_path)) - return chrome_exe_path; - - return FilePath(); -} diff --git a/cloud_print/service/win/chrome_launcher.h b/cloud_print/service/win/chrome_launcher.h index 8b98141..bc257ff 100644 --- a/cloud_print/service/win/chrome_launcher.h +++ b/cloud_print/service/win/chrome_launcher.h @@ -23,8 +23,6 @@ class ChromeLauncher : public base::DelegateSimpleThread::Delegate { virtual void Run() OVERRIDE; - static FilePath GetChromePath(HKEY key); - private: FilePath user_data_; base::WaitableEvent stop_event_; @@ -34,4 +32,3 @@ class ChromeLauncher : public base::DelegateSimpleThread::Delegate { }; #endif // CLOUD_PRINT_SERVICE_CHROME_LAUNCHER_H_ - diff --git a/cloud_print/service/win/cloud_print_service.cc b/cloud_print/service/win/cloud_print_service.cc index f87c2888..7c88591 100644 --- a/cloud_print/service/win/cloud_print_service.cc +++ b/cloud_print/service/win/cloud_print_service.cc @@ -15,6 +15,7 @@ #include "base/path_service.h" #include "base/string_util.h" #include "base/win/scoped_handle.h" +#include "chrome/installer/launcher_support/chrome_launcher_support.h" #include "cloud_print/service/service_state.h" #include "cloud_print/service/service_switches.h" #include "cloud_print/service/win/chrome_launcher.h" @@ -182,13 +183,15 @@ class CloudPrintServiceModule } HRESULT InstallService() { + using namespace chrome_launcher_support; + // TODO(vitalybuka): consider "lite" version if we don't want unregister // printers here. HRESULT hr = UninstallService(); if (FAILED(hr)) return hr; - if (ChromeLauncher::GetChromePath(HKEY_LOCAL_MACHINE).empty()) { + if (GetChromePathForInstallationLevel(SYSTEM_LEVEL_INSTALLATION).empty()) { LOG(ERROR) << "Found no Chrome installed for all users."; return HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND); } |