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

Side by Side Diff: components/user_prefs/tracked/registry_hash_store_contents_win.cc

Issue 2204943002: Integrate registry_hash_store_contents with the rest of tracked prefs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove a lost include statement Created 4 years, 4 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
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 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 "components/user_prefs/tracked/registry_hash_store_contents_win.h" 5 #include "components/user_prefs/tracked/registry_hash_store_contents_win.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/numerics/safe_conversions.h" 10 #include "base/numerics/safe_conversions.h"
11 #include "base/strings/string_split.h" 11 #include "base/strings/string_split.h"
12 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "base/values.h" 14 #include "base/values.h"
15 #include "base/win/registry.h" 15 #include "base/win/registry.h"
16 #include "components/user_prefs/tracked/tracked_preference_histogram_names.h"
16 17
17 using base::win::RegistryValueIterator; 18 using base::win::RegistryValueIterator;
18 19
19 namespace { 20 namespace {
20 21
21 constexpr size_t kMacSize = 32; 22 constexpr size_t kMacSize = 64;
22 23
23 base::string16 GetSplitPrefKeyName(const base::string16& reg_key_name, 24 base::string16 GetSplitPrefKeyName(const base::string16& reg_key_name,
24 const std::string& split_key_name) { 25 const std::string& split_key_name) {
25 return reg_key_name + L"\\" + base::UTF8ToUTF16(split_key_name); 26 return reg_key_name + L"\\" + base::UTF8ToUTF16(split_key_name);
26 } 27 }
27 28
28 bool ReadMacFromRegistry(const base::win::RegKey& key, 29 bool ReadMacFromRegistry(const base::win::RegKey& key,
29 const std::string& value_name, 30 const std::string& value_name,
30 std::string* out_mac) { 31 std::string* out_mac) {
31 base::string16 string_value; 32 base::string16 string_value;
(...skipping 29 matching lines...) Expand all
61 KEY_SET_VALUE | KEY_WOW64_32KEY) == ERROR_SUCCESS) { 62 KEY_SET_VALUE | KEY_WOW64_32KEY) == ERROR_SUCCESS) {
62 return key.DeleteKey(L"") == ERROR_SUCCESS; 63 return key.DeleteKey(L"") == ERROR_SUCCESS;
63 } 64 }
64 return false; 65 return false;
65 } 66 }
66 67
67 } // namespace 68 } // namespace
68 69
69 RegistryHashStoreContentsWin::RegistryHashStoreContentsWin( 70 RegistryHashStoreContentsWin::RegistryHashStoreContentsWin(
70 const base::string16& registry_path, 71 const base::string16& registry_path,
71 const base::string16& profile_name) 72 const base::string16& profile_name)
gab 2016/08/08 04:37:46 Another CL to fix this : as aforementioned "profil
proberge 2016/08/31 17:30:17 Acknowledged.
72 : preference_key_name_(registry_path + L"\\PreferenceMACs\\" + 73 : preference_key_name_(registry_path + L"\\PreferenceMACs\\" +
73 profile_name) {} 74 profile_name) {}
74 75
76 RegistryHashStoreContentsWin::RegistryHashStoreContentsWin(
77 const base::string16& preference_key_name)
78 : preference_key_name_(preference_key_name) {}
79
80 std::unique_ptr<HashStoreContents> RegistryHashStoreContentsWin::MakeCopy()
81 const {
82 return std::unique_ptr<HashStoreContents>(
83 new RegistryHashStoreContentsWin(preference_key_name_));
84 }
85
86 std::string RegistryHashStoreContentsWin::GetUMASuffix() const {
87 return user_prefs::tracked::kTrackedPrefRegistryValidationSuffix;
88 }
89
75 void RegistryHashStoreContentsWin::Reset() { 90 void RegistryHashStoreContentsWin::Reset() {
76 base::win::RegKey key; 91 base::win::RegKey key;
77 if (key.Open(HKEY_CURRENT_USER, preference_key_name_.c_str(), 92 if (key.Open(HKEY_CURRENT_USER, preference_key_name_.c_str(),
78 KEY_SET_VALUE | KEY_WOW64_32KEY) == ERROR_SUCCESS) { 93 KEY_SET_VALUE | KEY_WOW64_32KEY) == ERROR_SUCCESS) {
79 LONG result = key.DeleteKey(L""); 94 LONG result = key.DeleteKey(L"");
80 DCHECK(result == ERROR_SUCCESS || result == ERROR_FILE_NOT_FOUND) << result; 95 DCHECK(result == ERROR_SUCCESS || result == ERROR_FILE_NOT_FOUND) << result;
81 } 96 }
82 } 97 }
83 98
84 bool RegistryHashStoreContentsWin::GetMac(const std::string& path, 99 bool RegistryHashStoreContentsWin::GetMac(const std::string& path,
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 145
131 if (key.Create(HKEY_CURRENT_USER, 146 if (key.Create(HKEY_CURRENT_USER,
132 GetSplitPrefKeyName(preference_key_name_, path).c_str(), 147 GetSplitPrefKeyName(preference_key_name_, path).c_str(),
133 KEY_SET_VALUE | KEY_WOW64_32KEY) == ERROR_SUCCESS) { 148 KEY_SET_VALUE | KEY_WOW64_32KEY) == ERROR_SUCCESS) {
134 key.WriteValue(base::UTF8ToUTF16(split_path).c_str(), 149 key.WriteValue(base::UTF8ToUTF16(split_path).c_str(),
135 base::UTF8ToUTF16(value).c_str()); 150 base::UTF8ToUTF16(value).c_str());
136 } 151 }
137 } 152 }
138 153
139 bool RegistryHashStoreContentsWin::RemoveEntry(const std::string& path) { 154 bool RegistryHashStoreContentsWin::RemoveEntry(const std::string& path) {
140 // ClearSplitMac is first to avoid short-circuit issues.
141 return ClearAtomicMac(preference_key_name_, path) || 155 return ClearAtomicMac(preference_key_name_, path) ||
142 ClearSplitMac(preference_key_name_, path); 156 ClearSplitMac(preference_key_name_, path);
143 } 157 }
144 158
145 void RegistryHashStoreContentsWin::ImportEntry(const std::string& path, 159 void RegistryHashStoreContentsWin::ImportEntry(const std::string& path,
146 const base::Value* in_value) { 160 const base::Value* in_value) {
147 NOTREACHED() 161 NOTREACHED()
148 << "RegistryHashStore does not support the ImportEntry operation"; 162 << "RegistryHashStoreContents does not support the ImportEntry operation";
149 } 163 }
150 164
151 const base::DictionaryValue* RegistryHashStoreContentsWin::GetContents() const { 165 const base::DictionaryValue* RegistryHashStoreContentsWin::GetContents() const {
152 NOTREACHED() 166 NOTREACHED()
153 << "RegistryHashStore does not support the GetContents operation"; 167 << "RegistryHashStoreContents does not support the GetContents operation";
154 return NULL; 168 return NULL;
155 } 169 }
156 170
157 std::string RegistryHashStoreContentsWin::GetSuperMac() const { 171 std::string RegistryHashStoreContentsWin::GetSuperMac() const {
158 NOTREACHED() 172 NOTREACHED()
159 << "RegistryHashStore does not support the GetSuperMac operation"; 173 << "RegistryHashStoreContents does not support the GetSuperMac operation";
160 return NULL; 174 return NULL;
161 } 175 }
162 176
163 void RegistryHashStoreContentsWin::SetSuperMac(const std::string& super_mac) { 177 void RegistryHashStoreContentsWin::SetSuperMac(const std::string& super_mac) {
164 NOTREACHED() 178 NOTREACHED()
165 << "RegistryHashStore does not support the SetSuperMac operation"; 179 << "RegistryHashStoreContents does not support the SetSuperMac operation";
166 } 180 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698