| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/metrics/field_trial.h" | 6 #include "base/metrics/field_trial.h" |
| 7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
| 8 #include "base/metrics/sparse_histogram.h" | 8 #include "base/metrics/sparse_histogram.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "base/win/registry.h" | 10 #include "base/win/registry.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 } | 106 } |
| 107 | 107 |
| 108 void AddFinchBlacklistToRegistry() { | 108 void AddFinchBlacklistToRegistry() { |
| 109 base::win::RegKey finch_blacklist_registry_key( | 109 base::win::RegKey finch_blacklist_registry_key( |
| 110 HKEY_CURRENT_USER, blacklist::kRegistryFinchListPath, KEY_SET_VALUE); | 110 HKEY_CURRENT_USER, blacklist::kRegistryFinchListPath, KEY_SET_VALUE); |
| 111 | 111 |
| 112 // No point in trying to continue if the registry key isn't valid. | 112 // No point in trying to continue if the registry key isn't valid. |
| 113 if (!finch_blacklist_registry_key.Valid()) | 113 if (!finch_blacklist_registry_key.Valid()) |
| 114 return; | 114 return; |
| 115 | 115 |
| 116 // Delete and recreate the key to clear the registry. |
| 117 finch_blacklist_registry_key.DeleteKey(L""); |
| 118 finch_blacklist_registry_key.Create( |
| 119 HKEY_CURRENT_USER, blacklist::kRegistryFinchListPath, KEY_SET_VALUE); |
| 120 |
| 116 std::map<std::string, std::string> params; | 121 std::map<std::string, std::string> params; |
| 117 chrome_variations::GetVariationParams(kBrowserBlacklistTrialName, ¶ms); | 122 chrome_variations::GetVariationParams(kBrowserBlacklistTrialName, ¶ms); |
| 118 | 123 |
| 119 for (std::map<std::string, std::string>::iterator it = params.begin(); | 124 for (std::map<std::string, std::string>::iterator it = params.begin(); |
| 120 it != params.end(); | 125 it != params.end(); |
| 121 ++it) { | 126 ++it) { |
| 122 std::wstring name = base::UTF8ToWide(it->first); | 127 std::wstring name = base::UTF8ToWide(it->first); |
| 123 std::wstring val = base::UTF8ToWide(it->second); | 128 std::wstring val = base::UTF8ToWide(it->second); |
| 124 | 129 |
| 125 finch_blacklist_registry_key.WriteValue(name.c_str(), val.c_str()); | 130 finch_blacklist_registry_key.WriteValue(name.c_str(), val.c_str()); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 LONG set_state = blacklist_registry_key.WriteValue( | 181 LONG set_state = blacklist_registry_key.WriteValue( |
| 177 blacklist::kBeaconState, | 182 blacklist::kBeaconState, |
| 178 blacklist::BLACKLIST_ENABLED); | 183 blacklist::BLACKLIST_ENABLED); |
| 179 | 184 |
| 180 // Only report the blacklist as getting setup when both registry writes | 185 // Only report the blacklist as getting setup when both registry writes |
| 181 // succeed, since otherwise the blacklist wasn't properly setup. | 186 // succeed, since otherwise the blacklist wasn't properly setup. |
| 182 if (set_version == ERROR_SUCCESS && set_state == ERROR_SUCCESS) | 187 if (set_version == ERROR_SUCCESS && set_state == ERROR_SUCCESS) |
| 183 RecordBlacklistSetupEvent(BLACKLIST_SETUP_ENABLED); | 188 RecordBlacklistSetupEvent(BLACKLIST_SETUP_ENABLED); |
| 184 } | 189 } |
| 185 } | 190 } |
| OLD | NEW |