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

Unified Diff: chrome/browser/extensions/api/font_settings/font_settings_api.cc

Issue 11345008: Remove content::NotificationObserver dependency from most Prefs code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix PrefNotifierImpl Created 8 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/font_settings/font_settings_api.cc
diff --git a/chrome/browser/extensions/api/font_settings/font_settings_api.cc b/chrome/browser/extensions/api/font_settings/font_settings_api.cc
index 93d6a9c32cebb19b224cd6c64026b000495df5f1..c94607937d9a9660e53251f151ba73fcd65549ef 100644
--- a/chrome/browser/extensions/api/font_settings/font_settings_api.cc
+++ b/chrome/browser/extensions/api/font_settings/font_settings_api.cc
@@ -103,7 +103,7 @@ std::string MaybeGetLocalizedFontName(const std::string& font_name) {
// Registers |obs| to observe per-script font prefs under the path |map_name|.
void RegisterFontFamilyMapObserver(PrefChangeRegistrar* registrar,
const char* map_name,
- content::NotificationObserver* obs) {
+ PrefObserver* obs) {
for (size_t i = 0; i < prefs::kWebKitScriptsForFontFamilyMapsLength; ++i) {
const char* script = prefs::kWebKitScriptsForFontFamilyMaps[i];
std::string pref_name = base::StringPrintf("%s.%s", map_name, script);
@@ -148,41 +148,32 @@ void FontSettingsEventRouter::Init() {
}
void FontSettingsEventRouter::AddPrefToObserve(const char* pref_name,
- const char* event_name,
- const char* key) {
+ const char* event_name,
Mattias Nissler (ping if slow) 2012/10/31 13:29:35 nit: indentation
Jói 2012/10/31 14:56:26 Done.
+ const char* key) {
registrar_.Add(pref_name, this);
pref_event_map_[pref_name] = std::make_pair(event_name, key);
}
-void FontSettingsEventRouter::Observe(
- int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
- if (type != chrome::NOTIFICATION_PREF_CHANGED) {
- NOTREACHED();
- return;
- }
-
- PrefService* pref_service = content::Source<PrefService>(source).ptr();
+void FontSettingsEventRouter::OnPreferenceChanged(
+ PrefServiceBase* pref_service,
+ const std::string& pref_name) {
bool incognito = (pref_service != profile_->GetPrefs());
// We're only observing pref changes on the regular profile.
DCHECK(!incognito);
- const std::string* pref_name =
- content::Details<const std::string>(details).ptr();
- PrefEventMap::iterator iter = pref_event_map_.find(*pref_name);
+ PrefEventMap::iterator iter = pref_event_map_.find(pref_name);
if (iter != pref_event_map_.end()) {
const std::string& event_name = iter->second.first;
const std::string& key = iter->second.second;
- OnFontPrefChanged(pref_service, *pref_name, event_name, key, incognito);
+ OnFontPrefChanged(pref_service, pref_name, event_name, key, incognito);
return;
}
std::string generic_family;
std::string script;
- if (ParseFontNamePrefPath(*pref_name, &generic_family, &script)) {
- OnFontNamePrefChanged(pref_service, *pref_name, generic_family, script,
- incognito);
+ if (ParseFontNamePrefPath(pref_name, &generic_family, &script)) {
+ OnFontNamePrefChanged(static_cast<PrefService*>(pref_service), pref_name,
Mattias Nissler (ping if slow) 2012/10/31 13:29:35 The cast is not necessary.
Jói 2012/10/31 14:56:26 It was (this is OnFontNamePrefChanged, not OnFontN
+ generic_family, script, incognito);
return;
}
@@ -223,12 +214,12 @@ void FontSettingsEventRouter::OnFontNamePrefChanged(
}
void FontSettingsEventRouter::OnFontPrefChanged(
- PrefService* pref_service,
+ PrefServiceBase* pref_service,
const std::string& pref_name,
const std::string& event_name,
const std::string& key,
bool incognito) {
- const PrefService::Preference* pref = pref_service->FindPreference(
+ const PrefServiceBase::Preference* pref = pref_service->FindPreference(
pref_name.c_str());
CHECK(pref);

Powered by Google App Engine
This is Rietveld 408576698