OLD | NEW |
---|---|
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 "services/preferences/tracked/registry_hash_store_contents_win.h" | 5 #include "services/preferences/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/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
11 #include "base/numerics/safe_conversions.h" | 11 #include "base/numerics/safe_conversions.h" |
12 #include "base/strings/string_split.h" | 12 #include "base/strings/string_split.h" |
13 #include "base/strings/string_util.h" | |
13 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
14 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
15 #include "base/values.h" | 16 #include "base/values.h" |
16 #include "base/win/registry.h" | 17 #include "base/win/registry.h" |
17 #include "services/preferences/public/cpp/tracked/tracked_preference_histogram_n ames.h" | 18 #include "services/preferences/public/cpp/tracked/tracked_preference_histogram_n ames.h" |
18 | 19 |
19 using base::win::RegistryValueIterator; | 20 using base::win::RegistryValueIterator; |
20 | 21 |
21 namespace { | 22 namespace { |
22 | 23 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
64 return key.DeleteKey(L"") == ERROR_SUCCESS; | 65 return key.DeleteKey(L"") == ERROR_SUCCESS; |
65 } | 66 } |
66 return false; | 67 return false; |
67 } | 68 } |
68 | 69 |
69 } // namespace | 70 } // namespace |
70 | 71 |
71 RegistryHashStoreContentsWin::RegistryHashStoreContentsWin( | 72 RegistryHashStoreContentsWin::RegistryHashStoreContentsWin( |
72 const base::string16& registry_path, | 73 const base::string16& registry_path, |
73 const base::string16& store_key) | 74 const base::string16& store_key) |
74 : preference_key_name_(registry_path + L"\\PreferenceMACs\\" + store_key) {} | 75 : preference_key_name_(registry_path + L"\\PreferenceMACs\\" + store_key), |
76 reset_on_delete_(base::StartsWith(store_key, | |
jam
2017/05/17 19:06:16
I'm curious, it seems this cleanup code is quite f
gab
2017/05/17 20:01:05
I debated this too... basically the problem is a t
grt (UTC plus 2)
2017/05/18 08:21:58
My suggestion on the bug was to create a ScopedPro
| |
77 L"scoped_dir", | |
78 base::CompareCase::INSENSITIVE_ASCII)) { | |
79 } | |
80 | |
81 RegistryHashStoreContentsWin::~RegistryHashStoreContentsWin() { | |
82 if (reset_on_delete_) | |
83 Reset(); | |
84 } | |
75 | 85 |
76 RegistryHashStoreContentsWin::RegistryHashStoreContentsWin( | 86 RegistryHashStoreContentsWin::RegistryHashStoreContentsWin( |
77 const RegistryHashStoreContentsWin& other) = default; | 87 const RegistryHashStoreContentsWin& other) = default; |
78 | 88 |
79 bool RegistryHashStoreContentsWin::IsCopyable() const { | 89 bool RegistryHashStoreContentsWin::IsCopyable() const { |
80 return true; | 90 return true; |
81 } | 91 } |
82 | 92 |
83 std::unique_ptr<HashStoreContents> RegistryHashStoreContentsWin::MakeCopy() | 93 std::unique_ptr<HashStoreContents> RegistryHashStoreContentsWin::MakeCopy() |
84 const { | 94 const { |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
173 std::string RegistryHashStoreContentsWin::GetSuperMac() const { | 183 std::string RegistryHashStoreContentsWin::GetSuperMac() const { |
174 NOTREACHED() | 184 NOTREACHED() |
175 << "RegistryHashStoreContents does not support the GetSuperMac operation"; | 185 << "RegistryHashStoreContents does not support the GetSuperMac operation"; |
176 return NULL; | 186 return NULL; |
177 } | 187 } |
178 | 188 |
179 void RegistryHashStoreContentsWin::SetSuperMac(const std::string& super_mac) { | 189 void RegistryHashStoreContentsWin::SetSuperMac(const std::string& super_mac) { |
180 NOTREACHED() | 190 NOTREACHED() |
181 << "RegistryHashStoreContents does not support the SetSuperMac operation"; | 191 << "RegistryHashStoreContents does not support the SetSuperMac operation"; |
182 } | 192 } |
OLD | NEW |