OLD | NEW |
---|---|
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 22 matching lines...) Expand all Loading... | |
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 = KEY_ENUMERATE_SUB_KEYS | KEY_QUERY_VALUE; |
40 base::win::RegKey commands_key; | 40 base::win::RegKey commands_key; |
41 | 41 |
42 if (commands_key.Open(version_key.Handle(), google_update::kRegCommandsKey, | 42 if (commands_key.Open(version_key.Handle(), google_update::kRegCommandsKey, |
43 kAccess) == ERROR_SUCCESS) | 43 kAccess | KEY_WOW64_32KEY) == ERROR_SUCCESS) |
grt (UTC plus 2)
2014/05/27 16:42:08
move to definition of kAccess
Will Harris
2014/05/27 19:25:10
Done.
| |
44 return commands->Initialize(commands_key); | 44 return commands->Initialize(commands_key); |
45 return false; | 45 return false; |
46 } | 46 } |
47 | 47 |
48 bool ProductState::Initialize(bool system_install, | 48 bool ProductState::Initialize(bool system_install, |
49 BrowserDistribution* distribution) { | 49 BrowserDistribution* distribution) { |
50 const std::wstring version_key(distribution->GetVersionKey()); | 50 const std::wstring version_key(distribution->GetVersionKey()); |
51 const std::wstring state_key(distribution->GetStateKey()); | 51 const std::wstring state_key(distribution->GetStateKey()); |
52 const HKEY root_key = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | 52 const HKEY root_key = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
53 base::win::RegKey key; | 53 base::win::RegKey key; |
54 | 54 |
55 // Clear the runway. | 55 // Clear the runway. |
56 Clear(); | 56 Clear(); |
57 | 57 |
58 // Read from the Clients key. | 58 // Read from the Clients key. |
59 if (key.Open(root_key, version_key.c_str(), | 59 if (key.Open(root_key, version_key.c_str(), |
60 KEY_QUERY_VALUE) == ERROR_SUCCESS) { | 60 KEY_QUERY_VALUE | KEY_WOW64_32KEY) == ERROR_SUCCESS) { |
grt (UTC plus 2)
2014/05/27 16:42:08
define a local kAccess const with these two bits a
Will Harris
2014/05/27 19:25:10
Done.
| |
61 base::string16 version_str; | 61 base::string16 version_str; |
62 if (key.ReadValue(google_update::kRegVersionField, | 62 if (key.ReadValue(google_update::kRegVersionField, |
63 &version_str) == ERROR_SUCCESS) { | 63 &version_str) == ERROR_SUCCESS) { |
64 version_.reset(new Version(base::UTF16ToASCII(version_str))); | 64 version_.reset(new Version(base::UTF16ToASCII(version_str))); |
65 if (!version_->IsValid()) | 65 if (!version_->IsValid()) |
66 version_.reset(); | 66 version_.reset(); |
67 } | 67 } |
68 | 68 |
69 // Attempt to read the other values even if the "pv" version value was | 69 // Attempt to read the other values even if the "pv" version value was |
70 // absent. Note that ProductState instances containing these values will | 70 // absent. Note that ProductState instances containing these values will |
71 // only be accessible via InstallationState::GetNonVersionedProductState. | 71 // only be accessible via InstallationState::GetNonVersionedProductState. |
72 if (key.ReadValue(google_update::kRegOldVersionField, | 72 if (key.ReadValue(google_update::kRegOldVersionField, |
73 &version_str) == ERROR_SUCCESS) { | 73 &version_str) == ERROR_SUCCESS) { |
74 old_version_.reset(new Version(base::UTF16ToASCII(version_str))); | 74 old_version_.reset(new Version(base::UTF16ToASCII(version_str))); |
75 if (!old_version_->IsValid()) | 75 if (!old_version_->IsValid()) |
76 old_version_.reset(); | 76 old_version_.reset(); |
77 } | 77 } |
78 | 78 |
79 key.ReadValue(google_update::kRegRenameCmdField, &rename_cmd_); | 79 key.ReadValue(google_update::kRegRenameCmdField, &rename_cmd_); |
80 if (!InitializeCommands(key, &commands_)) | 80 if (!InitializeCommands(key, &commands_)) |
81 commands_.Clear(); | 81 commands_.Clear(); |
82 } | 82 } |
83 | 83 |
84 // Read from the ClientState key. | 84 // Read from the ClientState key. |
85 if (key.Open(root_key, state_key.c_str(), | 85 if (key.Open(root_key, state_key.c_str(), |
86 KEY_QUERY_VALUE) == ERROR_SUCCESS) { | 86 KEY_QUERY_VALUE | KEY_WOW64_32KEY) == 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 21 matching lines...) Expand all Loading... | |
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(), |
128 KEY_QUERY_VALUE) == ERROR_SUCCESS) { | 128 KEY_QUERY_VALUE | KEY_WOW64_32KEY) == 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 Loading... | |
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 |
OLD | NEW |