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

Side by Side Diff: chrome/browser/ui/prefs/prefs_tab_helper.cc

Issue 27527003: Skip per-script font preferences registration and filling on Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address falken's remark. Created 7 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/chrome_content_browser_client.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/prefs/prefs_tab_helper.h" 5 #include "chrome/browser/ui/prefs/prefs_tab_helper.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/prefs/overlay_user_pref_store.h" 9 #include "base/prefs/overlay_user_pref_store.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 prefs::kWebKitLoadsImagesAutomatically, 131 prefs::kWebKitLoadsImagesAutomatically,
132 prefs::kWebKitMinimumFontSize, 132 prefs::kWebKitMinimumFontSize,
133 prefs::kWebKitMinimumLogicalFontSize, 133 prefs::kWebKitMinimumLogicalFontSize,
134 prefs::kWebKitPluginsEnabled, 134 prefs::kWebKitPluginsEnabled,
135 prefs::kWebkitTabsToLinks, 135 prefs::kWebkitTabsToLinks,
136 prefs::kWebKitUsesUniversalDetector 136 prefs::kWebKitUsesUniversalDetector
137 }; 137 };
138 138
139 const int kPrefsToObserveLength = arraysize(kPrefsToObserve); 139 const int kPrefsToObserveLength = arraysize(kPrefsToObserve);
140 140
141 #if !defined(OS_ANDROID)
141 // Registers a preference under the path |pref_name| for each script used for 142 // Registers a preference under the path |pref_name| for each script used for
142 // per-script font prefs. 143 // per-script font prefs.
143 // For example, for WEBKIT_WEBPREFS_FONTS_SERIF ("fonts.serif"): 144 // For example, for WEBKIT_WEBPREFS_FONTS_SERIF ("fonts.serif"):
144 // "fonts.serif.Arab", "fonts.serif.Hang", etc. are registered. 145 // "fonts.serif.Arab", "fonts.serif.Hang", etc. are registered.
145 // |fonts_with_defaults| contains all |pref_names| already registered since they 146 // |fonts_with_defaults| contains all |pref_names| already registered since they
146 // have a specified default value. 147 // have a specified default value.
148 // On Android there are no default values for these properties and there is no
149 // way to set them (because extensions are not supported so the Font Settings
150 // API cannot be used), so we can avoid registering them altogether.
147 void RegisterFontFamilyPrefs(user_prefs::PrefRegistrySyncable* registry, 151 void RegisterFontFamilyPrefs(user_prefs::PrefRegistrySyncable* registry,
148 const std::set<std::string>& fonts_with_defaults) { 152 const std::set<std::string>& fonts_with_defaults) {
149 153
150 // Expand the font concatenated with script name so this stays at RO memory 154 // Expand the font concatenated with script name so this stays at RO memory
151 // rather than allocated in heap. 155 // rather than allocated in heap.
152 static const char* const kFontFamilyMap[] = { 156 static const char* const kFontFamilyMap[] = {
153 #define EXPAND_SCRIPT_FONT(map_name, script_name) map_name "." script_name, 157 #define EXPAND_SCRIPT_FONT(map_name, script_name) map_name "." script_name,
154 158
155 #include "chrome/common/pref_font_script_names-inl.h" 159 #include "chrome/common/pref_font_script_names-inl.h"
156 ALL_FONT_SCRIPTS(WEBKIT_WEBPREFS_FONTS_CURSIVE) 160 ALL_FONT_SCRIPTS(WEBKIT_WEBPREFS_FONTS_CURSIVE)
(...skipping 13 matching lines...) Expand all
170 // We haven't already set a default value for this font preference, so set 174 // We haven't already set a default value for this font preference, so set
171 // an empty string as the default. 175 // an empty string as the default.
172 registry->RegisterStringPref( 176 registry->RegisterStringPref(
173 pref_name, 177 pref_name,
174 std::string(), 178 std::string(),
175 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 179 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
176 } 180 }
177 } 181 }
178 } 182 }
179 183
180 #if !defined(OS_ANDROID)
181 // Registers |obs| to observe per-script font prefs under the path |map_name|. 184 // Registers |obs| to observe per-script font prefs under the path |map_name|.
182 // On android, there's no exposed way to change these prefs, so we can save 185 // On android, there's no exposed way to change these prefs, so we can save
183 // ~715KB of heap and some startup cycles by avoiding observing these prefs 186 // ~715KB of heap and some startup cycles by avoiding observing these prefs
184 // since they will never change. 187 // since they will never change.
185 void RegisterFontFamilyMapObserver( 188 void RegisterFontFamilyMapObserver(
186 PrefChangeRegistrar* registrar, 189 PrefChangeRegistrar* registrar,
187 const char* map_name, 190 const char* map_name,
188 const PrefChangeRegistrar::NamedChangeCallback& obs) { 191 const PrefChangeRegistrar::NamedChangeCallback& obs) {
189 DCHECK(StartsWithASCII(map_name, "webkit.webprefs.", true)); 192 DCHECK(StartsWithASCII(map_name, "webkit.webprefs.", true));
190 for (size_t i = 0; i < prefs::kWebKitScriptsForFontFamilyMapsLength; ++i) { 193 for (size_t i = 0; i < prefs::kWebKitScriptsForFontFamilyMapsLength; ++i) {
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 // not be really critical after all. 608 // not be really critical after all.
606 if (browser_script != pref_script) { 609 if (browser_script != pref_script) {
607 registry->RegisterLocalizedStringPref( 610 registry->RegisterLocalizedStringPref(
608 pref.pref_name, 611 pref.pref_name,
609 pref.resource_id, 612 pref.resource_id,
610 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 613 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
611 fonts_with_defaults.insert(pref.pref_name); 614 fonts_with_defaults.insert(pref.pref_name);
612 } 615 }
613 } 616 }
614 617
615 // Register font prefs that don't have defaults. 618 // Register per-script font prefs that don't have defaults.
619 #if !defined(OS_ANDROID)
616 RegisterFontFamilyPrefs(registry, fonts_with_defaults); 620 RegisterFontFamilyPrefs(registry, fonts_with_defaults);
621 #endif
617 622
618 registry->RegisterLocalizedIntegerPref( 623 registry->RegisterLocalizedIntegerPref(
619 prefs::kWebKitDefaultFontSize, 624 prefs::kWebKitDefaultFontSize,
620 IDS_DEFAULT_FONT_SIZE, 625 IDS_DEFAULT_FONT_SIZE,
621 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 626 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
622 registry->RegisterLocalizedIntegerPref( 627 registry->RegisterLocalizedIntegerPref(
623 prefs::kWebKitDefaultFixedFontSize, 628 prefs::kWebKitDefaultFixedFontSize,
624 IDS_DEFAULT_FIXED_FONT_SIZE, 629 IDS_DEFAULT_FIXED_FONT_SIZE,
625 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 630 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
626 registry->RegisterLocalizedIntegerPref( 631 registry->RegisterLocalizedIntegerPref(
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 WebPreferences web_prefs = 722 WebPreferences web_prefs =
718 web_contents_->GetRenderViewHost()->GetWebkitPreferences(); 723 web_contents_->GetRenderViewHost()->GetWebkitPreferences();
719 OverrideFontFamily(&web_prefs, generic_family, script, std::string()); 724 OverrideFontFamily(&web_prefs, generic_family, script, std::string());
720 web_contents_->GetRenderViewHost()->UpdateWebkitPreferences(web_prefs); 725 web_contents_->GetRenderViewHost()->UpdateWebkitPreferences(web_prefs);
721 return; 726 return;
722 } 727 }
723 } 728 }
724 729
725 UpdateWebPreferences(); 730 UpdateWebPreferences();
726 } 731 }
OLDNEW
« no previous file with comments | « chrome/browser/chrome_content_browser_client.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698