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

Unified Diff: chrome/installer/util/google_update_util.cc

Issue 216153006: Invoke setup.exe to reenable updates when the update bubble is clicked. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mad2
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/installer/util/google_update_util.cc
diff --git a/chrome/installer/util/google_update_util.cc b/chrome/installer/util/google_update_util.cc
index 18ea762e8f97147f26c7c9fd5b2bd23f4cd0b1ba..876372c97f4775bc2503377a371430022e2084c3 100644
--- a/chrome/installer/util/google_update_util.cc
+++ b/chrome/installer/util/google_update_util.cc
@@ -11,9 +11,11 @@
#include "base/command_line.h"
#include "base/environment.h"
+#include "base/file_util.h"
#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
+#include "base/path_service.h"
#include "base/process/kill.h"
#include "base/process/launch.h"
#include "base/strings/string16.h"
@@ -21,9 +23,12 @@
#include "base/time/time.h"
#include "base/win/registry.h"
#include "base/win/scoped_handle.h"
+#include "base/win/win_util.h"
+#include "base/win/windows_version.h"
#include "chrome/installer/launcher_support/chrome_launcher_support.h"
#include "chrome/installer/util/google_update_constants.h"
#include "chrome/installer/util/google_update_settings.h"
+#include "chrome/installer/util/install_util.h"
using base::win::RegKey;
@@ -217,6 +222,46 @@ bool UninstallGoogleUpdate(bool system_install) {
return success;
}
+bool ElevateIfNeededToReenableUpdates() {
+ base::FilePath chrome_exe;
+ PathService::Get(base::FILE_EXE, &chrome_exe);
+ base::FilePath exe_path =
+ base::FilePath(chrome_exe).DirName().Append(installer::kSetupExe);
+ if (!base::PathExists(exe_path)) {
+ HKEY reg_root = InstallUtil::IsPerUserInstall(chrome_exe.value().c_str()) ?
+ HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE;
+ BrowserDistribution* dist =
+ BrowserDistribution::GetSpecificDistribution(
+ BrowserDistribution::CHROME_BROWSER);
+ RegKey key(reg_root, dist->GetUninstallRegPath().c_str(), KEY_READ);
+ base::string16 uninstall_string;
+ key.ReadValue(installer::kUninstallStringField, &uninstall_string);
+ CommandLine command_line = CommandLine::FromString(uninstall_string);
+ exe_path = command_line.GetProgram();
+ }
+
+ if (!base::PathExists(exe_path)) {
+ LOG(ERROR) << "Could not find setup.exe to reenable updates.";
+ return false;
+ }
+
+ CommandLine cmd(exe_path);
+ cmd.AppendSwitch(installer::switches::kReenableAutoupdates);
+
+ if (!InstallUtil::IsPerUserInstall(chrome_exe.value().c_str()))
+ cmd.AppendSwitch(installer::switches::kSystemLevel);
+
+ base::LaunchOptions launch_options;
+ launch_options.force_breakaway_from_job_ = true;
+
+ if (base::win::GetVersion() >= base::win::VERSION_VISTA &&
+ base::win::UserAccountControlIsEnabled()) {
+ return base::LaunchElevatedProcess(cmd, launch_options, NULL);
+ } else {
+ return base::LaunchProcess(cmd, launch_options, NULL);
+ }
+}
+
std::string GetUntrustedDataValue(const std::string& key) {
std::map<std::string, std::string> untrusted_data;
if (GetGoogleUpdateUntrustedData(&untrusted_data)) {

Powered by Google App Engine
This is Rietveld 408576698