Chromium Code Reviews| 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 cf01a958e33df9ba0d82949357627cf7e80edca3..0a6381daa5b0cd960ccc5856ae42a0111781158f 100644 |
| --- a/chrome/browser/extensions/api/font_settings/font_settings_api.cc |
| +++ b/chrome/browser/extensions/api/font_settings/font_settings_api.cc |
| @@ -61,8 +61,8 @@ std::string GetFontNamePrefPath(fonts::GenericFamily generic_family_enum, |
| script = prefs::kWebKitCommonScript; |
| std::string generic_family = fonts::ToString(generic_family_enum); |
| return base::StringPrintf(kWebKitFontPrefFormat, |
| - generic_family.c_str(), |
| - script.c_str()); |
| + generic_family, |
| + script); |
| } |
| // Returns the localized name of a font so that it can be matched within the |
| @@ -84,10 +84,11 @@ void RegisterFontFamilyMapObserver( |
| PrefChangeRegistrar* registrar, |
| const char* map_name, |
| const PrefChangeRegistrar::NamedChangeCallback& callback) { |
| + std::string pref_name; |
|
Nico
2014/12/03 21:16:46
Now that I look at it again: This is unused.
|
| 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); |
|
Peter Kasting
2014/12/03 21:21:03
You're shadowing the outer variable with this inne
|
| - registrar->Add(pref_name.c_str(), callback); |
| + registrar->Add(pref_name, callback); |
|
Peter Kasting
2014/12/03 21:21:03
What's the perf of just doing:
registrar->Add(b
Georges Khalil
2014/12/03 21:58:32
Agreed, no impact on performance. Done. Hope that
|
| } |
| } |
| @@ -109,21 +110,21 @@ FontSettingsEventRouter::FontSettingsEventRouter( |
| PrefChangeRegistrar::NamedChangeCallback callback = |
| base::Bind(&FontSettingsEventRouter::OnFontFamilyMapPrefChanged, |
| - base::Unretained(this)); |
| - RegisterFontFamilyMapObserver(®istrar_, |
| - prefs::kWebKitStandardFontFamilyMap, callback); |
| - RegisterFontFamilyMapObserver(®istrar_, |
| - prefs::kWebKitSerifFontFamilyMap, callback); |
| - RegisterFontFamilyMapObserver(®istrar_, |
| - prefs::kWebKitSansSerifFontFamilyMap, callback); |
| - RegisterFontFamilyMapObserver(®istrar_, |
| - prefs::kWebKitFixedFontFamilyMap, callback); |
| - RegisterFontFamilyMapObserver(®istrar_, |
| - prefs::kWebKitCursiveFontFamilyMap, callback); |
| - RegisterFontFamilyMapObserver(®istrar_, |
| - prefs::kWebKitFantasyFontFamilyMap, callback); |
| - RegisterFontFamilyMapObserver(®istrar_, |
| - prefs::kWebKitPictographFontFamilyMap, |
| + base::Unretained(this)); |
| + RegisterFontFamilyMapObserver(®istrar_, |
| + prefs::kWebKitStandardFontFamilyMap, callback); |
| + RegisterFontFamilyMapObserver(®istrar_, |
| + prefs::kWebKitSerifFontFamilyMap, callback); |
| + RegisterFontFamilyMapObserver(®istrar_, |
| + prefs::kWebKitSansSerifFontFamilyMap, callback); |
| + RegisterFontFamilyMapObserver(®istrar_, |
| + prefs::kWebKitFixedFontFamilyMap, callback); |
| + RegisterFontFamilyMapObserver(®istrar_, |
| + prefs::kWebKitCursiveFontFamilyMap, callback); |
| + RegisterFontFamilyMapObserver(®istrar_, |
| + prefs::kWebKitFantasyFontFamilyMap, callback); |
| + RegisterFontFamilyMapObserver(®istrar_, |
| + prefs::kWebKitPictographFontFamilyMap, |
| callback); |
| } |
| @@ -156,7 +157,7 @@ void FontSettingsEventRouter::OnFontNamePrefChanged( |
| const std::string& generic_family, |
| const std::string& script) { |
| const PrefService::Preference* pref = registrar_.prefs()->FindPreference( |
| - pref_name.c_str()); |
| + pref_name); |
| CHECK(pref); |
| std::string font_name; |
| @@ -187,7 +188,7 @@ void FontSettingsEventRouter::OnFontPrefChanged( |
| const std::string& key, |
| const std::string& pref_name) { |
| const PrefService::Preference* pref = registrar_.prefs()->FindPreference( |
| - pref_name.c_str()); |
| + pref_name); |
| CHECK(pref); |
| base::ListValue args; |
| @@ -235,10 +236,10 @@ bool FontSettingsClearFontFunction::RunSync() { |
| // Ensure |pref_path| really is for a registered per-script font pref. |
| EXTENSION_FUNCTION_VALIDATE( |
| - GetProfile()->GetPrefs()->FindPreference(pref_path.c_str())); |
| + GetProfile()->GetPrefs()->FindPreference(pref_path)); |
| PreferenceAPI::Get(GetProfile())->RemoveExtensionControlledPref( |
| - extension_id(), pref_path.c_str(), kExtensionPrefsScopeRegular); |
| + extension_id(), pref_path, kExtensionPrefsScopeRegular); |
| return true; |
| } |
| @@ -252,7 +253,7 @@ bool FontSettingsGetFontFunction::RunSync() { |
| PrefService* prefs = GetProfile()->GetPrefs(); |
| const PrefService::Preference* pref = |
| - prefs->FindPreference(pref_path.c_str()); |
| + prefs->FindPreference(pref_path); |
| std::string font_name; |
| EXTENSION_FUNCTION_VALIDATE( |
| @@ -288,11 +289,11 @@ bool FontSettingsSetFontFunction::RunSync() { |
| // Ensure |pref_path| really is for a registered font pref. |
| EXTENSION_FUNCTION_VALIDATE( |
| - GetProfile()->GetPrefs()->FindPreference(pref_path.c_str())); |
| + GetProfile()->GetPrefs()->FindPreference(pref_path)); |
| PreferenceAPI::Get(GetProfile())->SetExtensionControlledPref( |
| extension_id(), |
| - pref_path.c_str(), |
| + pref_path, |
| kExtensionPrefsScopeRegular, |
| new base::StringValue(params->details.font_id)); |
| return true; |