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

Side by Side Diff: chrome/browser/policy/policy_prefs_browsertest.cc

Issue 1940153002: Use std::unique_ptr to express ownership of base::Value in PolicyMap::Entry (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: another-fix Created 4 years, 7 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cstdlib> 8 #include <cstdlib>
9 #include <map> 9 #include <map>
10 #include <memory> 10 #include <memory>
11 #include <sstream> 11 #include <sstream>
12 #include <string> 12 #include <string>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/files/file_path.h" 15 #include "base/files/file_path.h"
16 #include "base/files/file_util.h" 16 #include "base/files/file_util.h"
17 #include "base/json/json_reader.h" 17 #include "base/json/json_reader.h"
18 #include "base/logging.h" 18 #include "base/logging.h"
19 #include "base/macros.h" 19 #include "base/macros.h"
20 #include "base/memory/ptr_util.h"
20 #include "base/memory/scoped_vector.h" 21 #include "base/memory/scoped_vector.h"
21 #include "base/memory/weak_ptr.h" 22 #include "base/memory/weak_ptr.h"
22 #include "base/run_loop.h" 23 #include "base/run_loop.h"
23 #include "base/stl_util.h" 24 #include "base/stl_util.h"
24 #include "base/strings/string_util.h" 25 #include "base/strings/string_util.h"
25 #include "base/strings/utf_string_conversions.h" 26 #include "base/strings/utf_string_conversions.h"
26 #include "base/values.h" 27 #include "base/values.h"
27 #include "build/build_config.h" 28 #include "build/build_config.h"
28 #include "chrome/browser/browser_process.h" 29 #include "chrome/browser/browser_process.h"
29 #include "chrome/browser/profiles/profile.h" 30 #include "chrome/browser/profiles/profile.h"
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 } 515 }
515 516
516 void SetProviderPolicy(const base::DictionaryValue& policies, 517 void SetProviderPolicy(const base::DictionaryValue& policies,
517 PolicyLevel level) { 518 PolicyLevel level) {
518 PolicyMap policy_map; 519 PolicyMap policy_map;
519 for (base::DictionaryValue::Iterator it(policies); 520 for (base::DictionaryValue::Iterator it(policies);
520 !it.IsAtEnd(); it.Advance()) { 521 !it.IsAtEnd(); it.Advance()) {
521 const PolicyDetails* policy_details = GetChromePolicyDetails(it.key()); 522 const PolicyDetails* policy_details = GetChromePolicyDetails(it.key());
522 ASSERT_TRUE(policy_details); 523 ASSERT_TRUE(policy_details);
523 policy_map.Set( 524 policy_map.Set(
524 it.key(), 525 it.key(), level, POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD,
525 level, 526 it.value().CreateDeepCopy(),
526 POLICY_SCOPE_USER, 527 base::WrapUnique(policy_details->max_external_data_size
527 POLICY_SOURCE_CLOUD, 528 ? new ExternalDataFetcher(nullptr, it.key())
528 it.value().DeepCopy(), 529 : nullptr));
529 policy_details->max_external_data_size ?
530 new ExternalDataFetcher(base::WeakPtr<ExternalDataManager>(),
531 it.key()) :
532 NULL);
533 } 530 }
534 provider_.UpdateChromePolicy(policy_map); 531 provider_.UpdateChromePolicy(policy_map);
535 base::RunLoop().RunUntilIdle(); 532 base::RunLoop().RunUntilIdle();
536 } 533 }
537 534
538 MockConfigurationPolicyProvider provider_; 535 MockConfigurationPolicyProvider provider_;
539 }; 536 };
540 537
541 // Verifies that policies make their corresponding preferences become managed, 538 // Verifies that policies make their corresponding preferences become managed,
542 // and that the user can't override that setting. 539 // and that the user can't override that setting.
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 } 755 }
759 } 756 }
760 } 757 }
761 } 758 }
762 759
763 INSTANTIATE_TEST_CASE_P(PolicyPrefIndicatorTestInstance, 760 INSTANTIATE_TEST_CASE_P(PolicyPrefIndicatorTestInstance,
764 PolicyPrefIndicatorTest, 761 PolicyPrefIndicatorTest,
765 testing::ValuesIn(SplitPoliciesIntoChunks(10))); 762 testing::ValuesIn(SplitPoliciesIntoChunks(10)));
766 763
767 } // namespace policy 764 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/policy_network_browsertest.cc ('k') | chrome/browser/policy/policy_startup_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698