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

Side by Side Diff: chrome/browser/prefs/chrome_pref_service_factory.cc

Issue 22812002: Refactored ConfigurationPolicyPrefStore to not depend on chrome/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 4 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 | Annotate | Revision Log
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 "chrome/browser/prefs/chrome_pref_service_factory.h" 5 #include "chrome/browser/prefs/chrome_pref_service_factory.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "base/prefs/default_pref_store.h" 12 #include "base/prefs/default_pref_store.h"
13 #include "base/prefs/json_pref_store.h" 13 #include "base/prefs/json_pref_store.h"
14 #include "base/prefs/pref_notifier_impl.h" 14 #include "base/prefs/pref_notifier_impl.h"
15 #include "base/prefs/pref_registry.h" 15 #include "base/prefs/pref_registry.h"
16 #include "base/prefs/pref_service.h" 16 #include "base/prefs/pref_service.h"
17 #include "base/prefs/pref_value_store.h" 17 #include "base/prefs/pref_value_store.h"
18 #include "chrome/browser/policy/configuration_policy_pref_store.h" 18 #include "chrome/browser/browser_process.h"
19 #include "chrome/browser/prefs/command_line_pref_store.h" 19 #include "chrome/browser/prefs/command_line_pref_store.h"
20 #include "chrome/browser/prefs/pref_model_associator.h" 20 #include "chrome/browser/prefs/pref_model_associator.h"
21 #include "chrome/browser/prefs/pref_service_syncable_builder.h" 21 #include "chrome/browser/prefs/pref_service_syncable_builder.h"
22 #include "chrome/browser/ui/profile_error_dialog.h" 22 #include "chrome/browser/ui/profile_error_dialog.h"
23 #include "components/user_prefs/pref_registry_syncable.h" 23 #include "components/user_prefs/pref_registry_syncable.h"
24 #include "content/public/browser/browser_context.h" 24 #include "content/public/browser/browser_context.h"
25 #include "content/public/browser/browser_thread.h" 25 #include "content/public/browser/browser_thread.h"
26 #include "grit/chromium_strings.h" 26 #include "grit/chromium_strings.h"
27 #include "grit/generated_resources.h" 27 #include "grit/generated_resources.h"
28 28
29 #if defined(ENABLE_CONFIGURATION_POLICY)
30 #include "chrome/browser/policy/browser_policy_connector.h"
31 #include "chrome/browser/policy/configuration_policy_pref_store.h"
32 #include "chrome/browser/policy/policy_types.h"
33 #endif
34
29 using content::BrowserContext; 35 using content::BrowserContext;
30 using content::BrowserThread; 36 using content::BrowserThread;
31 37
32 namespace { 38 namespace {
33 39
34 // Shows notifications which correspond to PersistentPrefStore's reading errors. 40 // Shows notifications which correspond to PersistentPrefStore's reading errors.
35 void HandleReadError(PersistentPrefStore::PrefReadError error) { 41 void HandleReadError(PersistentPrefStore::PrefReadError error) {
36 if (error != PersistentPrefStore::PREF_READ_ERROR_NONE) { 42 if (error != PersistentPrefStore::PREF_READ_ERROR_NONE) {
37 // Failing to load prefs on startup is a bad thing(TM). See bug 38352 for 43 // Failing to load prefs on startup is a bad thing(TM). See bug 38352 for
38 // an example problem that this can cause. 44 // an example problem that this can cause.
(...skipping 29 matching lines...) Expand all
68 file_util::FileSystemType fstype; 74 file_util::FileSystemType fstype;
69 if (file_util::GetFileSystemType(pref_filename.DirName(), &fstype)) { 75 if (file_util::GetFileSystemType(pref_filename.DirName(), &fstype)) {
70 UMA_HISTOGRAM_ENUMERATION("PrefService.FileSystemType", 76 UMA_HISTOGRAM_ENUMERATION("PrefService.FileSystemType",
71 static_cast<int>(fstype), 77 static_cast<int>(fstype),
72 file_util::FILE_SYSTEM_TYPE_COUNT); 78 file_util::FILE_SYSTEM_TYPE_COUNT);
73 } 79 }
74 #endif 80 #endif
75 81
76 #if defined(ENABLE_CONFIGURATION_POLICY) 82 #if defined(ENABLE_CONFIGURATION_POLICY)
77 using policy::ConfigurationPolicyPrefStore; 83 using policy::ConfigurationPolicyPrefStore;
78 builder->WithManagedPrefs( 84 builder->WithManagedPrefs(new ConfigurationPolicyPrefStore(
79 ConfigurationPolicyPrefStore::CreateMandatoryPolicyPrefStore( 85 policy_service,
80 policy_service)); 86 g_browser_process->browser_policy_connector()->GetHandlerList(),
81 builder->WithRecommendedPrefs( 87 policy::POLICY_LEVEL_MANDATORY));
82 ConfigurationPolicyPrefStore::CreateRecommendedPolicyPrefStore( 88 builder->WithRecommendedPrefs(new ConfigurationPolicyPrefStore(
83 policy_service)); 89 policy_service,
90 g_browser_process->browser_policy_connector()->GetHandlerList(),
91 policy::POLICY_LEVEL_RECOMMENDED));
84 #endif // ENABLE_CONFIGURATION_POLICY 92 #endif // ENABLE_CONFIGURATION_POLICY
85 93
86 builder->WithAsync(async); 94 builder->WithAsync(async);
87 builder->WithExtensionPrefs(extension_prefs.get()); 95 builder->WithExtensionPrefs(extension_prefs.get());
88 builder->WithCommandLinePrefs( 96 builder->WithCommandLinePrefs(
89 new CommandLinePrefStore(CommandLine::ForCurrentProcess())); 97 new CommandLinePrefStore(CommandLine::ForCurrentProcess()));
90 builder->WithReadErrorCallback(base::Bind(&HandleReadError)); 98 builder->WithReadErrorCallback(base::Bind(&HandleReadError));
91 builder->WithUserPrefs(new JsonPrefStore(pref_filename, pref_io_task_runner)); 99 builder->WithUserPrefs(new JsonPrefStore(pref_filename, pref_io_task_runner));
92 } 100 }
93 101
(...skipping 30 matching lines...) Expand all
124 PrepareBuilder(&builder, 132 PrepareBuilder(&builder,
125 pref_filename, 133 pref_filename,
126 pref_io_task_runner, 134 pref_io_task_runner,
127 policy_service, 135 policy_service,
128 extension_prefs, 136 extension_prefs,
129 async); 137 async);
130 return builder.CreateSyncable(pref_registry.get()); 138 return builder.CreateSyncable(pref_registry.get());
131 } 139 }
132 140
133 } // namespace chrome_prefs 141 } // namespace chrome_prefs
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698