OLD | NEW |
---|---|
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 "chrome/browser/prefs/pref_service_mock_builder.h" | 5 #include "chrome/browser/prefs/pref_service_mock_builder.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop_proxy.h" | 8 #include "base/message_loop_proxy.h" |
9 #include "base/prefs/default_pref_store.h" | 9 #include "base/prefs/default_pref_store.h" |
10 #include "base/prefs/json_pref_store.h" | 10 #include "base/prefs/json_pref_store.h" |
11 #include "base/prefs/testing_pref_store.h" | 11 #include "base/prefs/testing_pref_store.h" |
12 #include "chrome/browser/policy/configuration_policy_pref_store.h" | 12 #include "chrome/browser/policy/configuration_policy_pref_store.h" |
13 #include "chrome/browser/prefs/command_line_pref_store.h" | 13 #include "chrome/browser/prefs/command_line_pref_store.h" |
14 #include "chrome/browser/prefs/pref_notifier_impl.h" | 14 #include "chrome/browser/prefs/pref_notifier_impl.h" |
15 #include "chrome/browser/prefs/pref_service.h" | 15 #include "chrome/browser/prefs/pref_service.h" |
16 #include "chrome/browser/prefs/pref_value_store.h" | 16 #include "chrome/browser/prefs/pref_value_store.h" |
17 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
Mattias Nissler (ping if slow)
2012/12/21 15:03:20
Please clean up the #includes that are no longer n
Jói
2012/12/21 15:29:52
Done.
| |
18 #include "ui/base/l10n/l10n_util.h" | |
19 | 18 |
20 using content::BrowserThread; | 19 using content::BrowserThread; |
21 | 20 |
22 PrefServiceMockBuilder::PrefServiceMockBuilder() { | 21 PrefServiceMockBuilder::PrefServiceMockBuilder() { |
23 ResetTestingState(); | |
24 } | 22 } |
25 | 23 |
26 PrefServiceMockBuilder::~PrefServiceMockBuilder() {} | 24 PrefServiceMockBuilder::~PrefServiceMockBuilder() {} |
27 | 25 |
28 #if defined(ENABLE_CONFIGURATION_POLICY) | 26 PrefServiceSimple* PrefServiceMockBuilder::CreateSimple() { |
29 PrefServiceMockBuilder& PrefServiceMockBuilder::WithManagedPolicies( | 27 user_prefs_ = new TestingPrefStore; |
Mattias Nissler (ping if slow)
2012/12/21 15:03:20
I think you should do this in a ResetDefaultState(
Jói
2012/12/21 15:29:52
Good idea, switched to that approach.
| |
30 policy::PolicyService* service) { | 28 PrefServiceSimple* service = PrefServiceBuilder::CreateSimple(); |
31 WithManagedPrefs(new policy::ConfigurationPolicyPrefStore( | 29 return service; |
32 service, policy::POLICY_LEVEL_MANDATORY)); | |
33 return *this; | |
34 } | 30 } |
35 | 31 |
36 PrefServiceMockBuilder& PrefServiceMockBuilder::WithRecommendedPolicies( | 32 PrefServiceSyncable* PrefServiceMockBuilder::CreateSyncable() { |
37 policy::PolicyService* service) { | 33 user_prefs_ = new TestingPrefStore; |
38 WithRecommendedPrefs(new policy::ConfigurationPolicyPrefStore( | 34 PrefServiceSyncable* service = PrefServiceSyncableBuilder::CreateSyncable(); |
39 service, policy::POLICY_LEVEL_RECOMMENDED)); | 35 return service; |
40 return *this; | |
41 } | 36 } |
42 #endif | |
43 | |
44 PrefServiceMockBuilder& | |
45 PrefServiceMockBuilder::WithCommandLine(CommandLine* command_line) { | |
46 WithCommandLinePrefs(new CommandLinePrefStore(command_line)); | |
47 return *this; | |
48 } | |
49 | |
50 PrefService* PrefServiceMockBuilder::Create() { | |
51 PrefService* pref_service = PrefServiceBuilder::Create(); | |
52 ResetTestingState(); | |
53 return pref_service; | |
54 } | |
55 | |
56 void PrefServiceMockBuilder::ResetTestingState() { | |
57 user_prefs_ = new TestingPrefStore; | |
58 } | |
OLD | NEW |