Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(557)

Side by Side Diff: chrome/installer/setup/install.cc

Issue 12398024: Do not try to make Chrome default when registering it if it can't be made default unattended. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nits Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/installer/setup/install.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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>
11 10
12 #include <string> 11 #include <string>
13 12
14 #include "base/command_line.h" 13 #include "base/command_line.h"
15 #include "base/file_util.h" 14 #include "base/file_util.h"
16 #include "base/files/file_path.h" 15 #include "base/files/file_path.h"
17 #include "base/logging.h" 16 #include "base/logging.h"
18 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
19 #include "base/path_service.h" 18 #include "base/path_service.h"
20 #include "base/process_util.h" 19 #include "base/process_util.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 void CopyPreferenceFileForFirstRun(const InstallerState& installer_state, 140 void CopyPreferenceFileForFirstRun(const InstallerState& installer_state,
142 const base::FilePath& prefs_source_path) { 141 const base::FilePath& prefs_source_path) {
143 base::FilePath prefs_dest_path(installer_state.target_path().AppendASCII( 142 base::FilePath prefs_dest_path(installer_state.target_path().AppendASCII(
144 installer::kDefaultMasterPrefs)); 143 installer::kDefaultMasterPrefs));
145 if (!file_util::CopyFile(prefs_source_path, prefs_dest_path)) { 144 if (!file_util::CopyFile(prefs_source_path, prefs_dest_path)) {
146 VLOG(1) << "Failed to copy master preferences from:" 145 VLOG(1) << "Failed to copy master preferences from:"
147 << prefs_source_path.value() << " gle: " << ::GetLastError(); 146 << prefs_source_path.value() << " gle: " << ::GetLastError();
148 } 147 }
149 } 148 }
150 149
151 // Returns true if the current process is running on the interactive window
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).
154 bool IsInteractiveProcess() {
155 static const wchar_t kWinSta0[] = L"WinSta0";
156 HWINSTA window_station = ::GetProcessWindowStation();
157 if (window_station == NULL) {
158 PLOG(ERROR) << "Failed to get window station";
159 return false;
160 }
161
162 // Make the buffer one char longer and zero it to be certain it's terminated.
163 wchar_t name[arraysize(kWinSta0) + 1] = {};
164 DWORD buffer_length = sizeof(kWinSta0);
165 DWORD name_length = 0;
166 return (GetUserObjectInformation(window_station, UOI_NAME, &name[0],
167 buffer_length, &name_length) &&
168 name_length == buffer_length &&
169 lstrcmpi(kWinSta0, name) == 0);
170 }
171
172 // This function installs a new version of Chrome to the specified location. 150 // This function installs a new version of Chrome to the specified location.
173 // 151 //
174 // setup_path: Path to the executable (setup.exe) as it will be copied 152 // setup_path: Path to the executable (setup.exe) as it will be copied
175 // to Chrome install folder after install is complete 153 // to Chrome install folder after install is complete
176 // archive_path: Path to the archive (chrome.7z) as it will be copied 154 // archive_path: Path to the archive (chrome.7z) as it will be copied
177 // to Chrome install folder after install is complete 155 // to Chrome install folder after install is complete
178 // src_path: the path that contains a complete and unpacked Chrome package 156 // src_path: the path that contains a complete and unpacked Chrome package
179 // to be installed. 157 // to be installed.
180 // temp_path: the path of working directory used during installation. This path 158 // temp_path: the path of working directory used during installation. This path
181 // does not need to exist. 159 // does not need to exist.
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 // error checking here because this operation will fail if user doesn't 454 // error checking here because this operation will fail if user doesn't
477 // have admin rights and we want to ignore the error. 455 // have admin rights and we want to ignore the error.
478 AddChromeToMediaPlayerList(); 456 AddChromeToMediaPlayerList();
479 457
480 // Make Chrome the default browser if desired when possible. Otherwise, only 458 // Make Chrome the default browser if desired when possible. Otherwise, only
481 // register it with Windows. 459 // register it with Windows.
482 BrowserDistribution* dist = product.distribution(); 460 BrowserDistribution* dist = product.distribution();
483 const string16 chrome_exe( 461 const string16 chrome_exe(
484 installer_state.target_path().Append(installer::kChromeExe).value()); 462 installer_state.target_path().Append(installer::kChromeExe).value());
485 VLOG(1) << "Registering Chrome as browser: " << chrome_exe; 463 VLOG(1) << "Registering Chrome as browser: " << chrome_exe;
486 if (make_chrome_default) { 464 if (make_chrome_default && ShellUtil::CanMakeChromeDefaultUnattended()) {
487 if (ShellUtil::CanMakeChromeDefaultUnattended()) { 465 int level = ShellUtil::CURRENT_USER;
488 int level = ShellUtil::CURRENT_USER; 466 if (installer_state.system_install())
489 if (installer_state.system_install()) 467 level = level | ShellUtil::SYSTEM_LEVEL;
490 level = level | ShellUtil::SYSTEM_LEVEL; 468 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 { 469 } else {
498 ShellUtil::RegisterChromeBrowser(dist, chrome_exe, string16(), false); 470 ShellUtil::RegisterChromeBrowser(dist, chrome_exe, string16(), false);
499 } 471 }
500 } 472 }
501 473
502 InstallStatus InstallOrUpdateProduct( 474 InstallStatus InstallOrUpdateProduct(
503 const InstallationState& original_state, 475 const InstallationState& original_state,
504 const InstallerState& installer_state, 476 const InstallerState& installer_state,
505 const base::FilePath& setup_path, 477 const base::FilePath& setup_path,
506 const base::FilePath& archive_path, 478 const base::FilePath& archive_path,
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 if (app_host_path.empty()) 680 if (app_host_path.empty())
709 return false; 681 return false;
710 682
711 CommandLine cmd(app_host_path); 683 CommandLine cmd(app_host_path);
712 cmd.AppendSwitchASCII(::switches::kInstallFromWebstore, app_code); 684 cmd.AppendSwitchASCII(::switches::kInstallFromWebstore, app_code);
713 VLOG(1) << "App install command: " << cmd.GetCommandLineString(); 685 VLOG(1) << "App install command: " << cmd.GetCommandLineString();
714 return base::LaunchProcess(cmd, base::LaunchOptions(), NULL); 686 return base::LaunchProcess(cmd, base::LaunchOptions(), NULL);
715 } 687 }
716 688
717 } // namespace installer 689 } // namespace installer
OLDNEW
« no previous file with comments | « chrome/installer/setup/install.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698