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 |
new file mode 100755 |
index 0000000000000000000000000000000000000000..26fd41132ce82aa46e35d1e7e1b151d8c0509136 |
--- /dev/null |
+++ b/chrome/installer/util/google_update_util.cc |
@@ -0,0 +1,71 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/installer/util/google_update_util.h" |
+ |
+#include "base/command_line.h" |
+#include "base/file_path.h" |
+#include "base/file_util.h" |
+#include "base/logging.h" |
+#include "base/process_util.h" |
+#include "base/string16.h" |
+#include "base/win/registry.h" |
+#include "chrome/installer/launcher_support/chrome_launcher_support.h" |
+#include "chrome/installer/util/google_update_constants.h" |
+ |
+using base::win::RegKey; |
+ |
+namespace google_update { |
+ |
+FilePath GetGoogleUpdateSetupExe(bool system_install) { |
erikwright (departed)
2012/09/20 18:00:01
doesn't match name in header file, but it's probab
huangs
2012/09/21 01:43:14
Done.
|
+ const HKEY root_key = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
+ RegKey update_key; |
+ |
+ if (update_key.Open(root_key, google_update::kRegPathGoogleUpdate, |
+ KEY_QUERY_VALUE) == ERROR_SUCCESS) { |
+ string16 path_str; |
+ string16 version_str; |
+ if ((update_key.ReadValue(google_update::kRegPathField, |
+ &path_str) == ERROR_SUCCESS) && |
huangs
2012/09/20 15:24:54
path_str will fit in the previous line, but right
|
+ (update_key.ReadValue(google_update::kRegGoogleUpdateVersion, |
+ &version_str) == ERROR_SUCCESS)) { |
+ FilePath google_update_setup(FilePath(path_str).DirName(). |
+ Append(version_str). |
+ Append(kGoogleUpdateSetupExecutable)); |
+ if (file_util::PathExists(google_update_setup)) |
+ return google_update_setup; |
erikwright (departed)
2012/09/20 18:00:01
if this doesn't exist, it's very unusual. LOG an E
huangs
2012/09/21 01:43:14
Done.
|
+ } |
+ } |
+ return FilePath(); |
+} |
+ |
+void AppendUserLevelGoogleUpdateInstallParam(CommandLine& cmd_line) { |
+ // Constants are found in googleclient/omaha/base/const_cmd_line.h. |
grt (UTC plus 2)
2012/09/20 17:58:51
please refer to omaha code by way of code.google.c
huangs
2012/09/21 01:43:14
Done. Also, I had a typo; it's in omaha/common.
|
+ cmd_line.AppendArg("/install"); |
+ // The "&" can be used in base::LaunchProcess() without quotation |
+ // (this is problematic only if run from command prompt). |
+ cmd_line.AppendArg("runtime=true&needsadmin=false"); |
+ cmd_line.AppendArg("/silent"); |
+} |
+ |
+bool EnsureUserLevelGoogleUpdateInstalled() { |
+ VLOG(1) << "Ensuring Google Update is installed at user level"; |
+ if (GetGoogleUpdateSetupExe(false).empty()) { |
erikwright (departed)
2012/09/20 18:00:01
I have mixed feelings about using the presence of
huangs
2012/09/21 01:43:14
Done. Added simple local routine IsGoogleUpdateIn
|
+ FilePath google_update_setup(GetGoogleUpdateSetupExe(true)); |
+ if (!google_update_setup.empty()) { |
+ CommandLine cmd_line(google_update_setup); |
+ AppendUserLevelGoogleUpdateInstallParam(cmd_line); |
+ VLOG(1) << "Command line: " << cmd_line.GetCommandLineString(); |
+ return base::LaunchProcess(cmd_line, base::LaunchOptions(), NULL); |
erikwright (departed)
2012/09/20 18:00:01
Probably appropriate to wait up to some timeout fo
huangs
2012/09/21 01:43:14
Wrote the time-out code, but can I output the retu
|
+ } else { |
+ LOG(ERROR) << "Cannot find " << kGoogleUpdateSetupExecutable; |
+ } |
+ } else { |
+ VLOG(1) << "Google Update already installed"; |
+ return true; |
+ } |
+ return false; |
+} |
+ |
+} // namespace google_update |