blob: b02a334142ea91a93485d3ed8e7a50d408ff81c0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/prefs/pref_service_mock_builder.h"
#include "chrome/browser/browser_thread.h"
#include "chrome/browser/policy/configuration_policy_pref_store.h"
#include "chrome/browser/prefs/command_line_pref_store.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/prefs/testing_pref_store.h"
#include "chrome/common/json_pref_store.h"
PrefServiceMockBuilder::PrefServiceMockBuilder()
: user_prefs_(new TestingPrefStore) {
}
PrefServiceMockBuilder::~PrefServiceMockBuilder() {}
PrefServiceMockBuilder&
PrefServiceMockBuilder::WithManagedPlatformPrefs(PrefStore* store) {
managed_platform_prefs_.reset(store);
return *this;
}
PrefServiceMockBuilder&
PrefServiceMockBuilder::WithDeviceManagementPrefs(PrefStore* store) {
device_management_prefs_.reset(store);
return *this;
}
PrefServiceMockBuilder&
PrefServiceMockBuilder::WithExtensionPrefs(PrefStore* store) {
extension_prefs_.reset(store);
return *this;
}
PrefServiceMockBuilder&
PrefServiceMockBuilder::WithCommandLinePrefs(PrefStore* store) {
command_line_prefs_.reset(store);
return *this;
}
PrefServiceMockBuilder&
PrefServiceMockBuilder::WithUserPrefs(PersistentPrefStore* store) {
user_prefs_.reset(store);
return *this;
}
PrefServiceMockBuilder&
PrefServiceMockBuilder::WithRecommendedPrefs(PrefStore* store) {
recommended_prefs_.reset(store);
return *this;
}
PrefServiceMockBuilder&
PrefServiceMockBuilder::WithManagedPlatformProvider(
policy::ConfigurationPolicyProvider* provider) {
managed_platform_prefs_.reset(
new policy::ConfigurationPolicyPrefStore(provider));
return *this;
}
PrefServiceMockBuilder&
PrefServiceMockBuilder::WithDeviceManagementProvider(
policy::ConfigurationPolicyProvider* provider) {
device_management_prefs_.reset(
new policy::ConfigurationPolicyPrefStore(provider));
return *this;
}
PrefServiceMockBuilder&
PrefServiceMockBuilder::WithRecommendedProvider(
policy::ConfigurationPolicyProvider* provider) {
recommended_prefs_.reset(
new policy::ConfigurationPolicyPrefStore(provider));
return *this;
}
PrefServiceMockBuilder&
PrefServiceMockBuilder::WithCommandLine(CommandLine* command_line) {
command_line_prefs_.reset(new CommandLinePrefStore(command_line));
return *this;
}
PrefServiceMockBuilder&
PrefServiceMockBuilder::WithUserFilePrefs(const FilePath& prefs_file) {
user_prefs_.reset(
new JsonPrefStore(prefs_file,
BrowserThread::GetMessageLoopProxyForThread(
BrowserThread::FILE)));
return *this;
}
PrefService* PrefServiceMockBuilder::Create() {
PrefService* pref_service =
new PrefService(managed_platform_prefs_.release(),
device_management_prefs_.release(),
extension_prefs_.release(),
command_line_prefs_.release(),
user_prefs_.release(),
recommended_prefs_.release());
user_prefs_.reset(new TestingPrefStore);
return pref_service;
}
|