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

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

Issue 10821047: Provide access to recommended pref values (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
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_value_store.h" 5 #include "chrome/browser/prefs/pref_value_store.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/browser/prefs/pref_model_associator.h" 8 #include "chrome/browser/prefs/pref_model_associator.h"
9 #include "chrome/browser/prefs/pref_notifier.h" 9 #include "chrome/browser/prefs/pref_notifier.h"
10 10
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 << " but got " << (*out_value)->GetType() 111 << " but got " << (*out_value)->GetType()
112 << " in store " << i; 112 << " in store " << i;
113 continue; 113 continue;
114 } 114 }
115 return true; 115 return true;
116 } 116 }
117 } 117 }
118 return false; 118 return false;
119 } 119 }
120 120
121 bool PrefValueStore::GetRecommendedValue(const std::string& name,
122 base::Value::Type type,
123 const Value** out_value) const {
124 *out_value = NULL;
125 if (!GetValueFromStore(name.c_str(), RECOMMENDED_STORE, out_value))
126 return false;
127 if (!(*out_value)->IsType(type)) {
128 LOG(WARNING) << "Expected type for " << name << " is " << type
129 << " but got " << (*out_value)->GetType();
130 return false;
131 }
Mattias Nissler (ping if slow) 2012/07/27 07:26:11 indentation
bartfab (slow) 2012/07/27 12:14:49 Done.
132 return true;
Mattias Nissler (ping if slow) 2012/07/27 07:26:11 seems like the code in this function is essentiall
bartfab (slow) 2012/07/27 12:14:49 Done.
133 }
134
121 void PrefValueStore::NotifyPrefChanged( 135 void PrefValueStore::NotifyPrefChanged(
122 const char* path, 136 const char* path,
123 PrefValueStore::PrefStoreType new_store) { 137 PrefValueStore::PrefStoreType new_store) {
124 DCHECK(new_store != INVALID_STORE); 138 DCHECK(new_store != INVALID_STORE);
125 139
126 // If the pref is controlled by a higher-priority store, its effective value 140 // If the pref is controlled by a higher-priority store, its effective value
127 // cannot have changed. 141 // cannot have changed.
128 PrefStoreType controller = ControllingPrefStoreForPref(path); 142 PrefStoreType controller = ControllingPrefStoreForPref(path);
129 if (controller == INVALID_STORE || controller >= new_store) { 143 if (controller == INVALID_STORE || controller >= new_store) {
130 pref_notifier_->OnPreferenceChanged(path); 144 pref_notifier_->OnPreferenceChanged(path);
131 if (pref_sync_associator_) 145 if (pref_sync_associator_)
132 pref_sync_associator_->ProcessPrefChange(path); 146 pref_sync_associator_->ProcessPrefChange(path);
147 // Always fire a notification when the recommended value changes, even if the
148 // effective value is unchanged.
Mattias Nissler (ping if slow) 2012/07/27 07:26:11 As discussed offline, maybe we want to just drop a
bartfab (slow) 2012/07/27 12:14:49 Fresh profile: Start browser, visit google.com, sh
149 } else if (new_store == RECOMMENDED_STORE) {
150 pref_notifier_->OnPreferenceChanged(path);
133 } 151 }
134 } 152 }
135 153
136 bool PrefValueStore::PrefValueInManagedStore(const char* name) const { 154 bool PrefValueStore::PrefValueInManagedStore(const char* name) const {
137 return PrefValueInStore(name, MANAGED_STORE); 155 return PrefValueInStore(name, MANAGED_STORE);
138 } 156 }
139 157
140 bool PrefValueStore::PrefValueInExtensionStore(const char* name) const { 158 bool PrefValueStore::PrefValueInExtensionStore(const char* name) const {
141 return PrefValueInStore(name, EXTENSION_STORE); 159 return PrefValueInStore(name, EXTENSION_STORE);
142 } 160 }
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 if (initialization_failed_) 283 if (initialization_failed_)
266 return; 284 return;
267 for (size_t i = 0; i <= PREF_STORE_TYPE_MAX; ++i) { 285 for (size_t i = 0; i <= PREF_STORE_TYPE_MAX; ++i) {
268 scoped_refptr<PrefStore> store = 286 scoped_refptr<PrefStore> store =
269 GetPrefStore(static_cast<PrefStoreType>(i)); 287 GetPrefStore(static_cast<PrefStoreType>(i));
270 if (store && !store->IsInitializationComplete()) 288 if (store && !store->IsInitializationComplete())
271 return; 289 return;
272 } 290 }
273 pref_notifier_->OnInitializationCompleted(true); 291 pref_notifier_->OnInitializationCompleted(true);
274 } 292 }
OLDNEW
« no previous file with comments | « chrome/browser/prefs/pref_value_store.h ('k') | chrome/browser/prefs/pref_value_store_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698