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

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

Issue 10828345: Extract PrefServiceBase into chrome/browser/api. Use in api and autofill. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head Created 8 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
« no previous file with comments | « chrome/browser/prefs/pref_service.h ('k') | chrome/browser/printing/print_view_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/pref_service.h" 5 #include "chrome/browser/prefs/pref_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/file_path.h" 11 #include "base/file_path.h"
12 #include "base/file_util.h" 12 #include "base/file_util.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/message_loop.h" 14 #include "base/message_loop.h"
15 #include "base/metrics/histogram.h" 15 #include "base/metrics/histogram.h"
16 #include "base/stl_util.h" 16 #include "base/stl_util.h"
17 #include "base/string_number_conversions.h" 17 #include "base/string_number_conversions.h"
18 #include "base/string_util.h" 18 #include "base/string_util.h"
19 #include "base/value_conversions.h" 19 #include "base/value_conversions.h"
20 #include "build/build_config.h" 20 #include "build/build_config.h"
21 #include "chrome/browser/browser_process.h" 21 #include "chrome/browser/browser_process.h"
22 #include "chrome/browser/extensions/extension_pref_store.h" 22 #include "chrome/browser/extensions/extension_pref_store.h"
23 #include "chrome/browser/policy/configuration_policy_pref_store.h" 23 #include "chrome/browser/policy/configuration_policy_pref_store.h"
24 #include "chrome/browser/prefs/command_line_pref_store.h" 24 #include "chrome/browser/prefs/command_line_pref_store.h"
25 #include "chrome/browser/prefs/default_pref_store.h" 25 #include "chrome/browser/prefs/default_pref_store.h"
26 #include "chrome/browser/prefs/overlay_user_pref_store.h" 26 #include "chrome/browser/prefs/overlay_user_pref_store.h"
27 #include "chrome/browser/prefs/pref_model_associator.h" 27 #include "chrome/browser/prefs/pref_model_associator.h"
28 #include "chrome/browser/prefs/pref_notifier_impl.h" 28 #include "chrome/browser/prefs/pref_notifier_impl.h"
29 #include "chrome/browser/prefs/pref_value_store.h" 29 #include "chrome/browser/prefs/pref_value_store.h"
30 #include "chrome/browser/profiles/profile.h"
30 #include "chrome/browser/ui/prefs/prefs_tab_helper.h" 31 #include "chrome/browser/ui/prefs/prefs_tab_helper.h"
31 #include "chrome/browser/ui/profile_error_dialog.h" 32 #include "chrome/browser/ui/profile_error_dialog.h"
32 #include "chrome/common/json_pref_store.h" 33 #include "chrome/common/json_pref_store.h"
33 #include "chrome/common/pref_names.h" 34 #include "chrome/common/pref_names.h"
34 #include "content/public/browser/browser_thread.h" 35 #include "content/public/browser/browser_thread.h"
35 #include "grit/chromium_strings.h" 36 #include "grit/chromium_strings.h"
36 #include "grit/generated_resources.h" 37 #include "grit/generated_resources.h"
37 #include "ui/base/l10n/l10n_util.h" 38 #include "ui/base/l10n/l10n_util.h"
38 39
39 using content::BrowserThread; 40 using content::BrowserThread;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 base::Bind(&NotifyReadError, message_id)); 107 base::Bind(&NotifyReadError, message_id));
107 } 108 }
108 UMA_HISTOGRAM_ENUMERATION("PrefService.ReadError", error, 109 UMA_HISTOGRAM_ENUMERATION("PrefService.ReadError", error,
109 PersistentPrefStore::PREF_READ_ERROR_MAX_ENUM); 110 PersistentPrefStore::PREF_READ_ERROR_MAX_ENUM);
110 } 111 }
111 } 112 }
112 }; 113 };
113 114
114 } // namespace 115 } // namespace
115 116
117 PrefServiceBase* PrefServiceBase::ForProfile(Profile* profile) {
118 return profile->GetPrefs();
119 }
120
116 // static 121 // static
117 PrefService* PrefService::CreatePrefService( 122 PrefService* PrefService::CreatePrefService(
118 const FilePath& pref_filename, 123 const FilePath& pref_filename,
119 policy::PolicyService* policy_service, 124 policy::PolicyService* policy_service,
120 PrefStore* extension_prefs, 125 PrefStore* extension_prefs,
121 bool async) { 126 bool async) {
122 using policy::ConfigurationPolicyPrefStore; 127 using policy::ConfigurationPolicyPrefStore;
123 128
124 #if defined(OS_LINUX) 129 #if defined(OS_LINUX)
125 // We'd like to see what fraction of our users have the preferences 130 // We'd like to see what fraction of our users have the preferences
(...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after
969 PrefService::Preference::Preference(const PrefService* service, 974 PrefService::Preference::Preference(const PrefService* service,
970 const char* name, 975 const char* name,
971 base::Value::Type type) 976 base::Value::Type type)
972 : name_(name), 977 : name_(name),
973 type_(type), 978 type_(type),
974 pref_service_(service) { 979 pref_service_(service) {
975 DCHECK(name); 980 DCHECK(name);
976 DCHECK(service); 981 DCHECK(service);
977 } 982 }
978 983
984 const std::string PrefService::Preference::name() const {
985 return name_;
986 }
987
979 base::Value::Type PrefService::Preference::GetType() const { 988 base::Value::Type PrefService::Preference::GetType() const {
980 return type_; 989 return type_;
981 } 990 }
982 991
983 const Value* PrefService::Preference::GetValue() const { 992 const Value* PrefService::Preference::GetValue() const {
984 DCHECK(pref_service_->FindPreference(name_.c_str())) << 993 DCHECK(pref_service_->FindPreference(name_.c_str())) <<
985 "Must register pref before getting its value"; 994 "Must register pref before getting its value";
986 995
987 const Value* found_value = NULL; 996 const Value* found_value = NULL;
988 if (pref_value_store()->GetValue(name_, type_, &found_value)) { 997 if (pref_value_store()->GetValue(name_, type_, &found_value)) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1037 return pref_value_store()->PrefValueFromDefaultStore(name_.c_str()); 1046 return pref_value_store()->PrefValueFromDefaultStore(name_.c_str());
1038 } 1047 }
1039 1048
1040 bool PrefService::Preference::IsUserModifiable() const { 1049 bool PrefService::Preference::IsUserModifiable() const {
1041 return pref_value_store()->PrefValueUserModifiable(name_.c_str()); 1050 return pref_value_store()->PrefValueUserModifiable(name_.c_str());
1042 } 1051 }
1043 1052
1044 bool PrefService::Preference::IsExtensionModifiable() const { 1053 bool PrefService::Preference::IsExtensionModifiable() const {
1045 return pref_value_store()->PrefValueExtensionModifiable(name_.c_str()); 1054 return pref_value_store()->PrefValueExtensionModifiable(name_.c_str());
1046 } 1055 }
OLDNEW
« no previous file with comments | « chrome/browser/prefs/pref_service.h ('k') | chrome/browser/printing/print_view_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698