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

Side by Side Diff: chrome/browser/chrome_elf_init_win.cc

Issue 1841573002: [Chrome ELF] New NT registry API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clean up OverrideRegistry function. Created 4 years, 8 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 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/metrics/field_trial.h" 8 #include "base/metrics/field_trial.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/metrics/sparse_histogram.h" 10 #include "base/metrics/sparse_histogram.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 // No point in trying to continue if the registry key isn't valid. 122 // No point in trying to continue if the registry key isn't valid.
123 if (!finch_blacklist_registry_key.Valid()) 123 if (!finch_blacklist_registry_key.Valid())
124 return; 124 return;
125 125
126 // Delete and recreate the key to clear the registry. 126 // Delete and recreate the key to clear the registry.
127 finch_blacklist_registry_key.DeleteKey(L""); 127 finch_blacklist_registry_key.DeleteKey(L"");
128 finch_blacklist_registry_key.Create( 128 finch_blacklist_registry_key.Create(
129 HKEY_CURRENT_USER, blacklist::kRegistryFinchListPath, KEY_SET_VALUE); 129 HKEY_CURRENT_USER, blacklist::kRegistryFinchListPath, KEY_SET_VALUE);
130 130
131 std::map<std::string, std::string> params; 131 std::map<std::string, std::string> params;
132 variations::GetVariationParams(kBrowserBlacklistTrialName, &params); 132 std::string value = variations::GetVariationParamValue(
133 kBrowserBlacklistTrialName, blacklist::kRegistryFinchListValueNameStr);
134 if (value.empty())
135 return;
136 std::wstring value_wcs = base::UTF8ToWide(value);
robertshield 2016/04/20 05:16:09 prefer base::string16
penny 2016/05/28 01:34:22 Done. This base API explicitly returns a std::wst
133 137
134 for (std::map<std::string, std::string>::iterator it = params.begin(); 138 // The dll names are comma-separated in this param value. We need to turn
135 it != params.end(); 139 // this into REG_MULTI_SZ format (double-null terminates).
136 ++it) { 140 // Note that the strings are wide character in registry.
137 std::wstring name = base::UTF8ToWide(it->first); 141 std::vector<wchar_t> reg_buffer(value_wcs.begin(), value_wcs.end());
robertshield 2016/04/20 05:16:09 I'm not sure you need to copy the dll names here.
penny 2016/05/28 01:34:22 Done. TIL! I didn't know you could embed null ch
138 std::wstring val = base::UTF8ToWide(it->second); 142 reg_buffer.push_back(L'\0');
143 reg_buffer.push_back(L'\0');
144 std::replace(reg_buffer.begin(), reg_buffer.end(), L',', L'\0');
139 145
140 finch_blacklist_registry_key.WriteValue(name.c_str(), val.c_str()); 146 finch_blacklist_registry_key.WriteValue(
141 } 147 blacklist::kRegistryFinchListValueName, reg_buffer.data(),
148 (reg_buffer.size() * sizeof(wchar_t)), REG_MULTI_SZ);
142 } 149 }
143 150
144 void BrowserBlacklistBeaconSetup() { 151 void BrowserBlacklistBeaconSetup() {
145 base::win::RegKey blacklist_registry_key(HKEY_CURRENT_USER, 152 base::win::RegKey blacklist_registry_key(HKEY_CURRENT_USER,
146 blacklist::kRegistryBeaconPath, 153 blacklist::kRegistryBeaconPath,
147 KEY_QUERY_VALUE | KEY_SET_VALUE); 154 KEY_QUERY_VALUE | KEY_SET_VALUE);
148 155
149 // 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.
150 if (!blacklist_registry_key.Valid()) 157 if (!blacklist_registry_key.Valid())
151 return; 158 return;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 206
200 blacklist_registry_key.WriteValue(blacklist::kBeaconAttemptCount, 207 blacklist_registry_key.WriteValue(blacklist::kBeaconAttemptCount,
201 static_cast<DWORD>(0)); 208 static_cast<DWORD>(0));
202 209
203 // Only report the blacklist as getting setup when both registry writes 210 // Only report the blacklist as getting setup when both registry writes
204 // succeed, since otherwise the blacklist wasn't properly setup. 211 // succeed, since otherwise the blacklist wasn't properly setup.
205 if (set_version == ERROR_SUCCESS && set_state == ERROR_SUCCESS) 212 if (set_version == ERROR_SUCCESS && set_state == ERROR_SUCCESS)
206 RecordBlacklistSetupEvent(BLACKLIST_SETUP_ENABLED); 213 RecordBlacklistSetupEvent(BLACKLIST_SETUP_ENABLED);
207 } 214 }
208 } 215 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698