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

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

Issue 6588003: Add support for the quick-enable-cf command to the installer. This encompase... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/installation_state.h" 5 #include "chrome/installer/util/installation_state.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/version.h" 9 #include "base/version.h"
10 #include "base/win/registry.h" 10 #include "base/win/registry.h"
11 #include "chrome/installer/util/google_update_constants.h" 11 #include "chrome/installer/util/google_update_constants.h"
12 #include "chrome/installer/util/install_util.h" 12 #include "chrome/installer/util/install_util.h"
13 13
14 namespace installer { 14 namespace installer {
15 15
16 ProductState::ProductState() 16 ProductState::ProductState()
17 : uninstall_command_(CommandLine::NO_PROGRAM), 17 : uninstall_command_(CommandLine::NO_PROGRAM),
18 msi_(false), 18 msi_(false),
19 multi_install_(false) { 19 multi_install_(false) {
20 } 20 }
21 21
22 bool ProductState::Initialize(bool system_install, 22 bool ProductState::Initialize(bool system_install,
23 BrowserDistribution::Type type) { 23 BrowserDistribution::Type type) {
24 return Initialize(system_install, 24 return Initialize(system_install,
25 BrowserDistribution::GetSpecificDistribution(type)); 25 BrowserDistribution::GetSpecificDistribution(type));
26 } 26 }
27 27
28 // Initializes |commands| from the "Commands" subkey of |version_key|.
29 // Returns false if there is no "Commands" subkey or on error.
30 // static
31 bool ProductState::InitializeCommands(const base::win::RegKey& version_key,
32 AppCommands* commands) {
33 static const DWORD kAccess = KEY_ENUMERATE_SUB_KEYS | KEY_QUERY_VALUE;
34 base::win::RegKey commands_key;
35
36 if (commands_key.Open(version_key.Handle(), google_update::kRegCommandsKey,
37 kAccess) == ERROR_SUCCESS)
38 return commands->Initialize(commands_key);
39 return false;
40 }
41
28 bool ProductState::Initialize(bool system_install, 42 bool ProductState::Initialize(bool system_install,
29 BrowserDistribution* distribution) { 43 BrowserDistribution* distribution) {
30 const std::wstring version_key(distribution->GetVersionKey()); 44 const std::wstring version_key(distribution->GetVersionKey());
31 const std::wstring state_key(distribution->GetStateKey()); 45 const std::wstring state_key(distribution->GetStateKey());
32 const HKEY root_key = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; 46 const HKEY root_key = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
33 base::win::RegKey key(root_key, version_key.c_str(), KEY_QUERY_VALUE); 47 base::win::RegKey key(root_key, version_key.c_str(), KEY_QUERY_VALUE);
34 std::wstring version_str; 48 std::wstring version_str;
35 if (key.ReadValue(google_update::kRegVersionField, 49 if (key.ReadValue(google_update::kRegVersionField,
36 &version_str) == ERROR_SUCCESS) { 50 &version_str) == ERROR_SUCCESS) {
37 version_.reset(Version::GetVersionFromString(WideToASCII(version_str))); 51 version_.reset(Version::GetVersionFromString(WideToASCII(version_str)));
38 if (version_.get() != NULL) { 52 if (version_.get() != NULL) {
39 // The product is installed. 53 // The product is installed.
40 if (key.ReadValue(google_update::kRegOldVersionField, 54 if (key.ReadValue(google_update::kRegOldVersionField,
41 &version_str) == ERROR_SUCCESS) { 55 &version_str) == ERROR_SUCCESS) {
42 old_version_.reset( 56 old_version_.reset(
43 Version::GetVersionFromString(WideToASCII(version_str))); 57 Version::GetVersionFromString(WideToASCII(version_str)));
44 } else { 58 } else {
45 old_version_.reset(); 59 old_version_.reset();
46 } 60 }
47 if (key.ReadValue(google_update::kRegRenameCmdField, 61 if (key.ReadValue(google_update::kRegRenameCmdField,
48 &rename_cmd_) != ERROR_SUCCESS) 62 &rename_cmd_) != ERROR_SUCCESS)
49 rename_cmd_.clear(); 63 rename_cmd_.clear();
64 if (!InitializeCommands(key, &commands_))
65 commands_.Clear();
50 // Read from the ClientState key. 66 // Read from the ClientState key.
51 channel_.set_value(std::wstring()); 67 channel_.set_value(std::wstring());
52 uninstall_command_ = CommandLine(CommandLine::NO_PROGRAM); 68 uninstall_command_ = CommandLine(CommandLine::NO_PROGRAM);
53 msi_ = false; 69 msi_ = false;
54 multi_install_ = false; 70 multi_install_ = false;
55 if (key.Open(root_key, state_key.c_str(), 71 if (key.Open(root_key, state_key.c_str(),
56 KEY_QUERY_VALUE) == ERROR_SUCCESS) { 72 KEY_QUERY_VALUE) == ERROR_SUCCESS) {
57 std::wstring setup_path; 73 std::wstring setup_path;
58 std::wstring uninstall_arguments; 74 std::wstring uninstall_arguments;
59 // "ap" will be absent if not managed by Google Update. 75 // "ap" will be absent if not managed by Google Update.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 return *version_; 108 return *version_;
93 } 109 }
94 110
95 ProductState& ProductState::CopyFrom(const ProductState& other) { 111 ProductState& ProductState::CopyFrom(const ProductState& other) {
96 channel_.set_value(other.channel_.value()); 112 channel_.set_value(other.channel_.value());
97 version_.reset(other.version_.get() == NULL ? NULL : other.version_->Clone()); 113 version_.reset(other.version_.get() == NULL ? NULL : other.version_->Clone());
98 old_version_.reset( 114 old_version_.reset(
99 other.old_version_.get() == NULL ? NULL : other.old_version_->Clone()); 115 other.old_version_.get() == NULL ? NULL : other.old_version_->Clone());
100 rename_cmd_ = other.rename_cmd_; 116 rename_cmd_ = other.rename_cmd_;
101 uninstall_command_ = other.uninstall_command_; 117 uninstall_command_ = other.uninstall_command_;
118 commands_.CopyFrom(other.commands_);
102 msi_ = other.msi_; 119 msi_ = other.msi_;
103 multi_install_ = other.multi_install_; 120 multi_install_ = other.multi_install_;
104 121
105 return *this; 122 return *this;
106 } 123 }
107 124
108 InstallationState::InstallationState() { 125 InstallationState::InstallationState() {
109 } 126 }
110 127
111 // static 128 // static
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 160
144 const ProductState* InstallationState::GetProductState( 161 const ProductState* InstallationState::GetProductState(
145 bool system_install, 162 bool system_install,
146 BrowserDistribution::Type type) const { 163 BrowserDistribution::Type type) const {
147 const ProductState& product_state = (system_install ? system_products_ : 164 const ProductState& product_state = (system_install ? system_products_ :
148 user_products_)[IndexFromDistType(type)]; 165 user_products_)[IndexFromDistType(type)];
149 return product_state.version_.get() == NULL ? NULL : &product_state; 166 return product_state.version_.get() == NULL ? NULL : &product_state;
150 } 167 }
151 168
152 } // namespace installer 169 } // namespace installer
OLDNEW
« no previous file with comments | « chrome/installer/util/installation_state.h ('k') | chrome/installer/util/installation_validator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698