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

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

Issue 10957016: Ensuring Google Update at user-level is installed alongside App Host, for the quick-enable App Host… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/installer/util/google_update_util.h"
6
7 #include "base/command_line.h"
8 #include "base/file_path.h"
9 #include "base/file_util.h"
10 #include "base/logging.h"
11 #include "base/process_util.h"
12 #include "base/string16.h"
13 #include "base/win/registry.h"
14 #include "chrome/installer/launcher_support/chrome_launcher_support.h"
15 #include "chrome/installer/util/google_update_constants.h"
16
17 using base::win::RegKey;
18
19 namespace google_update {
20
21 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.
22 const HKEY root_key = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
23 RegKey update_key;
24
25 if (update_key.Open(root_key, google_update::kRegPathGoogleUpdate,
26 KEY_QUERY_VALUE) == ERROR_SUCCESS) {
27 string16 path_str;
28 string16 version_str;
29 if ((update_key.ReadValue(google_update::kRegPathField,
30 &path_str) == ERROR_SUCCESS) &&
huangs 2012/09/20 15:24:54 path_str will fit in the previous line, but right
31 (update_key.ReadValue(google_update::kRegGoogleUpdateVersion,
32 &version_str) == ERROR_SUCCESS)) {
33 FilePath google_update_setup(FilePath(path_str).DirName().
34 Append(version_str).
35 Append(kGoogleUpdateSetupExecutable));
36 if (file_util::PathExists(google_update_setup))
37 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.
38 }
39 }
40 return FilePath();
41 }
42
43 void AppendUserLevelGoogleUpdateInstallParam(CommandLine& cmd_line) {
44 // 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.
45 cmd_line.AppendArg("/install");
46 // The "&" can be used in base::LaunchProcess() without quotation
47 // (this is problematic only if run from command prompt).
48 cmd_line.AppendArg("runtime=true&needsadmin=false");
49 cmd_line.AppendArg("/silent");
50 }
51
52 bool EnsureUserLevelGoogleUpdateInstalled() {
53 VLOG(1) << "Ensuring Google Update is installed at user level";
54 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
55 FilePath google_update_setup(GetGoogleUpdateSetupExe(true));
56 if (!google_update_setup.empty()) {
57 CommandLine cmd_line(google_update_setup);
58 AppendUserLevelGoogleUpdateInstallParam(cmd_line);
59 VLOG(1) << "Command line: " << cmd_line.GetCommandLineString();
60 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
61 } else {
62 LOG(ERROR) << "Cannot find " << kGoogleUpdateSetupExecutable;
63 }
64 } else {
65 VLOG(1) << "Google Update already installed";
66 return true;
67 }
68 return false;
69 }
70
71 } // namespace google_update
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698