summaryrefslogtreecommitdiffstats
path: root/cloud_print/service/win/chrome_launcher.cc
diff options
context:
space:
mode:
Diffstat (limited to 'cloud_print/service/win/chrome_launcher.cc')
-rw-r--r--cloud_print/service/win/chrome_launcher.cc63
1 files changed, 2 insertions, 61 deletions
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();
-}