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

Side by Side Diff: components/policy/core/common/policy_loader_win_unittest.cc

Issue 651253002: Enforce handle ownership in base::Process (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add empty line Created 6 years, 2 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "components/policy/core/common/policy_loader_win.h" 5 #include "components/policy/core/common/policy_loader_win.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <userenv.h> 8 #include <userenv.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
11 #include <cstring> 11 #include <cstring>
12 #include <functional> 12 #include <functional>
13 #include <iterator> 13 #include <iterator>
14 #include <vector> 14 #include <vector>
15 15
16 #include "base/base_paths.h" 16 #include "base/base_paths.h"
17 #include "base/callback.h" 17 #include "base/callback.h"
18 #include "base/files/file_path.h" 18 #include "base/files/file_path.h"
19 #include "base/files/file_util.h" 19 #include "base/files/file_util.h"
20 #include "base/files/scoped_temp_dir.h" 20 #include "base/files/scoped_temp_dir.h"
21 #include "base/json/json_writer.h" 21 #include "base/json/json_writer.h"
22 #include "base/path_service.h" 22 #include "base/path_service.h"
23 #include "base/process/process.h" 23 #include "base/process/process_handle.h"
24 #include "base/strings/string16.h" 24 #include "base/strings/string16.h"
25 #include "base/strings/string_number_conversions.h" 25 #include "base/strings/string_number_conversions.h"
26 #include "base/strings/string_util.h" 26 #include "base/strings/string_util.h"
27 #include "base/strings/stringprintf.h" 27 #include "base/strings/stringprintf.h"
28 #include "base/strings/utf_string_conversions.h" 28 #include "base/strings/utf_string_conversions.h"
29 #include "base/sys_byteorder.h" 29 #include "base/sys_byteorder.h"
30 #include "base/win/registry.h" 30 #include "base/win/registry.h"
31 #include "base/win/win_util.h" 31 #include "base/win/win_util.h"
32 #include "components/policy/core/common/async_policy_provider.h" 32 #include "components/policy/core/common/async_policy_provider.h"
33 #include "components/policy/core/common/configuration_policy_provider_test.h" 33 #include "components/policy/core/common/configuration_policy_provider_test.h"
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 GROUP_POLICY_OBJECT gpo_; 290 GROUP_POLICY_OBJECT gpo_;
291 291
292 DISALLOW_COPY_AND_ASSIGN(PRegTestHarness); 292 DISALLOW_COPY_AND_ASSIGN(PRegTestHarness);
293 }; 293 };
294 294
295 ScopedGroupPolicyRegistrySandbox::ScopedGroupPolicyRegistrySandbox() { 295 ScopedGroupPolicyRegistrySandbox::ScopedGroupPolicyRegistrySandbox() {
296 // Generate a unique registry key for the override for each test. This 296 // Generate a unique registry key for the override for each test. This
297 // makes sure that tests executing in parallel won't delete each other's 297 // makes sure that tests executing in parallel won't delete each other's
298 // key, at DeleteKeys(). 298 // key, at DeleteKeys().
299 key_name_ = base::ASCIIToWide(base::StringPrintf( 299 key_name_ = base::ASCIIToWide(base::StringPrintf(
300 "SOFTWARE\\chromium unittest %d", 300 "SOFTWARE\\chromium unittest %d", base::GetCurrentProcId()));
301 base::Process::Current().pid()));
302 std::wstring hklm_key_name = key_name_ + L"\\HKLM"; 301 std::wstring hklm_key_name = key_name_ + L"\\HKLM";
303 std::wstring hkcu_key_name = key_name_ + L"\\HKCU"; 302 std::wstring hkcu_key_name = key_name_ + L"\\HKCU";
304 303
305 // Create the subkeys to hold the overridden HKLM and HKCU 304 // Create the subkeys to hold the overridden HKLM and HKCU
306 // policy settings. 305 // policy settings.
307 temp_hklm_hive_key_.Create(HKEY_CURRENT_USER, 306 temp_hklm_hive_key_.Create(HKEY_CURRENT_USER,
308 hklm_key_name.c_str(), 307 hklm_key_name.c_str(),
309 KEY_ALL_ACCESS); 308 KEY_ALL_ACCESS);
310 temp_hkcu_hive_key_.Create(HKEY_CURRENT_USER, 309 temp_hkcu_hive_key_.Create(HKEY_CURRENT_USER,
311 hkcu_key_name.c_str(), 310 hkcu_key_name.c_str(),
(...skipping 896 matching lines...) Expand 10 before | Expand all | Expand 10 after
1208 PolicyMap& expected_policy = expected.Get(ns); 1207 PolicyMap& expected_policy = expected.Get(ns);
1209 expected_policy.Set("alternative_browser_path", 1208 expected_policy.Set("alternative_browser_path",
1210 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, 1209 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE,
1211 new base::StringValue("c:\\legacy\\browser.exe"), NULL); 1210 new base::StringValue("c:\\legacy\\browser.exe"), NULL);
1212 expected_policy.Set("url_list", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, 1211 expected_policy.Set("url_list", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE,
1213 list.DeepCopy(), NULL); 1212 list.DeepCopy(), NULL);
1214 EXPECT_TRUE(Matches(expected)); 1213 EXPECT_TRUE(Matches(expected));
1215 } 1214 }
1216 1215
1217 } // namespace policy 1216 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/safe_browsing_database.cc ('k') | content/browser/browser_child_process_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698