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

Side by Side Diff: chrome/browser/win/chrome_elf_init.cc

Issue 1841573002: [Chrome ELF] New NT registry API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: PRESUBMIT to allow chrome_elf directory files to use wstring. Created 4 years, 5 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
« no previous file with comments | « base/test/test_reg_util_win.cc ('k') | chrome/browser/win/chrome_elf_init_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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
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, &params); 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
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 }
OLDNEW
« no previous file with comments | « base/test/test_reg_util_win.cc ('k') | chrome/browser/win/chrome_elf_init_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698