| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/browser/first_run.h" | 5 #include "chrome/browser/first_run.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <shellapi.h> | 8 #include <shellapi.h> |
| 9 #include <shlobj.h> | 9 #include <shlobj.h> |
| 10 | 10 |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 return; | 198 return; |
| 199 service->updater()->CheckNow(); | 199 service->updater()->CheckNow(); |
| 200 return; | 200 return; |
| 201 } | 201 } |
| 202 | 202 |
| 203 NotificationRegistrar registrar_; | 203 NotificationRegistrar registrar_; |
| 204 }; | 204 }; |
| 205 | 205 |
| 206 } // namespace | 206 } // namespace |
| 207 | 207 |
| 208 CommandLine* Upgrade::new_command_line_ = NULL; |
| 209 |
| 208 bool FirstRun::CreateChromeDesktopShortcut() { | 210 bool FirstRun::CreateChromeDesktopShortcut() { |
| 209 std::wstring chrome_exe; | 211 std::wstring chrome_exe; |
| 210 if (!PathService::Get(base::FILE_EXE, &chrome_exe)) | 212 if (!PathService::Get(base::FILE_EXE, &chrome_exe)) |
| 211 return false; | 213 return false; |
| 212 BrowserDistribution *dist = BrowserDistribution::GetDistribution(); | 214 BrowserDistribution *dist = BrowserDistribution::GetDistribution(); |
| 213 if (!dist) | 215 if (!dist) |
| 214 return false; | 216 return false; |
| 215 return ShellUtil::CreateChromeDesktopShortcut(chrome_exe, | 217 return ShellUtil::CreateChromeDesktopShortcut(chrome_exe, |
| 216 dist->GetAppDescription(), ShellUtil::CURRENT_USER, | 218 dist->GetAppDescription(), ShellUtil::CURRENT_USER, |
| 217 false, true); // create if doesn't exist. | 219 false, true); // create if doesn't exist. |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 int error = GetLastError(); | 405 int error = GetLastError(); |
| 404 return (error == ERROR_ALREADY_EXISTS || error == ERROR_ACCESS_DENIED); | 406 return (error == ERROR_ALREADY_EXISTS || error == ERROR_ACCESS_DENIED); |
| 405 } | 407 } |
| 406 | 408 |
| 407 bool Upgrade::RelaunchChromeBrowser(const CommandLine& command_line) { | 409 bool Upgrade::RelaunchChromeBrowser(const CommandLine& command_line) { |
| 408 ::SetEnvironmentVariable(google_update::kEnvProductVersionKey, NULL); | 410 ::SetEnvironmentVariable(google_update::kEnvProductVersionKey, NULL); |
| 409 return base::LaunchApp(command_line.command_line_string(), | 411 return base::LaunchApp(command_line.command_line_string(), |
| 410 false, false, NULL); | 412 false, false, NULL); |
| 411 } | 413 } |
| 412 | 414 |
| 415 void Upgrade::RelaunchChromeBrowserWithNewCommandLineIfNeeded() { |
| 416 if (new_command_line_) { |
| 417 if (RelaunchChromeBrowser(*new_command_line_)) { |
| 418 DLOG(ERROR) << "Launching a new instance of the browser failed."; |
| 419 } else { |
| 420 DLOG(WARNING) << "Launched a new instance of the browser."; |
| 421 } |
| 422 delete new_command_line_; |
| 423 new_command_line_ = NULL; |
| 424 } |
| 425 } |
| 426 |
| 413 bool Upgrade::SwapNewChromeExeIfPresent() { | 427 bool Upgrade::SwapNewChromeExeIfPresent() { |
| 414 std::wstring new_chrome_exe; | 428 std::wstring new_chrome_exe; |
| 415 if (!GetNewerChromeFile(&new_chrome_exe)) | 429 if (!GetNewerChromeFile(&new_chrome_exe)) |
| 416 return false; | 430 return false; |
| 417 if (!file_util::PathExists(FilePath::FromWStringHack(new_chrome_exe))) | 431 if (!file_util::PathExists(FilePath::FromWStringHack(new_chrome_exe))) |
| 418 return false; | 432 return false; |
| 419 std::wstring curr_chrome_exe; | 433 std::wstring curr_chrome_exe; |
| 420 if (!PathService::Get(base::FILE_EXE, &curr_chrome_exe)) | 434 if (!PathService::Get(base::FILE_EXE, &curr_chrome_exe)) |
| 421 return false; | 435 return false; |
| 422 | 436 |
| (...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1013 | 1027 |
| 1014 Upgrade::TryResult Upgrade::ShowTryChromeDialog(size_t version) { | 1028 Upgrade::TryResult Upgrade::ShowTryChromeDialog(size_t version) { |
| 1015 if (version > 10000) { | 1029 if (version > 10000) { |
| 1016 // This is a test value. We want to make sure we exercise | 1030 // This is a test value. We want to make sure we exercise |
| 1017 // returning this early. See EarlyReturnTest test harness. | 1031 // returning this early. See EarlyReturnTest test harness. |
| 1018 return Upgrade::TD_NOT_NOW; | 1032 return Upgrade::TD_NOT_NOW; |
| 1019 } | 1033 } |
| 1020 TryChromeDialog td; | 1034 TryChromeDialog td; |
| 1021 return td.ShowModal(); | 1035 return td.ShowModal(); |
| 1022 } | 1036 } |
| 1023 | |
| OLD | NEW |