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

Side by Side Diff: chrome/installer/util/install_util.cc

Issue 1581473002: Remove base/win/metro.{cc|h} and some associated code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixes Created 4 years, 11 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
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 // See the corresponding header file for description of the functions in this 5 // See the corresponding header file for description of the functions in this
6 // file. 6 // file.
7 7
8 #include "chrome/installer/util/install_util.h" 8 #include "chrome/installer/util/install_util.h"
9 9
10 #include <shellapi.h> 10 #include <shellapi.h>
11 #include <shlobj.h> 11 #include <shlobj.h>
12 #include <shlwapi.h> 12 #include <shlwapi.h>
13 13
14 #include <algorithm> 14 #include <algorithm>
15 15
16 #include "base/command_line.h" 16 #include "base/command_line.h"
17 #include "base/environment.h" 17 #include "base/environment.h"
18 #include "base/files/file_util.h" 18 #include "base/files/file_util.h"
19 #include "base/logging.h" 19 #include "base/logging.h"
20 #include "base/macros.h" 20 #include "base/macros.h"
21 #include "base/memory/scoped_ptr.h" 21 #include "base/memory/scoped_ptr.h"
22 #include "base/numerics/safe_conversions.h" 22 #include "base/numerics/safe_conversions.h"
23 #include "base/path_service.h" 23 #include "base/path_service.h"
24 #include "base/process/launch.h" 24 #include "base/process/launch.h"
25 #include "base/strings/string_util.h" 25 #include "base/strings/string_util.h"
26 #include "base/strings/utf_string_conversions.h" 26 #include "base/strings/utf_string_conversions.h"
27 #include "base/sys_info.h" 27 #include "base/sys_info.h"
28 #include "base/values.h" 28 #include "base/values.h"
29 #include "base/version.h" 29 #include "base/version.h"
30 #include "base/win/metro.h"
31 #include "base/win/registry.h" 30 #include "base/win/registry.h"
32 #include "base/win/windows_version.h" 31 #include "base/win/windows_version.h"
33 #include "chrome/common/chrome_constants.h" 32 #include "chrome/common/chrome_constants.h"
34 #include "chrome/common/chrome_paths.h" 33 #include "chrome/common/chrome_paths.h"
35 #include "chrome/installer/util/browser_distribution.h" 34 #include "chrome/installer/util/browser_distribution.h"
36 #include "chrome/installer/util/google_update_constants.h" 35 #include "chrome/installer/util/google_update_constants.h"
37 #include "chrome/installer/util/helper.h" 36 #include "chrome/installer/util/helper.h"
38 #include "chrome/installer/util/installation_state.h" 37 #include "chrome/installer/util/installation_state.h"
39 #include "chrome/installer/util/l10n_string_util.h" 38 #include "chrome/installer/util/l10n_string_util.h"
40 #include "chrome/installer/util/util_constants.h" 39 #include "chrome/installer/util/util_constants.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 } else { 122 } else {
124 NOTREACHED() << "Unable to get default monitor"; 123 NOTREACHED() << "Unable to get default monitor";
125 } 124 }
126 ::SetForegroundWindow(foreground_window); 125 ::SetForegroundWindow(foreground_window);
127 } 126 }
128 return foreground_window; 127 return foreground_window;
129 } 128 }
130 129
131 } // namespace 130 } // namespace
132 131
133 bool InstallUtil::ShouldInstallMetroProperties() {
134 // Install Metro properties on Windows versions that Chrome supports as well
135 // as on any version prior to Win8 to ease in-place upgrades to Win8.
136 return base::win::IsChromeMetroSupported() ||
137 base::win::GetVersion() < base::win::VERSION_WIN8;
138 }
139
140 base::string16 InstallUtil::GetActiveSetupPath(BrowserDistribution* dist) { 132 base::string16 InstallUtil::GetActiveSetupPath(BrowserDistribution* dist) {
141 static const wchar_t kInstalledComponentsPath[] = 133 static const wchar_t kInstalledComponentsPath[] =
142 L"Software\\Microsoft\\Active Setup\\Installed Components\\"; 134 L"Software\\Microsoft\\Active Setup\\Installed Components\\";
143 return kInstalledComponentsPath + dist->GetActiveSetupGuid(); 135 return kInstalledComponentsPath + dist->GetActiveSetupGuid();
144 } 136 }
145 137
146 void InstallUtil::TriggerActiveSetupCommand() { 138 void InstallUtil::TriggerActiveSetupCommand() {
147 base::string16 active_setup_reg( 139 base::string16 active_setup_reg(
148 GetActiveSetupPath(BrowserDistribution::GetDistribution())); 140 GetActiveSetupPath(BrowserDistribution::GetDistribution()));
149 base::win::RegKey active_setup_key( 141 base::win::RegKey active_setup_key(
150 HKEY_LOCAL_MACHINE, active_setup_reg.c_str(), KEY_QUERY_VALUE); 142 HKEY_LOCAL_MACHINE, active_setup_reg.c_str(), KEY_QUERY_VALUE);
151 base::string16 cmd_str; 143 base::string16 cmd_str;
152 LONG read_status = active_setup_key.ReadValue(L"StubPath", &cmd_str); 144 LONG read_status = active_setup_key.ReadValue(L"StubPath", &cmd_str);
153 if (read_status != ERROR_SUCCESS) { 145 if (read_status != ERROR_SUCCESS) {
154 LOG(ERROR) << active_setup_reg << ", " << read_status; 146 LOG(ERROR) << active_setup_reg << ", " << read_status;
155 // This should never fail if Chrome is registered at system-level, but if it 147 // This should never fail if Chrome is registered at system-level, but if it
156 // does there is not much else to be done. 148 // does there is not much else to be done.
157 return; 149 return;
158 } 150 }
159 151
160 base::CommandLine cmd(base::CommandLine::FromString(cmd_str)); 152 base::CommandLine cmd(base::CommandLine::FromString(cmd_str));
161 // Force creation of shortcuts as the First Run beacon might land between now 153 // Force creation of shortcuts as the First Run beacon might land between now
162 // and the time setup.exe checks for it. 154 // and the time setup.exe checks for it.
163 cmd.AppendSwitch(installer::switches::kForceConfigureUserSettings); 155 cmd.AppendSwitch(installer::switches::kForceConfigureUserSettings);
164 156
165 base::LaunchOptions launch_options; 157 base::LaunchOptions launch_options;
gab 2016/01/12 21:11:04 inline base::LaunchOptions()
scottmg 2016/01/13 20:48:16 Done.
166 if (base::win::IsMetroProcess())
167 launch_options.force_breakaway_from_job_ = true;
168 base::Process process = 158 base::Process process =
169 base::LaunchProcess(cmd.GetCommandLineString(), launch_options); 159 base::LaunchProcess(cmd.GetCommandLineString(), launch_options);
170 if (!process.IsValid()) 160 if (!process.IsValid())
171 PLOG(ERROR) << cmd.GetCommandLineString(); 161 PLOG(ERROR) << cmd.GetCommandLineString();
172 } 162 }
173 163
174 bool InstallUtil::ExecuteExeAsAdmin(const base::CommandLine& cmd, 164 bool InstallUtil::ExecuteExeAsAdmin(const base::CommandLine& cmd,
175 DWORD* exit_code) { 165 DWORD* exit_code) {
176 base::FilePath::StringType program(cmd.GetProgram().value()); 166 base::FilePath::StringType program(cmd.GetProgram().value());
177 DCHECK(!program.empty()); 167 DCHECK(!program.empty());
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 // Open the program and see if it references the expected file. 673 // Open the program and see if it references the expected file.
684 base::File file; 674 base::File file;
685 BY_HANDLE_FILE_INFORMATION info = {}; 675 BY_HANDLE_FILE_INFORMATION info = {};
686 676
687 return (OpenForInfo(path, &file) && 677 return (OpenForInfo(path, &file) &&
688 GetInfo(file, &info) && 678 GetInfo(file, &info) &&
689 info.dwVolumeSerialNumber == file_info_.dwVolumeSerialNumber && 679 info.dwVolumeSerialNumber == file_info_.dwVolumeSerialNumber &&
690 info.nFileIndexHigh == file_info_.nFileIndexHigh && 680 info.nFileIndexHigh == file_info_.nFileIndexHigh &&
691 info.nFileIndexLow == file_info_.nFileIndexLow); 681 info.nFileIndexLow == file_info_.nFileIndexLow);
692 } 682 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698