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/mini_installer/regkey.h" | 5 #include "chrome/installer/mini_installer/regkey.h" |
6 | 6 |
7 #include "chrome/installer/mini_installer/mini_installer_constants.h" | 7 #include "chrome/installer/mini_installer/mini_installer_constants.h" |
8 #include "chrome/installer/mini_installer/mini_string.h" | 8 #include "chrome/installer/mini_installer/mini_string.h" |
9 | 9 |
10 namespace mini_installer { | 10 namespace mini_installer { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 sizeof(value)); | 65 sizeof(value)); |
66 } | 66 } |
67 | 67 |
68 void RegKey::Close() { | 68 void RegKey::Close() { |
69 if (key_ != NULL) { | 69 if (key_ != NULL) { |
70 ::RegCloseKey(key_); | 70 ::RegCloseKey(key_); |
71 key_ = NULL; | 71 key_ = NULL; |
72 } | 72 } |
73 } | 73 } |
74 | 74 |
75 | |
76 // static | 75 // static |
77 bool RegKey::ReadSZValue(HKEY root_key, const wchar_t *sub_key, | 76 bool RegKey::ReadSZValue(HKEY root_key, const wchar_t *sub_key, |
78 const wchar_t *value_name, wchar_t *value, | 77 const wchar_t *value_name, wchar_t *value, |
79 size_t size) { | 78 size_t size) { |
80 RegKey key; | 79 RegKey key; |
81 return (key.Open(root_key, sub_key, KEY_QUERY_VALUE) == ERROR_SUCCESS && | 80 return (key.Open(root_key, sub_key, KEY_QUERY_VALUE) == ERROR_SUCCESS && |
82 key.ReadSZValue(value_name, value, size) == ERROR_SUCCESS); | 81 key.ReadSZValue(value_name, value, size) == ERROR_SUCCESS); |
83 } | 82 } |
84 | 83 |
85 // Opens the Google Update ClientState key for a product. This finds only | 84 // Opens the Google Update Clients key for a product. |
86 // registry entries for Chrome; it does not support the Chromium registry | 85 LONG OpenClientsKey(HKEY root_key, |
87 // layout. | 86 const wchar_t* app_guid, |
88 bool OpenClientStateKey(HKEY root_key, const wchar_t* app_guid, | 87 REGSAM access, |
89 REGSAM access, RegKey* key) { | 88 RegKey* key) { |
| 89 StackString<MAX_PATH> clients_key; |
| 90 if (!clients_key.assign(kClientsKeyBase)) |
| 91 return ERROR_BUFFER_OVERFLOW; |
| 92 #if defined(GOOGLE_CHROME_BUILD) |
| 93 if (!clients_key.append(app_guid)) |
| 94 return ERROR_BUFFER_OVERFLOW; |
| 95 #endif |
| 96 return key->Open(root_key, clients_key.get(), access | KEY_WOW64_32KEY); |
| 97 } |
| 98 |
| 99 // Opens the Google Update ClientState key for a product. |
| 100 LONG OpenClientStateKey(HKEY root_key, |
| 101 const wchar_t* app_guid, |
| 102 REGSAM access, |
| 103 RegKey* key) { |
90 StackString<MAX_PATH> client_state_key; | 104 StackString<MAX_PATH> client_state_key; |
91 return client_state_key.assign(kClientStateKeyBase) && | 105 if (!client_state_key.assign(kClientStateKeyBase)) |
92 client_state_key.append(app_guid) && | 106 return ERROR_BUFFER_OVERFLOW; |
93 (key->Open(root_key, | 107 #if defined(GOOGLE_CHROME_BUILD) |
94 client_state_key.get(), | 108 if (!client_state_key.append(app_guid)) |
95 access | KEY_WOW64_32KEY) == ERROR_SUCCESS); | 109 return ERROR_BUFFER_OVERFLOW; |
| 110 #endif |
| 111 return key->Open(root_key, client_state_key.get(), access | KEY_WOW64_32KEY); |
96 } | 112 } |
97 | 113 |
98 } // namespace mini_installer | 114 } // namespace mini_installer |
OLD | NEW |