Chromium Code Reviews| 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/setup/install.h" | 5 #include "chrome/installer/setup/install.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <shlobj.h> | 8 #include <shlobj.h> |
| 9 #include <time.h> | 9 #include <time.h> |
| 10 #include <winuser.h> | 10 #include <winuser.h> |
|
grt (UTC plus 2)
2013/03/05 03:27:10
remove this
gab
2013/03/05 16:29:32
Done.
| |
| 11 | 11 |
| 12 #include <string> | 12 #include <string> |
| 13 | 13 |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/file_util.h" | 15 #include "base/file_util.h" |
| 16 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" |
| 17 #include "base/logging.h" | 17 #include "base/logging.h" |
| 18 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
| 19 #include "base/path_service.h" | 19 #include "base/path_service.h" |
| 20 #include "base/process_util.h" | 20 #include "base/process_util.h" |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 141 void CopyPreferenceFileForFirstRun(const InstallerState& installer_state, | 141 void CopyPreferenceFileForFirstRun(const InstallerState& installer_state, |
| 142 const base::FilePath& prefs_source_path) { | 142 const base::FilePath& prefs_source_path) { |
| 143 base::FilePath prefs_dest_path(installer_state.target_path().AppendASCII( | 143 base::FilePath prefs_dest_path(installer_state.target_path().AppendASCII( |
| 144 installer::kDefaultMasterPrefs)); | 144 installer::kDefaultMasterPrefs)); |
| 145 if (!file_util::CopyFile(prefs_source_path, prefs_dest_path)) { | 145 if (!file_util::CopyFile(prefs_source_path, prefs_dest_path)) { |
| 146 VLOG(1) << "Failed to copy master preferences from:" | 146 VLOG(1) << "Failed to copy master preferences from:" |
| 147 << prefs_source_path.value() << " gle: " << ::GetLastError(); | 147 << prefs_source_path.value() << " gle: " << ::GetLastError(); |
| 148 } | 148 } |
| 149 } | 149 } |
| 150 | 150 |
| 151 // Returns true if the current process is running on the interactive window | 151 // Returns true if the current process is running on the interactive window |
|
grt (UTC plus 2)
2013/03/05 03:27:10
remove this function and mention in the CL descrip
| |
| 152 // station. This cares not whether the input desktop is the default or not | 152 // station. This cares not whether the input desktop is the default or not |
| 153 // (i.e., the screen saver is running, or what have you). | 153 // (i.e., the screen saver is running, or what have you). |
| 154 bool IsInteractiveProcess() { | 154 bool IsInteractiveProcess() { |
| 155 static const wchar_t kWinSta0[] = L"WinSta0"; | 155 static const wchar_t kWinSta0[] = L"WinSta0"; |
| 156 HWINSTA window_station = ::GetProcessWindowStation(); | 156 HWINSTA window_station = ::GetProcessWindowStation(); |
| 157 if (window_station == NULL) { | 157 if (window_station == NULL) { |
| 158 PLOG(ERROR) << "Failed to get window station"; | 158 PLOG(ERROR) << "Failed to get window station"; |
| 159 return false; | 159 return false; |
| 160 } | 160 } |
| 161 | 161 |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 476 // error checking here because this operation will fail if user doesn't | 476 // error checking here because this operation will fail if user doesn't |
| 477 // have admin rights and we want to ignore the error. | 477 // have admin rights and we want to ignore the error. |
| 478 AddChromeToMediaPlayerList(); | 478 AddChromeToMediaPlayerList(); |
| 479 | 479 |
| 480 // Make Chrome the default browser if desired when possible. Otherwise, only | 480 // Make Chrome the default browser if desired when possible. Otherwise, only |
| 481 // register it with Windows. | 481 // register it with Windows. |
| 482 BrowserDistribution* dist = product.distribution(); | 482 BrowserDistribution* dist = product.distribution(); |
| 483 const string16 chrome_exe( | 483 const string16 chrome_exe( |
| 484 installer_state.target_path().Append(installer::kChromeExe).value()); | 484 installer_state.target_path().Append(installer::kChromeExe).value()); |
| 485 VLOG(1) << "Registering Chrome as browser: " << chrome_exe; | 485 VLOG(1) << "Registering Chrome as browser: " << chrome_exe; |
| 486 if (make_chrome_default) { | 486 if (make_chrome_default && ShellUtil::CanMakeChromeDefaultUnattended()) { |
| 487 if (ShellUtil::CanMakeChromeDefaultUnattended()) { | 487 int level = ShellUtil::CURRENT_USER; |
| 488 int level = ShellUtil::CURRENT_USER; | 488 if (installer_state.system_install()) |
| 489 if (installer_state.system_install()) | 489 level = level | ShellUtil::SYSTEM_LEVEL; |
| 490 level = level | ShellUtil::SYSTEM_LEVEL; | 490 ShellUtil::MakeChromeDefault(dist, level, chrome_exe, true); |
| 491 ShellUtil::MakeChromeDefault(dist, level, chrome_exe, true); | |
| 492 } else if (IsInteractiveProcess()) { | |
| 493 ShellUtil::ShowMakeChromeDefaultSystemUI(dist, chrome_exe); | |
| 494 } else { | |
| 495 ShellUtil::RegisterChromeBrowser(dist, chrome_exe, string16(), false); | |
| 496 } | |
| 497 } else { | 491 } else { |
| 498 ShellUtil::RegisterChromeBrowser(dist, chrome_exe, string16(), false); | 492 ShellUtil::RegisterChromeBrowser(dist, chrome_exe, string16(), false); |
| 499 } | 493 } |
| 500 } | 494 } |
| 501 | 495 |
| 502 InstallStatus InstallOrUpdateProduct( | 496 InstallStatus InstallOrUpdateProduct( |
| 503 const InstallationState& original_state, | 497 const InstallationState& original_state, |
| 504 const InstallerState& installer_state, | 498 const InstallerState& installer_state, |
| 505 const base::FilePath& setup_path, | 499 const base::FilePath& setup_path, |
| 506 const base::FilePath& archive_path, | 500 const base::FilePath& archive_path, |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 708 if (app_host_path.empty()) | 702 if (app_host_path.empty()) |
| 709 return false; | 703 return false; |
| 710 | 704 |
| 711 CommandLine cmd(app_host_path); | 705 CommandLine cmd(app_host_path); |
| 712 cmd.AppendSwitchASCII(::switches::kInstallFromWebstore, app_code); | 706 cmd.AppendSwitchASCII(::switches::kInstallFromWebstore, app_code); |
| 713 VLOG(1) << "App install command: " << cmd.GetCommandLineString(); | 707 VLOG(1) << "App install command: " << cmd.GetCommandLineString(); |
| 714 return base::LaunchProcess(cmd, base::LaunchOptions(), NULL); | 708 return base::LaunchProcess(cmd, base::LaunchOptions(), NULL); |
| 715 } | 709 } |
| 716 | 710 |
| 717 } // namespace installer | 711 } // namespace installer |
| OLD | NEW |