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

Side by Side Diff: chrome/browser/extensions/app_host/app_host_upgrade.cc

Issue 10905238: If Chrome Binaries version > App Host version, then update App Host. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Refactoring; adding app_host_upgrade.*; focusing on system-level setup.exe. 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
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/browser/extensions/app_host/app_host_upgrade.h"
6 #include "chrome/installer/launcher_support/chrome_launcher_support.h"
erikwright (departed) 2012/09/13 01:13:44 chrome_launcher_support should be ordered with the
huangs 2012/09/13 04:40:47 Done.
7
8 #include <windows.h>
9 #include <tchar.h>
erikwright (departed) 2012/09/13 01:13:44 what is tchar used for?
huangs 2012/09/13 04:40:47 I mistakenly thought it was needed for wchar_t. D
10 #include "base/command_line.h"
11 #include "base/logging.h"
12 #include "base/process_util.h"
13 #include "base/string16.h"
14 #include "base/string_util.h"
15 #include "base/version.h"
16 #include "base/win/registry.h"
17
18 namespace app_host {
19
20 const wchar_t kGoogleRegClientsKey[] =
erikwright (departed) 2012/09/13 01:13:44 anonymous namespace for this and other constants n
huangs 2012/09/13 04:40:47 Done.
21 L"Software\\Google\\Update\\Clients\\";
22
23 // Copied from chrome_appid.cc
24 const wchar_t kMultiInstallAppGuid[] =
25 L"{4DC8B4CA-1BDA-483e-B5FA-D3C12E15B62D}";
26 const wchar_t kChromeAppHostAppGuid[] =
27 L"{FDA71E6F-AC4C-4a00-8B70-9958A68906BF}";
28
29 // Copied from util_constants.cc
30 const char kMultiInstall[] = "multi-install";
31 const char kChromeAppHost[] = "app-host";
32 const char kVerboseLogging[] = "verbose-logging";
33
34 // Copied from google_update_constants.cc
35 const wchar_t kRegVersionField[] = L"pv";
36
37 // TODO(huangs): Refactor parameter |system_level|.
erikwright (departed) 2012/09/13 01:13:44 TODO unnecessary.
huangs 2012/09/13 04:40:47 Done.
38 bool GetAppVersionForInstallationLevel(const wchar_t* app_guid,
39 bool system_level,
40 Version* version) {
41 using base::win::RegKey;
erikwright (departed) 2012/09/13 01:13:44 This is only used once, right? So 'using' is overk
huangs 2012/09/13 04:40:47 Done.
42 HKEY root_key = system_level ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
43 string16 client_key(kGoogleRegClientsKey);
44 client_key.append(app_guid);
45 LOG(INFO) << "Trying to get " << client_key;
erikwright (departed) 2012/09/13 01:13:44 remove log statement.
huangs 2012/09/13 04:40:47 Done.
46 RegKey reg_key;
47 string16 version_str;
48 if ((reg_key.Open(root_key, client_key.c_str(), KEY_QUERY_VALUE)
49 != ERROR_SUCCESS) ||
erikwright (departed) 2012/09/13 01:13:44 != should go on previous line (prefer wrap after o
huangs 2012/09/13 04:40:47 Done.
50 (reg_key.ReadValue(kRegVersionField, &version_str) != ERROR_SUCCESS)) {
51 return false;
52 }
53 *version = Version(WideToASCII(version_str));
54 return version->IsValid();
55 }
56
57 // TODO(huangs): Refactor parameter |system_level|.
erikwright (departed) 2012/09/13 01:13:44 remove TODO
huangs 2012/09/13 04:40:47 Done.
58 bool UpgradeAppHost(bool system_level) {
59 using namespace chrome_launcher_support;
60 // Get the path to the setup.exe.
61 FilePath setup_exe(GetSetupExeForInstallationLevel(
62 system_level ? SYSTEM_LEVEL_INSTALLATION : USER_LEVEL_INSTALLATION));
63 if (setup_exe.empty()) {
64 LOG(INFO) << "Failed to find setup.exe";
65 return false;
66 }
67 CommandLine cmd_line(setup_exe);
68 cmd_line.AppendSwitch(kMultiInstall);
69 cmd_line.AppendSwitch(kChromeAppHost);
70 if (CommandLine::ForCurrentProcess()->HasSwitch(
erikwright (departed) 2012/09/13 01:13:44 Don't check the command-line for the current proce
huangs 2012/09/13 04:40:47 Done.
71 kVerboseLogging)) {
72 cmd_line.AppendSwitch(kVerboseLogging);
73 }
74 LOG(INFO) << "Command line: " << cmd_line.GetCommandLineString();
erikwright (departed) 2012/09/13 01:13:44 "Upgrading app_host.exe using command-line: ..."
huangs 2012/09/13 04:40:47 Done.
75 return base::LaunchProcess(cmd_line, base::LaunchOptions(), NULL);
76 }
77
78 } // namespace app_host
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698