summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/chrome_content_browser_client.cc15
-rw-r--r--chrome/browser/extensions/extension_font_settings_api.cc77
-rw-r--r--chrome/browser/extensions/extension_font_settings_apitest.cc4
-rw-r--r--chrome/browser/prefs/pref_service_unittest.cc3
-rw-r--r--chrome/browser/printing/cloud_print/cloud_print_setup_flow.cc4
-rw-r--r--chrome/browser/resources/options2/font_settings.html8
-rw-r--r--chrome/browser/ui/prefs/prefs_tab_helper.cc130
-rw-r--r--chrome/browser/ui/prefs/prefs_tab_helper_browsertest.cc105
-rw-r--r--chrome/browser/ui/webui/options2/font_settings_handler2.cc18
-rw-r--r--chrome/browser/ui/webui/options2/font_settings_utils2_mac.mm6
10 files changed, 216 insertions, 154 deletions
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index fad4f84..1c5efe5 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -305,7 +305,7 @@ void FillFontFamilyMap(const PrefService* prefs,
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->push_back(std::make_pair(script, UTF8ToUTF16(font_family)));
+ (*map)[script] = UTF8ToUTF16(font_family);
}
}
@@ -1334,19 +1334,6 @@ void ChromeContentBrowserClient::OverrideWebkitPrefs(
rvh->GetProcess()->GetBrowserContext());
PrefService* prefs = profile->GetPrefs();
- web_prefs->standard_font_family =
- UTF8ToUTF16(prefs->GetString(prefs::kWebKitGlobalStandardFontFamily));
- web_prefs->fixed_font_family =
- UTF8ToUTF16(prefs->GetString(prefs::kWebKitGlobalFixedFontFamily));
- web_prefs->serif_font_family =
- UTF8ToUTF16(prefs->GetString(prefs::kWebKitGlobalSerifFontFamily));
- web_prefs->sans_serif_font_family =
- UTF8ToUTF16(prefs->GetString(prefs::kWebKitGlobalSansSerifFontFamily));
- web_prefs->cursive_font_family =
- UTF8ToUTF16(prefs->GetString(prefs::kWebKitGlobalCursiveFontFamily));
- web_prefs->fantasy_font_family =
- UTF8ToUTF16(prefs->GetString(prefs::kWebKitGlobalFantasyFontFamily));
-
FillFontFamilyMap(prefs, prefs::kWebKitStandardFontFamilyMap,
&web_prefs->standard_font_family_map);
FillFontFamilyMap(prefs, prefs::kWebKitFixedFontFamilyMap,
diff --git a/chrome/browser/extensions/extension_font_settings_api.cc b/chrome/browser/extensions/extension_font_settings_api.cc
index 9d12154..6943745 100644
--- a/chrome/browser/extensions/extension_font_settings_api.cc
+++ b/chrome/browser/extensions/extension_font_settings_api.cc
@@ -50,20 +50,9 @@ const char kOnFontChanged[] = "experimental.fontSettings.onFontChanged";
const char kOnMinimumFontSizeChanged[] =
"experimental.fontSettings.onMinimumFontSizeChanged";
-// Format for per-script font preference keys.
-// E.g., "webkit.webprefs.fonts.standard.Hrkt"
-const char kWebKitPerScriptFontPrefFormat[] = "webkit.webprefs.fonts.%s.%s";
-const char kWebKitPerScriptFontPrefPrefix[] = "webkit.webprefs.fonts.";
-
-// Format for global (non per-script) font preference keys.
-// E.g., "webkit.webprefs.global.fixed_font_family"
-// Note: there are two meanings of "global" here. The "Global" in the const name
-// means "not per-script". The "global" in the key itself means "not per-tab"
-// (per-profile).
-const char kWebKitGlobalFontPrefFormat[] =
- "webkit.webprefs.global.%s_font_family";
-const char kWebKitGlobalFontPrefPrefix[] = "webkit.webprefs.global.";
-const char kWebKitGlobalFontPrefSuffix[] = "_font_family";
+// Format for font preference keys.
+const char kWebKitFontPrefFormat[] = "webkit.webprefs.fonts.%s.%s";
+const char kWebKitFontPrefPrefix[] = "webkit.webprefs.fonts.";
// Gets the font name preference path from |details| which contains key
// |kGenericFamilyKey| and optionally |kScriptKey|.
@@ -72,18 +61,14 @@ bool GetFontNamePrefPath(DictionaryValue* details, std::string* pref_path) {
if (!details->GetString(kGenericFamilyKey, &generic_family))
return false;
- if (details->HasKey(kScriptKey)) {
- std::string script;
- if (!details->GetString(kScriptKey, &script))
- return false;
- *pref_path = StringPrintf(kWebKitPerScriptFontPrefFormat,
- generic_family.c_str(),
- script.c_str());
- } else {
- *pref_path = StringPrintf(kWebKitGlobalFontPrefFormat,
- generic_family.c_str());
- }
-
+ std::string script;
+ if (!details->HasKey(kScriptKey))
+ script = prefs::kWebKitCommonScript;
+ else if (!details->GetString(kScriptKey, &script))
+ return false;
+ *pref_path = StringPrintf(kWebKitFontPrefFormat,
+ generic_family.c_str(),
+ script.c_str());
return true;
}
@@ -91,25 +76,16 @@ bool GetFontNamePrefPath(DictionaryValue* details, std::string* pref_path) {
bool ParseFontNamePrefPath(std::string pref_path,
std::string* generic_family,
std::string* script) {
- if (StartsWithASCII(pref_path, kWebKitPerScriptFontPrefPrefix, true)) {
- size_t start = strlen(kWebKitPerScriptFontPrefPrefix);
- size_t pos = pref_path.find('.', start);
- if (pos == std::string::npos || pos + 1 == pref_path.length())
- return false;
- *generic_family = pref_path.substr(start, pos - start);
- *script = pref_path.substr(pos + 1);
- return true;
- } else if (StartsWithASCII(pref_path, kWebKitGlobalFontPrefPrefix, true) &&
- EndsWith(pref_path, kWebKitGlobalFontPrefSuffix, true)) {
- size_t start = strlen(kWebKitGlobalFontPrefPrefix);
- size_t pos = pref_path.find('_', start);
- if (pos == std::string::npos || pos + 1 == pref_path.length())
- return false;
- *generic_family = pref_path.substr(start, pos - start);
- *script = "";
- return true;
- }
- return false;
+ if (!StartsWithASCII(pref_path, kWebKitFontPrefPrefix, true))
+ return false;
+
+ size_t start = strlen(kWebKitFontPrefPrefix);
+ size_t pos = pref_path.find('.', start);
+ if (pos == std::string::npos || pos + 1 == pref_path.length())
+ return false;
+ *generic_family = pref_path.substr(start, pos - start);
+ *script = pref_path.substr(pos + 1);
+ return true;
}
// Returns the localized name of a font so that it can be matched within the
@@ -160,12 +136,6 @@ void ExtensionFontSettingsEventRouter::Init() {
kOnDefaultCharacterSetChanged,
kCharsetKey);
- registrar_.Add(prefs::kWebKitGlobalStandardFontFamily, this);
- registrar_.Add(prefs::kWebKitGlobalSerifFontFamily, this);
- registrar_.Add(prefs::kWebKitGlobalSansSerifFontFamily, this);
- registrar_.Add(prefs::kWebKitGlobalFixedFontFamily, this);
- registrar_.Add(prefs::kWebKitGlobalCursiveFontFamily, this);
- registrar_.Add(prefs::kWebKitGlobalFantasyFontFamily, this);
RegisterFontFamilyMapObserver(&registrar_,
prefs::kWebKitStandardFontFamilyMap, this);
RegisterFontFamilyMapObserver(&registrar_,
@@ -244,8 +214,7 @@ void ExtensionFontSettingsEventRouter::OnFontNamePrefChanged(
args.Append(dict);
dict->SetString(kFontNameKey, font_name);
dict->SetString(kGenericFamilyKey, generic_family);
- if (!script.empty())
- dict->SetString(kScriptKey, script);
+ dict->SetString(kScriptKey, script);
extension_preference_helpers::DispatchEventToExtensions(
profile_,
@@ -350,7 +319,7 @@ bool SetFontFunction::RunImpl() {
std::string font_name;
EXTENSION_FUNCTION_VALIDATE(details->GetString(kFontNameKey, &font_name));
- // Ensure |pref_path| really is for a registered per-script font pref.
+ // Ensure |pref_path| really is for a registered font pref.
EXTENSION_FUNCTION_VALIDATE(
profile_->GetPrefs()->FindPreference(pref_path.c_str()));
diff --git a/chrome/browser/extensions/extension_font_settings_apitest.cc b/chrome/browser/extensions/extension_font_settings_apitest.cc
index 4ab7329..337c098 100644
--- a/chrome/browser/extensions/extension_font_settings_apitest.cc
+++ b/chrome/browser/extensions/extension_font_settings_apitest.cc
@@ -15,7 +15,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, FontSettings) {
PrefService* prefs = browser()->profile()->GetPrefs();
prefs->SetString(prefs::kWebKitStandardFontFamilyKorean, "Tahoma");
- prefs->SetString(prefs::kWebKitGlobalSansSerifFontFamily, "Arial");
+ prefs->SetString(prefs::kWebKitSansSerifFontFamily, "Arial");
prefs->SetInteger(prefs::kWebKitGlobalDefaultFontSize, 16);
prefs->SetInteger(prefs::kWebKitGlobalDefaultFixedFontSize, 14);
prefs->SetInteger(prefs::kWebKitGlobalMinimumFontSize, 8);
@@ -30,7 +30,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, FontSettingsIncognito) {
PrefService* prefs = browser()->profile()->GetPrefs();
prefs->SetString(prefs::kWebKitStandardFontFamilyKorean, "Tahoma");
- prefs->SetString(prefs::kWebKitGlobalSansSerifFontFamily, "Arial");
+ prefs->SetString(prefs::kWebKitSansSerifFontFamily, "Arial");
prefs->SetInteger(prefs::kWebKitGlobalDefaultFontSize, 16);
int flags = ExtensionApiTest::kFlagEnableIncognito |
diff --git a/chrome/browser/prefs/pref_service_unittest.cc b/chrome/browser/prefs/pref_service_unittest.cc
index ab3a62f..a685885 100644
--- a/chrome/browser/prefs/pref_service_unittest.cc
+++ b/chrome/browser/prefs/pref_service_unittest.cc
@@ -404,6 +404,7 @@ TEST_F(PrefServiceWebKitPrefs, PrefsCopied) {
#else
const char kDefaultFont[] = "Times New Roman";
#endif
- EXPECT_EQ(ASCIIToUTF16(kDefaultFont), webkit_prefs.standard_font_family);
+ EXPECT_EQ(ASCIIToUTF16(kDefaultFont),
+ webkit_prefs.standard_font_family_map[prefs::kWebKitCommonScript]);
EXPECT_TRUE(webkit_prefs.javascript_enabled);
}
diff --git a/chrome/browser/printing/cloud_print/cloud_print_setup_flow.cc b/chrome/browser/printing/cloud_print/cloud_print_setup_flow.cc
index f41c1e0..efabb80 100644
--- a/chrome/browser/printing/cloud_print/cloud_print_setup_flow.cc
+++ b/chrome/browser/printing/cloud_print/cloud_print_setup_flow.cc
@@ -133,7 +133,7 @@ void CloudPrintSetupFlow::GetWebUIMessageHandlers(
void CloudPrintSetupFlow::GetDialogSize(gfx::Size* size) const {
PrefService* prefs = profile_->GetPrefs();
gfx::Font approximate_web_font(
- prefs->GetString(prefs::kWebKitGlobalSansSerifFontFamily),
+ prefs->GetString(prefs::kWebKitSansSerifFontFamily),
prefs->GetInteger(prefs::kWebKitGlobalDefaultFontSize));
if (setup_done_) {
@@ -315,7 +315,7 @@ void CloudPrintSetupFlow::ShowSetupDone() {
if (web_ui_) {
PrefService* prefs = profile_->GetPrefs();
gfx::Font approximate_web_font(
- prefs->GetString(prefs::kWebKitGlobalSansSerifFontFamily),
+ prefs->GetString(prefs::kWebKitSansSerifFontFamily),
prefs->GetInteger(prefs::kWebKitGlobalDefaultFontSize));
gfx::Size done_size = ui::GetLocalizedContentsSizeForFont(
IDS_CLOUD_PRINT_SETUP_WIZARD_DONE_WIDTH_CHARS,
diff --git a/chrome/browser/resources/options2/font_settings.html b/chrome/browser/resources/options2/font_settings.html
index 23b03ef..c49795c 100644
--- a/chrome/browser/resources/options2/font_settings.html
+++ b/chrome/browser/resources/options2/font_settings.html
@@ -9,7 +9,7 @@
<div>
<select id="standard-font-family" class="font-input"
data-type="string" metric="Options_ChangeStandardFont"
- pref="webkit.webprefs.global.standard_font_family">
+ pref="webkit.webprefs.fonts.standard.Zyyy">
</select>
</div>
<div>
@@ -32,7 +32,7 @@
<div class="font-input-div">
<div>
<select id="serif-font-family" class="font-input" data-type="string"
- pref="webkit.webprefs.global.serif_font_family"
+ pref="webkit.webprefs.fonts.serif.Zyyy"
metric="Options_ChangeSerifFont">
</select>
</div>
@@ -47,7 +47,7 @@
<div>
<select id="sans-serif-font-family" class="font-input"
data-type="string" metric="Options_ChangeSansSerifFont"
- pref="webkit.webprefs.global.sansserif_font_family">
+ pref="webkit.webprefs.fonts.sansserif.Zyyy">
</select>
</div>
</div>
@@ -60,7 +60,7 @@
<div class="font-input-div">
<div>
<select id="fixed-font-family" class="font-input" data-type="string"
- pref="webkit.webprefs.global.fixed_font_family"
+ pref="webkit.webprefs.fonts.fixed.Zyyy"
metric="Options_ChangeFixedFont">
</select>
</div>
diff --git a/chrome/browser/ui/prefs/prefs_tab_helper.cc b/chrome/browser/ui/prefs/prefs_tab_helper.cc
index 65b58ad..2e19ecc 100644
--- a/chrome/browser/ui/prefs/prefs_tab_helper.cc
+++ b/chrome/browser/ui/prefs/prefs_tab_helper.cc
@@ -36,24 +36,6 @@ static void RegisterFontsAndCharsetPrefs(PrefService* prefs) {
prefs->RegisterLocalizedStringPref(prefs::kDefaultCharset,
IDS_DEFAULT_ENCODING,
PrefService::SYNCABLE_PREF);
- prefs->RegisterLocalizedStringPref(prefs::kWebKitStandardFontFamily,
- IDS_STANDARD_FONT_FAMILY,
- PrefService::UNSYNCABLE_PREF);
- prefs->RegisterLocalizedStringPref(prefs::kWebKitFixedFontFamily,
- IDS_FIXED_FONT_FAMILY,
- PrefService::UNSYNCABLE_PREF);
- prefs->RegisterLocalizedStringPref(prefs::kWebKitSerifFontFamily,
- IDS_SERIF_FONT_FAMILY,
- PrefService::UNSYNCABLE_PREF);
- prefs->RegisterLocalizedStringPref(prefs::kWebKitSansSerifFontFamily,
- IDS_SANS_SERIF_FONT_FAMILY,
- PrefService::UNSYNCABLE_PREF);
- prefs->RegisterLocalizedStringPref(prefs::kWebKitCursiveFontFamily,
- IDS_CURSIVE_FONT_FAMILY,
- PrefService::UNSYNCABLE_PREF);
- prefs->RegisterLocalizedStringPref(prefs::kWebKitFantasyFontFamily,
- IDS_FANTASY_FONT_FAMILY,
- PrefService::UNSYNCABLE_PREF);
prefs->RegisterLocalizedIntegerPref(prefs::kWebKitDefaultFontSize,
IDS_DEFAULT_FONT_SIZE,
PrefService::UNSYNCABLE_PREF);
@@ -66,6 +48,44 @@ static void RegisterFontsAndCharsetPrefs(PrefService* prefs) {
prefs->RegisterLocalizedIntegerPref(prefs::kWebKitMinimumLogicalFontSize,
IDS_MINIMUM_LOGICAL_FONT_SIZE,
PrefService::UNSYNCABLE_PREF);
+
+ // These are only registered to be used in migration.
+ prefs->RegisterLocalizedStringPref(prefs::kWebKitOldStandardFontFamily,
+ IDS_STANDARD_FONT_FAMILY,
+ PrefService::UNSYNCABLE_PREF);
+ prefs->RegisterLocalizedStringPref(prefs::kWebKitOldFixedFontFamily,
+ IDS_FIXED_FONT_FAMILY,
+ PrefService::UNSYNCABLE_PREF);
+ prefs->RegisterLocalizedStringPref(prefs::kWebKitOldSerifFontFamily,
+ IDS_SERIF_FONT_FAMILY,
+ PrefService::UNSYNCABLE_PREF);
+ prefs->RegisterLocalizedStringPref(prefs::kWebKitOldSansSerifFontFamily,
+ IDS_SANS_SERIF_FONT_FAMILY,
+ PrefService::UNSYNCABLE_PREF);
+ prefs->RegisterLocalizedStringPref(prefs::kWebKitOldCursiveFontFamily,
+ IDS_CURSIVE_FONT_FAMILY,
+ PrefService::UNSYNCABLE_PREF);
+ prefs->RegisterLocalizedStringPref(prefs::kWebKitOldFantasyFontFamily,
+ IDS_FANTASY_FONT_FAMILY,
+ PrefService::UNSYNCABLE_PREF);
+ prefs->RegisterLocalizedStringPref(prefs::kWebKitGlobalStandardFontFamily,
+ IDS_STANDARD_FONT_FAMILY,
+ PrefService::UNSYNCABLE_PREF);
+ prefs->RegisterLocalizedStringPref(prefs::kWebKitGlobalFixedFontFamily,
+ IDS_FIXED_FONT_FAMILY,
+ PrefService::UNSYNCABLE_PREF);
+ prefs->RegisterLocalizedStringPref(prefs::kWebKitGlobalSerifFontFamily,
+ IDS_SERIF_FONT_FAMILY,
+ PrefService::UNSYNCABLE_PREF);
+ prefs->RegisterLocalizedStringPref(prefs::kWebKitGlobalSansSerifFontFamily,
+ IDS_SANS_SERIF_FONT_FAMILY,
+ PrefService::UNSYNCABLE_PREF);
+ prefs->RegisterLocalizedStringPref(prefs::kWebKitGlobalCursiveFontFamily,
+ IDS_CURSIVE_FONT_FAMILY,
+ PrefService::UNSYNCABLE_PREF);
+ prefs->RegisterLocalizedStringPref(prefs::kWebKitGlobalFantasyFontFamily,
+ IDS_FANTASY_FONT_FAMILY,
+ PrefService::UNSYNCABLE_PREF);
}
// The list of prefs we want to observe.
@@ -75,20 +95,14 @@ const char* kPrefsToObserve[] = {
prefs::kEnableReferrers,
prefs::kWebKitAllowDisplayingInsecureContent,
prefs::kWebKitAllowRunningInsecureContent,
- prefs::kWebKitGlobalCursiveFontFamily,
prefs::kWebKitGlobalDefaultFixedFontSize,
prefs::kWebKitGlobalDefaultFontSize,
- prefs::kWebKitGlobalFantasyFontFamily,
- prefs::kWebKitGlobalFixedFontFamily,
prefs::kWebKitGlobalJavascriptEnabled,
prefs::kWebKitJavaEnabled,
prefs::kWebKitGlobalLoadsImagesAutomatically,
prefs::kWebKitGlobalMinimumFontSize,
prefs::kWebKitGlobalMinimumLogicalFontSize,
prefs::kWebKitGlobalPluginsEnabled,
- prefs::kWebKitGlobalSansSerifFontFamily,
- prefs::kWebKitGlobalSerifFontFamily,
- prefs::kWebKitGlobalStandardFontFamily,
prefs::kWebkitTabsToLinks,
prefs::kWebKitUsesUniversalDetector
};
@@ -243,26 +257,51 @@ const struct {
} kPrefNamesToMigrate[] = {
{ prefs::kDefaultCharset,
prefs::kGlobalDefaultCharset },
- { prefs::kWebKitCursiveFontFamily,
- prefs::kWebKitGlobalCursiveFontFamily },
{ prefs::kWebKitDefaultFixedFontSize,
prefs::kWebKitGlobalDefaultFixedFontSize },
{ prefs::kWebKitDefaultFontSize,
prefs::kWebKitGlobalDefaultFontSize },
- { prefs::kWebKitFantasyFontFamily,
- prefs::kWebKitGlobalFantasyFontFamily },
- { prefs::kWebKitFixedFontFamily,
- prefs::kWebKitGlobalFixedFontFamily },
{ prefs::kWebKitMinimumFontSize,
prefs::kWebKitGlobalMinimumFontSize },
{ prefs::kWebKitMinimumLogicalFontSize,
prefs::kWebKitGlobalMinimumLogicalFontSize },
- { prefs::kWebKitSansSerifFontFamily,
- prefs::kWebKitGlobalSansSerifFontFamily },
- { prefs::kWebKitSerifFontFamily,
- prefs::kWebKitGlobalSerifFontFamily },
- { prefs::kWebKitStandardFontFamily,
- prefs::kWebKitGlobalStandardFontFamily },
+
+ // Migrate prefs like "webkit.webprefs.standard_font_family" to
+ // "webkit.webprefs.fonts.standard.Zyyy". This moves the formerly
+ // "non-per-script" font prefs into the per-script font pref maps, as the
+ // entry for the "Common" script (Zyyy is the ISO 15924 script code for the
+ // Common script). The |from| prefs will exist if the migration to global
+ // prefs (for the per-tab pref mechanism, which has since been removed) never
+ // occurred.
+ { prefs::kWebKitOldCursiveFontFamily,
+ prefs::kWebKitCursiveFontFamily },
+ { prefs::kWebKitOldFantasyFontFamily,
+ prefs::kWebKitFantasyFontFamily },
+ { prefs::kWebKitOldFixedFontFamily,
+ prefs::kWebKitFixedFontFamily },
+ { prefs::kWebKitOldSansSerifFontFamily,
+ prefs::kWebKitSansSerifFontFamily },
+ { prefs::kWebKitOldSerifFontFamily,
+ prefs::kWebKitSerifFontFamily },
+ { prefs::kWebKitOldStandardFontFamily,
+ prefs::kWebKitStandardFontFamily },
+
+ // Migrate "global" prefs. These will exist if the migration to global prefs
+ // (for the per-tab pref mechanism, which has since been removed) occurred.
+ // In addition, this moves the formerly "non-per-script" font prefs into the
+ // per-script font pref maps, as above.
+ { prefs::kWebKitGlobalCursiveFontFamily,
+ prefs::kWebKitCursiveFontFamily },
+ { prefs::kWebKitGlobalFantasyFontFamily,
+ prefs::kWebKitFantasyFontFamily },
+ { prefs::kWebKitGlobalFixedFontFamily,
+ prefs::kWebKitFixedFontFamily },
+ { prefs::kWebKitGlobalSansSerifFontFamily,
+ prefs::kWebKitSansSerifFontFamily },
+ { prefs::kWebKitGlobalSerifFontFamily,
+ prefs::kWebKitSerifFontFamily },
+ { prefs::kWebKitGlobalStandardFontFamily,
+ prefs::kWebKitStandardFontFamily }
};
const int kPrefsToMigrateLength = ARRAYSIZE_UNSAFE(kPrefNamesToMigrate);
@@ -385,22 +424,22 @@ void PrefsTabHelper::RegisterUserPrefs(PrefService* prefs) {
prefs->RegisterLocalizedStringPref(prefs::kGlobalDefaultCharset,
IDS_DEFAULT_ENCODING,
PrefService::SYNCABLE_PREF);
- prefs->RegisterLocalizedStringPref(prefs::kWebKitGlobalStandardFontFamily,
+ prefs->RegisterLocalizedStringPref(prefs::kWebKitStandardFontFamily,
IDS_STANDARD_FONT_FAMILY,
PrefService::UNSYNCABLE_PREF);
- prefs->RegisterLocalizedStringPref(prefs::kWebKitGlobalFixedFontFamily,
+ prefs->RegisterLocalizedStringPref(prefs::kWebKitFixedFontFamily,
IDS_FIXED_FONT_FAMILY,
PrefService::UNSYNCABLE_PREF);
- prefs->RegisterLocalizedStringPref(prefs::kWebKitGlobalSerifFontFamily,
+ prefs->RegisterLocalizedStringPref(prefs::kWebKitSerifFontFamily,
IDS_SERIF_FONT_FAMILY,
PrefService::UNSYNCABLE_PREF);
- prefs->RegisterLocalizedStringPref(prefs::kWebKitGlobalSansSerifFontFamily,
+ prefs->RegisterLocalizedStringPref(prefs::kWebKitSansSerifFontFamily,
IDS_SANS_SERIF_FONT_FAMILY,
PrefService::UNSYNCABLE_PREF);
- prefs->RegisterLocalizedStringPref(prefs::kWebKitGlobalCursiveFontFamily,
+ prefs->RegisterLocalizedStringPref(prefs::kWebKitCursiveFontFamily,
IDS_CURSIVE_FONT_FAMILY,
PrefService::UNSYNCABLE_PREF);
- prefs->RegisterLocalizedStringPref(prefs::kWebKitGlobalFantasyFontFamily,
+ prefs->RegisterLocalizedStringPref(prefs::kWebKitFantasyFontFamily,
IDS_FANTASY_FONT_FAMILY,
PrefService::UNSYNCABLE_PREF);
@@ -413,8 +452,11 @@ void PrefsTabHelper::RegisterUserPrefs(PrefService* prefs) {
const PerScriptFontDefault& pref = kPerScriptFontDefaults[i];
// Suppress default per-script font when the script matches the browser's
// locale. Otherwise, the default would override the user's preferences
- // when viewing pages in their native language. This can be removed when
- // per-script fonts are added to Preferences UI.
+ // when viewing pages in their native language. This would be bad
+ // particularly because there is not yet a way for users to customize
+ // their per-script font prefs. This code can possibly be removed later if
+ // users can easily access per-script font prefs (e.g., via the extensions
+ // workflow), or the problem turns out to not be really critical after all.
if (!StartsWithASCII(locale, pref.native_locale, false)) {
prefs->RegisterLocalizedStringPref(pref.pref_name,
pref.resource_id,
diff --git a/chrome/browser/ui/prefs/prefs_tab_helper_browsertest.cc b/chrome/browser/ui/prefs/prefs_tab_helper_browsertest.cc
index 890a33a..ba7a54f 100644
--- a/chrome/browser/ui/prefs/prefs_tab_helper_browsertest.cc
+++ b/chrome/browser/ui/prefs/prefs_tab_helper_browsertest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -14,9 +14,17 @@
class PrefsTabHelperBrowserTest : public InProcessBrowserTest {
protected:
- virtual bool SetUpUserDataDirectory() OVERRIDE {
+ virtual FilePath GetPreferencesFilePath() {
FilePath test_data_directory;
PathService::Get(chrome::DIR_TEST_DATA, &test_data_directory);
+ return test_data_directory
+ .AppendASCII("profiles")
+ .AppendASCII("webkit_global_migration")
+ .AppendASCII("Default")
+ .Append(chrome::kPreferencesFilename);
+ }
+
+ virtual bool SetUpUserDataDirectory() OVERRIDE {
FilePath user_data_directory;
PathService::Get(chrome::DIR_USER_DATA, &user_data_directory);
FilePath default_profile = user_data_directory.AppendASCII("Default");
@@ -24,12 +32,7 @@ class PrefsTabHelperBrowserTest : public InProcessBrowserTest {
LOG(ERROR) << "Can't create " << default_profile.MaybeAsASCII();
return false;
}
- FilePath non_global_pref_file;
- non_global_pref_file = test_data_directory
- .AppendASCII("profiles")
- .AppendASCII("webkit_global_migration")
- .AppendASCII("Default")
- .Append(chrome::kPreferencesFilename);
+ FilePath non_global_pref_file = GetPreferencesFilePath();
if (!file_util::PathExists(non_global_pref_file)) {
LOG(ERROR) << "Doesn't exist " << non_global_pref_file.MaybeAsASCII();
return false;
@@ -52,6 +55,10 @@ class PrefsTabHelperBrowserTest : public InProcessBrowserTest {
}
};
+// This tests migration like:
+// webkit.webprefs.default_charset -> webkit.webprefs.global.default_charset
+// This was needed for per-tab prefs, which have since been removed. So
+// eventually this migration will be replaced with the reverse migration.
IN_PROC_BROWSER_TEST_F(PrefsTabHelperBrowserTest, NonGlobalPrefsAreMigrated) {
PrefService* prefs = browser()->profile()->GetPrefs();
@@ -60,12 +67,6 @@ IN_PROC_BROWSER_TEST_F(PrefsTabHelperBrowserTest, NonGlobalPrefsAreMigrated) {
EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitDefaultFixedFontSize));
EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitMinimumFontSize));
EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitMinimumLogicalFontSize));
- EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitCursiveFontFamily));
- EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitFantasyFontFamily));
- EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitFixedFontFamily));
- EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitSansSerifFontFamily));
- EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitSerifFontFamily));
- EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitStandardFontFamily));
EXPECT_EQ("ISO-8859-1", prefs->GetString(prefs::kGlobalDefaultCharset));
EXPECT_EQ(42, prefs->GetInteger(prefs::kWebKitGlobalDefaultFontSize));
@@ -74,16 +75,78 @@ IN_PROC_BROWSER_TEST_F(PrefsTabHelperBrowserTest, NonGlobalPrefsAreMigrated) {
EXPECT_EQ(42, prefs->GetInteger(prefs::kWebKitGlobalMinimumFontSize));
EXPECT_EQ(42,
prefs->GetInteger(prefs::kWebKitGlobalMinimumLogicalFontSize));
+};
+
+// This tests migration like:
+// webkit.webprefs.standard_font_family -> webkit.webprefs.fonts.standard.Zyyy
+// This migration moves the formerly "non-per-script" font prefs into the
+// per-script font maps, as the entry for "Common" script (Zyyy is the ISO 15924
+// script code for the Common script).
+IN_PROC_BROWSER_TEST_F(PrefsTabHelperBrowserTest, PrefsAreMigratedToFontMap) {
+ PrefService* prefs = browser()->profile()->GetPrefs();
+
+ EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitOldCursiveFontFamily));
+ EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitOldFantasyFontFamily));
+ EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitOldFixedFontFamily));
+ EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitOldSansSerifFontFamily));
+ EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitOldSerifFontFamily));
+ EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitOldStandardFontFamily));
EXPECT_EQ("CursiveFontFamily",
- prefs->GetString(prefs::kWebKitGlobalCursiveFontFamily));
+ prefs->GetString(prefs::kWebKitCursiveFontFamily));
EXPECT_EQ("FantasyFontFamily",
- prefs->GetString(prefs::kWebKitGlobalFantasyFontFamily));
+ prefs->GetString(prefs::kWebKitFantasyFontFamily));
EXPECT_EQ("FixedFontFamily",
- prefs->GetString(prefs::kWebKitGlobalFixedFontFamily));
+ prefs->GetString(prefs::kWebKitFixedFontFamily));
EXPECT_EQ("SansSerifFontFamily",
- prefs->GetString(prefs::kWebKitGlobalSansSerifFontFamily));
+ prefs->GetString(prefs::kWebKitSansSerifFontFamily));
EXPECT_EQ("SerifFontFamily",
- prefs->GetString(prefs::kWebKitGlobalSerifFontFamily));
+ prefs->GetString(prefs::kWebKitSerifFontFamily));
EXPECT_EQ("StandardFontFamily",
- prefs->GetString(prefs::kWebKitGlobalStandardFontFamily));
-}
+ prefs->GetString(prefs::kWebKitStandardFontFamily));
+};
+
+class PrefsTabHelperBrowserTest2 : public PrefsTabHelperBrowserTest {
+ protected:
+ virtual FilePath GetPreferencesFilePath() OVERRIDE {
+ FilePath test_data_directory;
+ PathService::Get(chrome::DIR_TEST_DATA, &test_data_directory);
+ return test_data_directory
+ .AppendASCII("profiles")
+ .AppendASCII("webkit_global_reverse_migration")
+ .AppendASCII("Default")
+ .Append(chrome::kPreferencesFilename);
+ }
+};
+
+// This tests migration like:
+// webkit.webprefs.global.standard_font_family ->
+// webkit.webprefs.fonts.standard.Zyyy
+// This undoes the migration to "global" names (originally done for the per-tab
+// pref mechanism, which has since been removed). In addition, it moves the
+// formerly "non-per-script" font prefs into the per-script font maps, as
+// described in the comment for PrefsAreMigratedToFontMap.
+IN_PROC_BROWSER_TEST_F(PrefsTabHelperBrowserTest2, GlobalPrefsAreMigrated) {
+ PrefService* prefs = browser()->profile()->GetPrefs();
+
+ EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitGlobalCursiveFontFamily));
+ EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitGlobalFantasyFontFamily));
+ EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitGlobalFixedFontFamily));
+ EXPECT_EQ(NULL,
+ prefs->FindPreference(prefs::kWebKitGlobalSansSerifFontFamily));
+ EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitGlobalSerifFontFamily));
+ EXPECT_EQ(NULL,
+ prefs->FindPreference(prefs::kWebKitGlobalStandardFontFamily));
+
+ EXPECT_EQ("CursiveFontFamily",
+ prefs->GetString(prefs::kWebKitCursiveFontFamily));
+ EXPECT_EQ("FantasyFontFamily",
+ prefs->GetString(prefs::kWebKitFantasyFontFamily));
+ EXPECT_EQ("FixedFontFamily",
+ prefs->GetString(prefs::kWebKitFixedFontFamily));
+ EXPECT_EQ("SansSerifFontFamily",
+ prefs->GetString(prefs::kWebKitSansSerifFontFamily));
+ EXPECT_EQ("SerifFontFamily",
+ prefs->GetString(prefs::kWebKitSerifFontFamily));
+ EXPECT_EQ("StandardFontFamily",
+ prefs->GetString(prefs::kWebKitStandardFontFamily));
+};
diff --git a/chrome/browser/ui/webui/options2/font_settings_handler2.cc b/chrome/browser/ui/webui/options2/font_settings_handler2.cc
index 1fc18fc..338f285 100644
--- a/chrome/browser/ui/webui/options2/font_settings_handler2.cc
+++ b/chrome/browser/ui/webui/options2/font_settings_handler2.cc
@@ -106,12 +106,12 @@ void FontSettingsHandler::RegisterMessages() {
FontSettingsUtilities::ValidateSavedFonts(pref_service);
// Register for preferences that we need to observe manually.
- standard_font_.Init(prefs::kWebKitGlobalStandardFontFamily,
+ standard_font_.Init(prefs::kWebKitStandardFontFamily,
pref_service, this);
- serif_font_.Init(prefs::kWebKitGlobalSerifFontFamily, pref_service, this);
- sans_serif_font_.Init(prefs::kWebKitGlobalSansSerifFontFamily,
+ serif_font_.Init(prefs::kWebKitSerifFontFamily, pref_service, this);
+ sans_serif_font_.Init(prefs::kWebKitSansSerifFontFamily,
pref_service, this);
- fixed_font_.Init(prefs::kWebKitGlobalFixedFontFamily, pref_service, this);
+ fixed_font_.Init(prefs::kWebKitFixedFontFamily, pref_service, this);
font_encoding_.Init(prefs::kGlobalDefaultCharset, pref_service, this);
default_font_size_.Init(prefs::kWebKitGlobalDefaultFontSize,
pref_service, this);
@@ -196,14 +196,14 @@ void FontSettingsHandler::Observe(int type,
const content::NotificationDetails& details) {
if (type == chrome::NOTIFICATION_PREF_CHANGED) {
std::string* pref_name = content::Details<std::string>(details).ptr();
- if (*pref_name == prefs::kWebKitGlobalStandardFontFamily) {
+ if (*pref_name == prefs::kWebKitStandardFontFamily) {
SetUpStandardFontSample();
- } else if (*pref_name == prefs::kWebKitGlobalSerifFontFamily) {
+ } else if (*pref_name == prefs::kWebKitSerifFontFamily) {
SetUpSerifFontSample();
- } else if (*pref_name == prefs::kWebKitGlobalSansSerifFontFamily) {
+ } else if (*pref_name == prefs::kWebKitSansSerifFontFamily) {
SetUpSansSerifFontSample();
- } else if (*pref_name == prefs::kWebKitGlobalFixedFontFamily ||
- *pref_name == prefs::kWebKitGlobalDefaultFixedFontSize) {
+ } else if (*pref_name == prefs::kWebKitFixedFontFamily ||
+ *pref_name == prefs::kWebKitDefaultFixedFontSize) {
SetUpFixedFontSample();
} else if (*pref_name == prefs::kWebKitGlobalDefaultFontSize) {
SetUpStandardFontSample();
diff --git a/chrome/browser/ui/webui/options2/font_settings_utils2_mac.mm b/chrome/browser/ui/webui/options2/font_settings_utils2_mac.mm
index 1f96b9b..888fd6e 100644
--- a/chrome/browser/ui/webui/options2/font_settings_utils2_mac.mm
+++ b/chrome/browser/ui/webui/options2/font_settings_utils2_mac.mm
@@ -34,9 +34,9 @@ static void ValidateFontFamily(PrefService* prefs,
// static
void FontSettingsUtilities::ValidateSavedFonts(PrefService* prefs) {
- ValidateFontFamily(prefs, prefs::kWebKitGlobalSerifFontFamily);
- ValidateFontFamily(prefs, prefs::kWebKitGlobalSansSerifFontFamily);
- ValidateFontFamily(prefs, prefs::kWebKitGlobalFixedFontFamily);
+ ValidateFontFamily(prefs, prefs::kWebKitSerifFontFamily);
+ ValidateFontFamily(prefs, prefs::kWebKitSansSerifFontFamily);
+ ValidateFontFamily(prefs, prefs::kWebKitFixedFontFamily);
}
} // namespace options2