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 538760897ec27eea4f920598c1a711750ace011f..d6de9f44725db5ae489660d6fd6e0da71c1af8e4 100644 |
| --- a/chrome/browser/extensions/api/font_settings/font_settings_api.cc |
| +++ b/chrome/browser/extensions/api/font_settings/font_settings_api.cc |
| @@ -59,11 +59,19 @@ const char kWebKitFontPrefPrefix[] = "webkit.webprefs.fonts."; |
| // Gets the font name preference path for |generic_family| and |script|. If |
| // |script| is NULL, uses prefs::kWebKitCommonScript. |
| -std::string GetFontNamePrefPath(const std::string& generic_family, |
| - const std::string* script) { |
| +std::string GetFontNamePrefPath(fonts::GenericFamily generic_family_enum, |
| + fonts::ScriptCode script_enum) { |
| + std::string script; |
| + scoped_ptr<Value> script_value = fonts::CreateEnumValue(script_enum); |
| + if (script_value.get()) |
| + script_value->GetAsString(&script); |
|
not at google - send to devlin
2012/09/14 01:44:51
etc
cduvall
2012/09/17 22:07:46
Done.
|
| + else |
| + script = prefs::kWebKitCommonScript; |
| + std::string generic_family; |
| + fonts::CreateEnumValue(generic_family_enum)->GetAsString(&generic_family); |
| return StringPrintf(kWebKitFontPrefFormat, |
| generic_family.c_str(), |
| - script ? script->c_str() : prefs::kWebKitCommonScript); |
| + script.c_str()); |
| } |
| // Extracts the generic family and script from font name pref path |pref_path|. |
| @@ -251,7 +259,7 @@ bool ClearFontFunction::RunImpl() { |
| EXTENSION_FUNCTION_VALIDATE(params.get()); |
| std::string pref_path = GetFontNamePrefPath(params->details.generic_family, |
| - params->details.script.get()); |
| + params->details.script); |
| // Ensure |pref_path| really is for a registered per-script font pref. |
| EXTENSION_FUNCTION_VALIDATE( |
| @@ -270,7 +278,8 @@ bool GetFontFunction::RunImpl() { |
| EXTENSION_FUNCTION_VALIDATE(params.get()); |
| std::string pref_path = GetFontNamePrefPath(params->details.generic_family, |
| - params->details.script.get()); |
| + params->details.script); |
| + |
| PrefService* prefs = profile_->GetPrefs(); |
| const PrefService::Preference* pref = |
| prefs->FindPreference(pref_path.c_str()); |
| @@ -307,7 +316,8 @@ bool SetFontFunction::RunImpl() { |
| EXTENSION_FUNCTION_VALIDATE(params.get()); |
| std::string pref_path = GetFontNamePrefPath(params->details.generic_family, |
| - params->details.script.get()); |
| + params->details.script); |
| + |
| // Ensure |pref_path| really is for a registered font pref. |
| EXTENSION_FUNCTION_VALIDATE( |
| profile_->GetPrefs()->FindPreference(pref_path.c_str())); |