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

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

Issue 217533005: Invoke setup.exe to reenable updates when the update bubble is clicked. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: i can haz linux compile? Created 6 years, 8 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/util/google_update_util.h ('k') | chrome/installer/util/util_constants.h » ('j') | 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/util/google_update_util.h" 5 #include "chrome/installer/util/google_update_util.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/environment.h" 13 #include "base/environment.h"
14 #include "base/file_util.h"
14 #include "base/files/file_path.h" 15 #include "base/files/file_path.h"
15 #include "base/logging.h" 16 #include "base/logging.h"
16 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
18 #include "base/path_service.h"
17 #include "base/process/kill.h" 19 #include "base/process/kill.h"
18 #include "base/process/launch.h" 20 #include "base/process/launch.h"
19 #include "base/strings/string16.h" 21 #include "base/strings/string16.h"
20 #include "base/strings/string_split.h" 22 #include "base/strings/string_split.h"
21 #include "base/time/time.h" 23 #include "base/time/time.h"
22 #include "base/win/registry.h" 24 #include "base/win/registry.h"
23 #include "base/win/scoped_handle.h" 25 #include "base/win/scoped_handle.h"
26 #include "base/win/win_util.h"
27 #include "base/win/windows_version.h"
24 #include "chrome/installer/launcher_support/chrome_launcher_support.h" 28 #include "chrome/installer/launcher_support/chrome_launcher_support.h"
29 #include "chrome/installer/util/browser_distribution.h"
25 #include "chrome/installer/util/google_update_constants.h" 30 #include "chrome/installer/util/google_update_constants.h"
26 #include "chrome/installer/util/google_update_settings.h" 31 #include "chrome/installer/util/google_update_settings.h"
32 #include "chrome/installer/util/install_util.h"
33 #include "chrome/installer/util/installation_state.h"
34 #include "chrome/installer/util/product.h"
27 35
28 using base::win::RegKey; 36 using base::win::RegKey;
29 37
30 namespace google_update { 38 namespace google_update {
31 39
32 namespace { 40 namespace {
33 41
34 const int kGoogleUpdateTimeoutMs = 20 * 1000; 42 const int kGoogleUpdateTimeoutMs = 20 * 1000;
35 43
36 const char kEnvVariableUntrustedData[] = "GoogleUpdateUntrustedData"; 44 const char kEnvVariableUntrustedData[] = "GoogleUpdateUntrustedData";
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 GoogleUpdateSettings::GetUninstallCommandLine(system_install)); 218 GoogleUpdateSettings::GetUninstallCommandLine(system_install));
211 if (cmd_string.empty()) { 219 if (cmd_string.empty()) {
212 success = true; // Nothing to; vacuous success. 220 success = true; // Nothing to; vacuous success.
213 } else { 221 } else {
214 success = LaunchProcessAndWaitWithTimeout(cmd_string, 222 success = LaunchProcessAndWaitWithTimeout(cmd_string,
215 base::TimeDelta::FromMilliseconds(kGoogleUpdateTimeoutMs)); 223 base::TimeDelta::FromMilliseconds(kGoogleUpdateTimeoutMs));
216 } 224 }
217 return success; 225 return success;
218 } 226 }
219 227
228 void ElevateIfNeededToReenableUpdates() {
229 base::FilePath chrome_exe;
230 if (!PathService::Get(base::FILE_EXE, &chrome_exe)) {
231 NOTREACHED();
232 return;
233 }
234 installer::ProductState product_state;
235 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
236 const bool system_install = !InstallUtil::IsPerUserInstall(
237 chrome_exe.value().c_str());
238 if (!product_state.Initialize(system_install, dist))
239 return;
240 base::FilePath exe_path(product_state.GetSetupPath());
241 if (exe_path.empty() || !base::PathExists(exe_path)) {
242 LOG(ERROR) << "Could not find setup.exe to reenable updates.";
243 return;
244 }
245
246 CommandLine cmd(exe_path);
247 cmd.AppendSwitch(installer::switches::kReenableAutoupdates);
248 installer::Product product(dist);
249 product.InitializeFromUninstallCommand(product_state.uninstall_command());
250 product.AppendProductFlags(&cmd);
251 if (system_install)
252 cmd.AppendSwitch(installer::switches::kSystemLevel);
253 if (product_state.uninstall_command().HasSwitch(
254 installer::switches::kVerboseLogging)) {
255 cmd.AppendSwitch(installer::switches::kVerboseLogging);
256 }
257
258 base::LaunchOptions launch_options;
259 launch_options.force_breakaway_from_job_ = true;
260
261 if (base::win::GetVersion() >= base::win::VERSION_VISTA &&
262 base::win::UserAccountControlIsEnabled()) {
263 base::LaunchElevatedProcess(cmd, launch_options, NULL);
264 } else {
265 base::LaunchProcess(cmd, launch_options, NULL);
266 }
267 }
268
220 std::string GetUntrustedDataValue(const std::string& key) { 269 std::string GetUntrustedDataValue(const std::string& key) {
221 std::map<std::string, std::string> untrusted_data; 270 std::map<std::string, std::string> untrusted_data;
222 if (GetGoogleUpdateUntrustedData(&untrusted_data)) { 271 if (GetGoogleUpdateUntrustedData(&untrusted_data)) {
223 std::map<std::string, std::string>::const_iterator data_it( 272 std::map<std::string, std::string>::const_iterator data_it(
224 untrusted_data.find(key)); 273 untrusted_data.find(key));
225 if (data_it != untrusted_data.end()) 274 if (data_it != untrusted_data.end())
226 return data_it->second; 275 return data_it->second;
227 } 276 }
228 277
229 return std::string(); 278 return std::string();
230 } 279 }
231 280
232 std::string GetUntrustedDataValueFromTag(const std::string& tag, 281 std::string GetUntrustedDataValueFromTag(const std::string& tag,
233 const std::string& key) { 282 const std::string& key) {
234 std::map<std::string, std::string> untrusted_data; 283 std::map<std::string, std::string> untrusted_data;
235 if (ParseUntrustedData(tag, &untrusted_data)) 284 if (ParseUntrustedData(tag, &untrusted_data))
236 return untrusted_data[key]; 285 return untrusted_data[key];
237 286
238 return std::string(); 287 return std::string();
239 } 288 }
240 289
241 } // namespace google_update 290 } // namespace google_update
OLDNEW
« no previous file with comments | « chrome/installer/util/google_update_util.h ('k') | chrome/installer/util/util_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698