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

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

Issue 300593002: Make omaha, gcapi and uninstall registry accesses use Wow6432Node on 64-bit (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 6 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
« no previous file with comments | « chrome/installer/util/install_util.cc ('k') | chrome/installer/util/installer_state.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/version.h" 10 #include "base/version.h"
(...skipping 18 matching lines...) Expand all
29 BrowserDistribution::Type type) { 29 BrowserDistribution::Type type) {
30 return Initialize(system_install, 30 return Initialize(system_install,
31 BrowserDistribution::GetSpecificDistribution(type)); 31 BrowserDistribution::GetSpecificDistribution(type));
32 } 32 }
33 33
34 // Initializes |commands| from the "Commands" subkey of |version_key|. 34 // Initializes |commands| from the "Commands" subkey of |version_key|.
35 // Returns false if there is no "Commands" subkey or on error. 35 // Returns false if there is no "Commands" subkey or on error.
36 // static 36 // static
37 bool ProductState::InitializeCommands(const base::win::RegKey& version_key, 37 bool ProductState::InitializeCommands(const base::win::RegKey& version_key,
38 AppCommands* commands) { 38 AppCommands* commands) {
39 static const DWORD kAccess = KEY_ENUMERATE_SUB_KEYS | KEY_QUERY_VALUE; 39 static const DWORD kAccess =
40 KEY_ENUMERATE_SUB_KEYS | KEY_QUERY_VALUE | KEY_WOW64_32KEY;
40 base::win::RegKey commands_key; 41 base::win::RegKey commands_key;
41 42
42 if (commands_key.Open(version_key.Handle(), google_update::kRegCommandsKey, 43 if (commands_key.Open(version_key.Handle(), google_update::kRegCommandsKey,
43 kAccess) == ERROR_SUCCESS) 44 kAccess) == ERROR_SUCCESS)
44 return commands->Initialize(commands_key); 45 return commands->Initialize(commands_key);
45 return false; 46 return false;
46 } 47 }
47 48
48 bool ProductState::Initialize(bool system_install, 49 bool ProductState::Initialize(bool system_install,
49 BrowserDistribution* distribution) { 50 BrowserDistribution* distribution) {
51 static const DWORD kAccess = KEY_QUERY_VALUE | KEY_WOW64_32KEY;
50 const std::wstring version_key(distribution->GetVersionKey()); 52 const std::wstring version_key(distribution->GetVersionKey());
51 const std::wstring state_key(distribution->GetStateKey()); 53 const std::wstring state_key(distribution->GetStateKey());
52 const HKEY root_key = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; 54 const HKEY root_key = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
53 base::win::RegKey key; 55 base::win::RegKey key;
54 56
55 // Clear the runway. 57 // Clear the runway.
56 Clear(); 58 Clear();
57 59
58 // Read from the Clients key. 60 // Read from the Clients key.
59 if (key.Open(root_key, version_key.c_str(), 61 if (key.Open(root_key, version_key.c_str(), kAccess) == ERROR_SUCCESS) {
60 KEY_QUERY_VALUE) == ERROR_SUCCESS) {
61 base::string16 version_str; 62 base::string16 version_str;
62 if (key.ReadValue(google_update::kRegVersionField, 63 if (key.ReadValue(google_update::kRegVersionField,
63 &version_str) == ERROR_SUCCESS) { 64 &version_str) == ERROR_SUCCESS) {
64 version_.reset(new Version(base::UTF16ToASCII(version_str))); 65 version_.reset(new Version(base::UTF16ToASCII(version_str)));
65 if (!version_->IsValid()) 66 if (!version_->IsValid())
66 version_.reset(); 67 version_.reset();
67 } 68 }
68 69
69 // Attempt to read the other values even if the "pv" version value was 70 // Attempt to read the other values even if the "pv" version value was
70 // absent. Note that ProductState instances containing these values will 71 // absent. Note that ProductState instances containing these values will
71 // only be accessible via InstallationState::GetNonVersionedProductState. 72 // only be accessible via InstallationState::GetNonVersionedProductState.
72 if (key.ReadValue(google_update::kRegOldVersionField, 73 if (key.ReadValue(google_update::kRegOldVersionField,
73 &version_str) == ERROR_SUCCESS) { 74 &version_str) == ERROR_SUCCESS) {
74 old_version_.reset(new Version(base::UTF16ToASCII(version_str))); 75 old_version_.reset(new Version(base::UTF16ToASCII(version_str)));
75 if (!old_version_->IsValid()) 76 if (!old_version_->IsValid())
76 old_version_.reset(); 77 old_version_.reset();
77 } 78 }
78 79
79 key.ReadValue(google_update::kRegRenameCmdField, &rename_cmd_); 80 key.ReadValue(google_update::kRegRenameCmdField, &rename_cmd_);
80 if (!InitializeCommands(key, &commands_)) 81 if (!InitializeCommands(key, &commands_))
81 commands_.Clear(); 82 commands_.Clear();
82 } 83 }
83 84
84 // Read from the ClientState key. 85 // Read from the ClientState key.
85 if (key.Open(root_key, state_key.c_str(), 86 if (key.Open(root_key, state_key.c_str(), kAccess) == ERROR_SUCCESS) {
86 KEY_QUERY_VALUE) == ERROR_SUCCESS) {
87 std::wstring setup_path; 87 std::wstring setup_path;
88 std::wstring uninstall_arguments; 88 std::wstring uninstall_arguments;
89 // "ap" will be absent if not managed by Google Update. 89 // "ap" will be absent if not managed by Google Update.
90 channel_.Initialize(key); 90 channel_.Initialize(key);
91 91
92 // Read in the brand code, it may be absent 92 // Read in the brand code, it may be absent
93 key.ReadValue(google_update::kRegBrandField, &brand_); 93 key.ReadValue(google_update::kRegBrandField, &brand_);
94 94
95 // "UninstallString" will be absent for the multi-installer package. 95 // "UninstallString" will be absent for the multi-installer package.
96 key.ReadValue(kUninstallStringField, &setup_path); 96 key.ReadValue(kUninstallStringField, &setup_path);
(...skipping 20 matching lines...) Expand all
117 // Multi-install is implied or is derived from the command-line. 117 // Multi-install is implied or is derived from the command-line.
118 if (distribution->GetType() == BrowserDistribution::CHROME_BINARIES) 118 if (distribution->GetType() == BrowserDistribution::CHROME_BINARIES)
119 multi_install_ = true; 119 multi_install_ = true;
120 else 120 else
121 multi_install_ = uninstall_command_.HasSwitch(switches::kMultiInstall); 121 multi_install_ = uninstall_command_.HasSwitch(switches::kMultiInstall);
122 } 122 }
123 123
124 // Read from the ClientStateMedium key. Values here override those in 124 // Read from the ClientStateMedium key. Values here override those in
125 // ClientState. 125 // ClientState.
126 if (system_install && 126 if (system_install &&
127 key.Open(root_key, distribution->GetStateMediumKey().c_str(), 127 key.Open(root_key, distribution->GetStateMediumKey().c_str(), kAccess) ==
128 KEY_QUERY_VALUE) == ERROR_SUCCESS) { 128 ERROR_SUCCESS) {
129 DWORD dword_value = 0; 129 DWORD dword_value = 0;
130 130
131 if (key.ReadValueDW(google_update::kRegUsageStatsField, 131 if (key.ReadValueDW(google_update::kRegUsageStatsField,
132 &dword_value) == ERROR_SUCCESS) { 132 &dword_value) == ERROR_SUCCESS) {
133 has_usagestats_ = true; 133 has_usagestats_ = true;
134 usagestats_ = dword_value; 134 usagestats_ = dword_value;
135 } 135 }
136 136
137 if (key.ReadValueDW(google_update::kRegEULAAceptedField, 137 if (key.ReadValueDW(google_update::kRegEULAAceptedField,
138 &dword_value) == ERROR_SUCCESS) { 138 &dword_value) == ERROR_SUCCESS) {
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 } 269 }
270 270
271 const ProductState* InstallationState::GetProductState( 271 const ProductState* InstallationState::GetProductState(
272 bool system_install, 272 bool system_install,
273 BrowserDistribution::Type type) const { 273 BrowserDistribution::Type type) const {
274 const ProductState* product_state = 274 const ProductState* product_state =
275 GetNonVersionedProductState(system_install, type); 275 GetNonVersionedProductState(system_install, type);
276 return product_state->version_.get() == NULL ? NULL : product_state; 276 return product_state->version_.get() == NULL ? NULL : product_state;
277 } 277 }
278 } // namespace installer 278 } // namespace installer
OLDNEW
« no previous file with comments | « chrome/installer/util/install_util.cc ('k') | chrome/installer/util/installer_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698