OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <windows.h> | 5 #include <windows.h> |
6 #include <initguid.h> | 6 #include <initguid.h> |
7 #include <urlmon.h> | 7 #include <urlmon.h> |
8 #pragma comment(lib, "urlmon.lib") | 8 #pragma comment(lib, "urlmon.lib") |
9 | 9 |
10 #include "base/at_exit.h" | 10 #include "base/at_exit.h" |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 | 179 |
180 for (size_t i = 0; i < app_id.size(); ++i) { | 180 for (size_t i = 0; i < app_id.size(); ++i) { |
181 char c = base::ToLowerASCII(app_id[i]); | 181 char c = base::ToLowerASCII(app_id[i]); |
182 if (c < 'a' || c > 'p') | 182 if (c < 'a' || c > 'p') |
183 return false; | 183 return false; |
184 } | 184 } |
185 | 185 |
186 return true; | 186 return true; |
187 } | 187 } |
188 | 188 |
189 base::FilePath GetChromeExePath(bool is_canary) { | |
190 return is_canary ? chrome_launcher_support::GetAnyChromeSxSPath() | |
191 : chrome_launcher_support::GetAnyChromePath(); | |
192 } | |
193 | |
194 ExitCode GetChrome(bool is_canary) { | 189 ExitCode GetChrome(bool is_canary) { |
195 // Show UI to install Chrome. The UI returns a download URL. | 190 // Show UI to install Chrome. The UI returns a download URL. |
196 base::string16 download_url = | 191 base::string16 download_url = |
197 DownloadAndEulaHTMLDialog(is_canary).ShowModal(); | 192 DownloadAndEulaHTMLDialog(is_canary).ShowModal(); |
198 if (download_url.empty()) | 193 if (download_url.empty()) |
199 return EULA_CANCELLED; | 194 return EULA_CANCELLED; |
200 | 195 |
201 DVLOG(1) << "Chrome download url: " << download_url; | 196 DVLOG(1) << "Chrome download url: " << download_url; |
202 | 197 |
203 // Get a temporary file path. | 198 // Get a temporary file path. |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 | 265 |
271 if (!is_canary) { | 266 if (!is_canary) { |
272 result = parsed_pairs.find(sxs); | 267 result = parsed_pairs.find(sxs); |
273 is_canary = result != parsed_pairs.end() && result->second == "1"; | 268 is_canary = result != parsed_pairs.end() && result->second == "1"; |
274 } | 269 } |
275 } | 270 } |
276 | 271 |
277 if (!IsValidAppId(app_id)) | 272 if (!IsValidAppId(app_id)) |
278 return INVALID_APP_ID; | 273 return INVALID_APP_ID; |
279 | 274 |
280 base::FilePath chrome_path = GetChromeExePath(is_canary); | 275 base::FilePath chrome_path = |
| 276 chrome_launcher_support::GetAnyChromePath(is_canary); |
281 // If none found, show EULA, download, and install Chrome. | 277 // If none found, show EULA, download, and install Chrome. |
282 if (chrome_path.empty()) { | 278 if (chrome_path.empty()) { |
283 ExitCode get_chrome_result = GetChrome(is_canary); | 279 ExitCode get_chrome_result = GetChrome(is_canary); |
284 if (get_chrome_result != SUCCESS) | 280 if (get_chrome_result != SUCCESS) |
285 return get_chrome_result; | 281 return get_chrome_result; |
286 | 282 |
287 chrome_path = GetChromeExePath(is_canary); | 283 chrome_path = chrome_launcher_support::GetAnyChromePath(is_canary); |
288 if (chrome_path.empty()) | 284 if (chrome_path.empty()) |
289 return COULD_NOT_FIND_CHROME; | 285 return COULD_NOT_FIND_CHROME; |
290 } | 286 } |
291 | 287 |
292 base::CommandLine cmd(chrome_path); | 288 base::CommandLine cmd(chrome_path); |
293 cmd.AppendSwitchASCII(kInstallChromeApp, app_id); | 289 cmd.AppendSwitchASCII(kInstallChromeApp, app_id); |
294 DVLOG(1) << "Install command: " << cmd.GetCommandLineString(); | 290 DVLOG(1) << "Install command: " << cmd.GetCommandLineString(); |
295 bool launched = base::LaunchProcess(cmd, base::LaunchOptions(), NULL); | 291 bool launched = base::LaunchProcess(cmd, base::LaunchOptions(), NULL); |
296 DVLOG(1) << "Launch " << (launched ? "success." : "failed."); | 292 DVLOG(1) << "Launch " << (launched ? "success." : "failed."); |
297 | 293 |
298 return SUCCESS; | 294 return SUCCESS; |
299 } | 295 } |
300 | 296 |
301 } // namespace app_installer | 297 } // namespace app_installer |
OLD | NEW |