| 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 | |
| 210 bool FirstRun::CreateChromeDesktopShortcut() { | 208 bool FirstRun::CreateChromeDesktopShortcut() { |
| 211 std::wstring chrome_exe; | 209 std::wstring chrome_exe; |
| 212 if (!PathService::Get(base::FILE_EXE, &chrome_exe)) | 210 if (!PathService::Get(base::FILE_EXE, &chrome_exe)) |
| 213 return false; | 211 return false; |
| 214 BrowserDistribution *dist = BrowserDistribution::GetDistribution(); | 212 BrowserDistribution *dist = BrowserDistribution::GetDistribution(); |
| 215 if (!dist) | 213 if (!dist) |
| 216 return false; | 214 return false; |
| 217 return ShellUtil::CreateChromeDesktopShortcut(chrome_exe, | 215 return ShellUtil::CreateChromeDesktopShortcut(chrome_exe, |
| 218 dist->GetAppDescription(), ShellUtil::CURRENT_USER, | 216 dist->GetAppDescription(), ShellUtil::CURRENT_USER, |
| 219 false, true); // create if doesn't exist. | 217 false, true); // create if doesn't exist. |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 int error = GetLastError(); | 403 int error = GetLastError(); |
| 406 return (error == ERROR_ALREADY_EXISTS || error == ERROR_ACCESS_DENIED); | 404 return (error == ERROR_ALREADY_EXISTS || error == ERROR_ACCESS_DENIED); |
| 407 } | 405 } |
| 408 | 406 |
| 409 bool Upgrade::RelaunchChromeBrowser(const CommandLine& command_line) { | 407 bool Upgrade::RelaunchChromeBrowser(const CommandLine& command_line) { |
| 410 ::SetEnvironmentVariable(google_update::kEnvProductVersionKey, NULL); | 408 ::SetEnvironmentVariable(google_update::kEnvProductVersionKey, NULL); |
| 411 return base::LaunchApp(command_line.command_line_string(), | 409 return base::LaunchApp(command_line.command_line_string(), |
| 412 false, false, NULL); | 410 false, false, NULL); |
| 413 } | 411 } |
| 414 | 412 |
| 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 | |
| 427 bool Upgrade::SwapNewChromeExeIfPresent() { | 413 bool Upgrade::SwapNewChromeExeIfPresent() { |
| 428 std::wstring new_chrome_exe; | 414 std::wstring new_chrome_exe; |
| 429 if (!GetNewerChromeFile(&new_chrome_exe)) | 415 if (!GetNewerChromeFile(&new_chrome_exe)) |
| 430 return false; | 416 return false; |
| 431 if (!file_util::PathExists(FilePath::FromWStringHack(new_chrome_exe))) | 417 if (!file_util::PathExists(FilePath::FromWStringHack(new_chrome_exe))) |
| 432 return false; | 418 return false; |
| 433 std::wstring curr_chrome_exe; | 419 std::wstring curr_chrome_exe; |
| 434 if (!PathService::Get(base::FILE_EXE, &curr_chrome_exe)) | 420 if (!PathService::Get(base::FILE_EXE, &curr_chrome_exe)) |
| 435 return false; | 421 return false; |
| 436 | 422 |
| (...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1027 | 1013 |
| 1028 Upgrade::TryResult Upgrade::ShowTryChromeDialog(size_t version) { | 1014 Upgrade::TryResult Upgrade::ShowTryChromeDialog(size_t version) { |
| 1029 if (version > 10000) { | 1015 if (version > 10000) { |
| 1030 // This is a test value. We want to make sure we exercise | 1016 // This is a test value. We want to make sure we exercise |
| 1031 // returning this early. See EarlyReturnTest test harness. | 1017 // returning this early. See EarlyReturnTest test harness. |
| 1032 return Upgrade::TD_NOT_NOW; | 1018 return Upgrade::TD_NOT_NOW; |
| 1033 } | 1019 } |
| 1034 TryChromeDialog td; | 1020 TryChromeDialog td; |
| 1035 return td.ShowModal(); | 1021 return td.ShowModal(); |
| 1036 } | 1022 } |
| 1023 |
| OLD | NEW |