Index: chrome/browser/prefs/pref_notifier.cc |
diff --git a/chrome/browser/prefs/pref_notifier.cc b/chrome/browser/prefs/pref_notifier.cc |
index 151b128aa60c88e42cd2c6698c1ca4bc8b08fc4b..55ebe0bfcb22cde94be3e78019e24d0bc7dd903d 100644 |
--- a/chrome/browser/prefs/pref_notifier.cc |
+++ b/chrome/browser/prefs/pref_notifier.cc |
@@ -11,13 +11,8 @@ |
#include "chrome/browser/prefs/pref_value_store.h" |
#include "chrome/common/notification_service.h" |
- |
-PrefNotifier::PrefNotifier(PrefService* service, PrefValueStore* value_store) |
- : pref_service_(service), |
- pref_value_store_(value_store) { |
- registrar_.Add(this, |
- NotificationType(NotificationType::POLICY_CHANGED), |
- NotificationService::AllSources()); |
+PrefNotifier::PrefNotifier(PrefService* service) |
+ : pref_service_(service) { |
} |
PrefNotifier::~PrefNotifier() { |
@@ -37,23 +32,24 @@ PrefNotifier::~PrefNotifier() { |
pref_observers_.clear(); |
} |
-void PrefNotifier::OnPreferenceSet(const char* pref_name, |
- PrefNotifier::PrefStoreType new_store) { |
- if (pref_value_store_->PrefHasChanged(pref_name, new_store)) |
+void PrefNotifier::OnPreferenceChanged(const std::string& pref_name) { |
+ if (pref_service_->FindPreference(pref_name.c_str())) |
FireObservers(pref_name); |
} |
-void PrefNotifier::OnUserPreferenceSet(const char* pref_name) { |
- OnPreferenceSet(pref_name, PrefNotifier::USER_STORE); |
+void PrefNotifier::OnInitializationCompleted() { |
+ NotificationService::current()->Notify( |
+ NotificationType::PREF_INITIALIZATION_COMPLETED, |
+ Source<PrefService>(pref_service_), |
+ NotificationService::NoDetails()); |
} |
-void PrefNotifier::FireObservers(const char* path) { |
+void PrefNotifier::FireObservers(const std::string& path) { |
DCHECK(CalledOnValidThread()); |
// Convert path to a std::string because the Details constructor requires a |
// class. |
battre (please use the other)
2010/12/02 10:41:19
This comment became obsolete.
Mattias Nissler (ping if slow)
2010/12/02 16:38:24
Done.
|
- std::string path_str(path); |
- PrefObserverMap::iterator observer_iterator = pref_observers_.find(path_str); |
+ PrefObserverMap::iterator observer_iterator = pref_observers_.find(path); |
if (observer_iterator == pref_observers_.end()) |
return; |
@@ -62,7 +58,7 @@ void PrefNotifier::FireObservers(const char* path) { |
while ((observer = it.GetNext()) != NULL) { |
observer->Observe(NotificationType::PREF_CHANGED, |
Source<PrefService>(pref_service_), |
- Details<std::string>(&path_str)); |
+ Details<const std::string>(&path)); |
} |
} |
@@ -103,35 +99,3 @@ void PrefNotifier::RemovePrefObserver(const char* path, |
NotificationObserverList* observer_list = observer_iterator->second; |
observer_list->RemoveObserver(obs); |
} |
- |
-void PrefNotifier::FireObserversForRefreshedManagedPrefs( |
- std::vector<std::string> changed_prefs_paths) { |
- DCHECK(CalledOnValidThread()); |
- std::vector<std::string>::const_iterator current; |
- for (current = changed_prefs_paths.begin(); |
- current != changed_prefs_paths.end(); |
- ++current) { |
- FireObservers(current->c_str()); |
- } |
-} |
- |
-void PrefNotifier::Observe(NotificationType type, |
- const NotificationSource& source, |
- const NotificationDetails& details) { |
- using policy::ConfigurationPolicyPrefStore; |
- |
- if (type == NotificationType::POLICY_CHANGED) { |
- PrefValueStore::AfterRefreshCallback* callback = |
- NewCallback(this, |
- &PrefNotifier::FireObserversForRefreshedManagedPrefs); |
- // The notification of the policy refresh can come from any thread, |
- // but the manipulation of the PrefValueStore must happen on the UI |
- // thread, thus the policy refresh must be explicitly started on it. |
- BrowserThread::PostTask( |
- BrowserThread::UI, FROM_HERE, |
- NewRunnableMethod( |
- pref_value_store_, |
- &PrefValueStore::RefreshPolicyPrefs, |
- callback)); |
- } |
-} |