Chromium Code Reviews| Index: chrome/browser/chrome_content_browser_client.cc |
| diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc |
| index 87b4810c84496bca98e654eca78011517dbd2d77..06dc881fa8da453b7e06c5997304a56155b2a605 100644 |
| --- a/chrome/browser/chrome_content_browser_client.cc |
| +++ b/chrome/browser/chrome_content_browser_client.cc |
| @@ -39,6 +39,7 @@ |
| #include "chrome/browser/extensions/extension_web_ui.h" |
| #include "chrome/browser/extensions/extension_webkit_preferences.h" |
| #include "chrome/browser/extensions/suggest_permission_util.h" |
| +#include "chrome/browser/font_family_cache.h" |
| #include "chrome/browser/geolocation/chrome_access_token_store.h" |
| #include "chrome/browser/geolocation/geolocation_permission_context.h" |
| #include "chrome/browser/geolocation/geolocation_permission_context_factory.h" |
| @@ -502,19 +503,19 @@ bool CertMatchesFilter(const net::X509Certificate& cert, |
| } |
| #if !defined(OS_ANDROID) |
| -// Fills |map| with the per-script font prefs under path |map_name|. |
| -void FillFontFamilyMap(const PrefService* prefs, |
| +void FillFontFamilyMap(Profile* profile, |
| const char* map_name, |
| content::ScriptFontFamilyMap* map) { |
| - // TODO(falken): Get rid of the brute-force scan over possible |
| - // (font family / script) combinations - see http://crbug.com/308095. |
| - 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); |
| - std::string font_family = prefs->GetString(pref_name.c_str()); |
| - if (!font_family.empty()) |
| - (*map)[script] = base::UTF8ToUTF16(font_family); |
| + chrome::FontFamilyCache* cache = static_cast<chrome::FontFamilyCache*>( |
| + profile->GetUserData(&chrome::kFontFamilyCacheKey)); |
| + if (!cache) { |
| + PrefService* prefs = profile->GetPrefs(); |
| + cache = new chrome::FontFamilyCache(prefs); |
| + // The profile takes ownership of |cache|. |
| + profile->SetUserData(&chrome::kFontFamilyCacheKey, cache); |
|
Avi (use Gerrit)
2014/08/05 18:07:36
And you set it on the BrowserContext, which is alr
|
| } |
| + |
| + cache->FillFontFamilyMap(map_name, map); |
| } |
| #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| @@ -2423,19 +2424,19 @@ void ChromeContentBrowserClient::OverrideWebkitPrefs( |
| // Fill per-script font preferences. These are not registered on Android |
| // - http://crbug.com/308033. |
| #if !defined(OS_ANDROID) |
| - FillFontFamilyMap(prefs, prefs::kWebKitStandardFontFamilyMap, |
| + FillFontFamilyMap(profile, prefs::kWebKitStandardFontFamilyMap, |
| &web_prefs->standard_font_family_map); |
| - FillFontFamilyMap(prefs, prefs::kWebKitFixedFontFamilyMap, |
| + FillFontFamilyMap(profile, prefs::kWebKitFixedFontFamilyMap, |
| &web_prefs->fixed_font_family_map); |
| - FillFontFamilyMap(prefs, prefs::kWebKitSerifFontFamilyMap, |
| + FillFontFamilyMap(profile, prefs::kWebKitSerifFontFamilyMap, |
| &web_prefs->serif_font_family_map); |
| - FillFontFamilyMap(prefs, prefs::kWebKitSansSerifFontFamilyMap, |
| + FillFontFamilyMap(profile, prefs::kWebKitSansSerifFontFamilyMap, |
| &web_prefs->sans_serif_font_family_map); |
| - FillFontFamilyMap(prefs, prefs::kWebKitCursiveFontFamilyMap, |
| + FillFontFamilyMap(profile, prefs::kWebKitCursiveFontFamilyMap, |
| &web_prefs->cursive_font_family_map); |
| - FillFontFamilyMap(prefs, prefs::kWebKitFantasyFontFamilyMap, |
| + FillFontFamilyMap(profile, prefs::kWebKitFantasyFontFamilyMap, |
| &web_prefs->fantasy_font_family_map); |
| - FillFontFamilyMap(prefs, prefs::kWebKitPictographFontFamilyMap, |
| + FillFontFamilyMap(profile, prefs::kWebKitPictographFontFamilyMap, |
| &web_prefs->pictograph_font_family_map); |
| #endif |