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

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: Nit fixes & CreateRegKey now recursive. Created 4 years, 6 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 base::string16 value_wcs = base::UTF8ToWide(value);
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 value_wcs.push_back(L'\0');
138 std::wstring val = base::UTF8ToWide(it->second); 142 value_wcs.push_back(L'\0');
143 std::replace(value_wcs.begin(), value_wcs.end(), L',', L'\0');
139 144
140 finch_blacklist_registry_key.WriteValue(name.c_str(), val.c_str()); 145 finch_blacklist_registry_key.WriteValue(
141 } 146 blacklist::kRegistryFinchListValueName, value_wcs.data(),
147 (value_wcs.size() * sizeof(wchar_t)), REG_MULTI_SZ);
142 } 148 }
143 149
144 void BrowserBlacklistBeaconSetup() { 150 void BrowserBlacklistBeaconSetup() {
145 base::win::RegKey blacklist_registry_key(HKEY_CURRENT_USER, 151 base::win::RegKey blacklist_registry_key(HKEY_CURRENT_USER,
146 blacklist::kRegistryBeaconPath, 152 blacklist::kRegistryBeaconPath,
147 KEY_QUERY_VALUE | KEY_SET_VALUE); 153 KEY_QUERY_VALUE | KEY_SET_VALUE);
148 154
149 // No point in trying to continue if the registry key isn't valid. 155 // No point in trying to continue if the registry key isn't valid.
150 if (!blacklist_registry_key.Valid()) 156 if (!blacklist_registry_key.Valid())
151 return; 157 return;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 205
200 blacklist_registry_key.WriteValue(blacklist::kBeaconAttemptCount, 206 blacklist_registry_key.WriteValue(blacklist::kBeaconAttemptCount,
201 static_cast<DWORD>(0)); 207 static_cast<DWORD>(0));
202 208
203 // Only report the blacklist as getting setup when both registry writes 209 // Only report the blacklist as getting setup when both registry writes
204 // succeed, since otherwise the blacklist wasn't properly setup. 210 // succeed, since otherwise the blacklist wasn't properly setup.
205 if (set_version == ERROR_SUCCESS && set_state == ERROR_SUCCESS) 211 if (set_version == ERROR_SUCCESS && set_state == ERROR_SUCCESS)
206 RecordBlacklistSetupEvent(BLACKLIST_SETUP_ENABLED); 212 RecordBlacklistSetupEvent(BLACKLIST_SETUP_ENABLED);
207 } 213 }
208 } 214 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698