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 "chrome/browser/win/chrome_elf_init.h" | 5 #include "chrome/browser/win/chrome_elf_init.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 // No point in trying to continue if the registry key isn't valid. | 123 // No point in trying to continue if the registry key isn't valid. |
124 if (!finch_blacklist_registry_key.Valid()) | 124 if (!finch_blacklist_registry_key.Valid()) |
125 return; | 125 return; |
126 | 126 |
127 // Delete and recreate the key to clear the registry. | 127 // Delete and recreate the key to clear the registry. |
128 finch_blacklist_registry_key.DeleteKey(L""); | 128 finch_blacklist_registry_key.DeleteKey(L""); |
129 finch_blacklist_registry_key.Create( | 129 finch_blacklist_registry_key.Create( |
130 HKEY_CURRENT_USER, blacklist::kRegistryFinchListPath, KEY_SET_VALUE); | 130 HKEY_CURRENT_USER, blacklist::kRegistryFinchListPath, KEY_SET_VALUE); |
131 | 131 |
132 std::map<std::string, std::string> params; | 132 std::map<std::string, std::string> params; |
133 variations::GetVariationParams(kBrowserBlacklistTrialName, ¶ms); | 133 std::string value = variations::GetVariationParamValue( |
| 134 kBrowserBlacklistTrialName, blacklist::kRegistryFinchListValueNameStr); |
| 135 if (value.empty()) |
| 136 return; |
| 137 base::string16 value_wcs = base::UTF8ToWide(value); |
134 | 138 |
135 for (std::map<std::string, std::string>::iterator it = params.begin(); | 139 // The dll names are comma-separated in this param value. We need to turn |
136 it != params.end(); | 140 // this into REG_MULTI_SZ format (double-null terminates). |
137 ++it) { | 141 // Note that the strings are wide character in registry. |
138 std::wstring name = base::UTF8ToWide(it->first); | 142 value_wcs.push_back(L'\0'); |
139 std::wstring val = base::UTF8ToWide(it->second); | 143 value_wcs.push_back(L'\0'); |
| 144 std::replace(value_wcs.begin(), value_wcs.end(), L',', L'\0'); |
140 | 145 |
141 finch_blacklist_registry_key.WriteValue(name.c_str(), val.c_str()); | 146 finch_blacklist_registry_key.WriteValue( |
142 } | 147 blacklist::kRegistryFinchListValueName, value_wcs.data(), |
| 148 (value_wcs.size() * sizeof(wchar_t)), REG_MULTI_SZ); |
143 } | 149 } |
144 | 150 |
145 void BrowserBlacklistBeaconSetup() { | 151 void BrowserBlacklistBeaconSetup() { |
146 base::win::RegKey blacklist_registry_key(HKEY_CURRENT_USER, | 152 base::win::RegKey blacklist_registry_key(HKEY_CURRENT_USER, |
147 blacklist::kRegistryBeaconPath, | 153 blacklist::kRegistryBeaconPath, |
148 KEY_QUERY_VALUE | KEY_SET_VALUE); | 154 KEY_QUERY_VALUE | KEY_SET_VALUE); |
149 | 155 |
150 // No point in trying to continue if the registry key isn't valid. | 156 // No point in trying to continue if the registry key isn't valid. |
151 if (!blacklist_registry_key.Valid()) | 157 if (!blacklist_registry_key.Valid()) |
152 return; | 158 return; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 | 206 |
201 blacklist_registry_key.WriteValue(blacklist::kBeaconAttemptCount, | 207 blacklist_registry_key.WriteValue(blacklist::kBeaconAttemptCount, |
202 static_cast<DWORD>(0)); | 208 static_cast<DWORD>(0)); |
203 | 209 |
204 // Only report the blacklist as getting setup when both registry writes | 210 // Only report the blacklist as getting setup when both registry writes |
205 // succeed, since otherwise the blacklist wasn't properly setup. | 211 // succeed, since otherwise the blacklist wasn't properly setup. |
206 if (set_version == ERROR_SUCCESS && set_state == ERROR_SUCCESS) | 212 if (set_version == ERROR_SUCCESS && set_state == ERROR_SUCCESS) |
207 RecordBlacklistSetupEvent(BLACKLIST_SETUP_ENABLED); | 213 RecordBlacklistSetupEvent(BLACKLIST_SETUP_ENABLED); |
208 } | 214 } |
209 } | 215 } |
OLD | NEW |