OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/installer/launcher_support/chrome_launcher_support.h" | 5 #include "chrome/installer/launcher_support/chrome_launcher_support.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
12 #include "base/win/registry.h" | 12 #include "base/win/registry.h" |
13 | 13 |
14 namespace chrome_launcher_support { | 14 namespace chrome_launcher_support { |
15 | 15 |
16 namespace { | 16 namespace { |
17 | 17 |
18 // TODO(huangs) Refactor the constants: http://crbug.com/148538 | 18 // TODO(huangs) Refactor the constants: http://crbug.com/148538 |
19 const wchar_t kGoogleRegClientStateKey[] = | 19 const wchar_t kGoogleRegClientStateKey[] = |
20 L"Software\\Google\\Update\\ClientState"; | 20 L"Software\\Google\\Update\\ClientState"; |
21 | 21 |
22 // Copied from chrome_appid.cc. | 22 // Copied from chrome_appid.cc. |
23 const wchar_t kBinariesAppGuid[] = L"{4DC8B4CA-1BDA-483e-B5FA-D3C12E15B62D}"; | 23 const wchar_t kBinariesAppGuid[] = L"{4DC8B4CA-1BDA-483e-B5FA-D3C12E15B62D}"; |
24 | 24 |
25 // Copied from google_chrome_distribution.cc. | 25 // Copied from google_chrome_distribution.cc. |
26 const wchar_t kBrowserAppGuid[] = L"{8A69D345-D564-463c-AFF1-A69D9E530F96}"; | 26 const wchar_t kBrowserAppGuid[] = L"{8A69D345-D564-463c-AFF1-A69D9E530F96}"; |
27 | 27 |
| 28 // Copied frome google_chrome_sxs_distribution.cc. |
| 29 const wchar_t kSxSBrowserAppGuid[] = L"{4ea16ac7-fd5a-47c3-875b-dbf4a2008c20}"; |
| 30 |
28 // Copied from util_constants.cc. | 31 // Copied from util_constants.cc. |
29 const wchar_t kChromeExe[] = L"chrome.exe"; | 32 const wchar_t kChromeExe[] = L"chrome.exe"; |
30 const wchar_t kUninstallStringField[] = L"UninstallString"; | 33 const wchar_t kUninstallStringField[] = L"UninstallString"; |
31 | 34 |
32 // Reads a string value from the specified product's "ClientState" registry key. | 35 // Reads a string value from the specified product's "ClientState" registry key. |
33 // Returns true iff the value is present and successfully read. | 36 // Returns true iff the value is present and successfully read. |
34 bool GetClientStateValue(InstallationLevel level, | 37 bool GetClientStateValue(InstallationLevel level, |
35 const wchar_t* app_guid, | 38 const wchar_t* app_guid, |
36 const wchar_t* value_name, | 39 const wchar_t* value_name, |
37 base::string16* value) { | 40 base::string16* value) { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 return exe_path; | 95 return exe_path; |
93 // By way of mild future proofing, look up one to see if there's a | 96 // By way of mild future proofing, look up one to see if there's a |
94 // |exe_file| in the version directory | 97 // |exe_file| in the version directory |
95 exe_path = setup_exe_path.DirName().DirName().Append(exe_file); | 98 exe_path = setup_exe_path.DirName().DirName().Append(exe_file); |
96 if (base::PathExists(exe_path)) | 99 if (base::PathExists(exe_path)) |
97 return exe_path; | 100 return exe_path; |
98 } | 101 } |
99 return base::FilePath(); | 102 return base::FilePath(); |
100 } | 103 } |
101 | 104 |
| 105 // Returns the path to an installed SxS chrome.exe at the specified level, if |
| 106 // it can be found via Omaha client state. |
| 107 base::FilePath GetChromeSxSPathForInstallationLevel(InstallationLevel level) { |
| 108 return FindExeRelativeToSetupExe( |
| 109 GetSetupExeFromRegistry(level, kSxSBrowserAppGuid), kChromeExe); |
| 110 } |
| 111 |
102 } // namespace | 112 } // namespace |
103 | 113 |
104 base::FilePath GetChromePathForInstallationLevel(InstallationLevel level) { | 114 base::FilePath GetChromePathForInstallationLevel(InstallationLevel level) { |
105 return FindExeRelativeToSetupExe( | 115 return FindExeRelativeToSetupExe( |
106 GetSetupExeForInstallationLevel(level), kChromeExe); | 116 GetSetupExeForInstallationLevel(level), kChromeExe); |
107 } | 117 } |
108 | 118 |
109 base::FilePath GetAnyChromePath() { | 119 base::FilePath GetAnyChromePath() { |
110 base::FilePath chrome_path; | 120 base::FilePath chrome_path; |
111 if (chrome_path.empty()) | 121 if (chrome_path.empty()) |
112 chrome_path = GetChromePathForInstallationLevel(SYSTEM_LEVEL_INSTALLATION); | 122 chrome_path = GetChromePathForInstallationLevel(SYSTEM_LEVEL_INSTALLATION); |
113 if (chrome_path.empty()) | 123 if (chrome_path.empty()) |
114 chrome_path = GetChromePathForInstallationLevel(USER_LEVEL_INSTALLATION); | 124 chrome_path = GetChromePathForInstallationLevel(USER_LEVEL_INSTALLATION); |
115 return chrome_path; | 125 return chrome_path; |
116 } | 126 } |
117 | 127 |
| 128 base::FilePath GetAnyChromeSxSPath() { |
| 129 base::FilePath path = |
| 130 GetChromeSxSPathForInstallationLevel(USER_LEVEL_INSTALLATION); |
| 131 if (path.empty()) |
| 132 path = GetChromeSxSPathForInstallationLevel(SYSTEM_LEVEL_INSTALLATION); |
| 133 return path; |
| 134 } |
| 135 |
118 } // namespace chrome_launcher_support | 136 } // namespace chrome_launcher_support |
OLD | NEW |