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

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

Issue 2734573002: Don't look up font size preferences on Android. (Closed)
Patch Set: Created 3 years, 9 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/prefs/chrome_pref_service_unittest.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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <set> 10 #include <set>
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 map = &prefs->cursive_font_family_map; 314 map = &prefs->cursive_font_family_map;
315 else if (generic_family == "fantasy") 315 else if (generic_family == "fantasy")
316 map = &prefs->fantasy_font_family_map; 316 map = &prefs->fantasy_font_family_map;
317 else if (generic_family == "pictograph") 317 else if (generic_family == "pictograph")
318 map = &prefs->pictograph_font_family_map; 318 map = &prefs->pictograph_font_family_map;
319 else 319 else
320 NOTREACHED() << "Unknown generic font family: " << generic_family; 320 NOTREACHED() << "Unknown generic font family: " << generic_family;
321 (*map)[script] = base::UTF8ToUTF16(pref_value); 321 (*map)[script] = base::UTF8ToUTF16(pref_value);
322 } 322 }
323 323
324 #if !defined(OS_ANDROID)
324 void RegisterLocalizedFontPref(user_prefs::PrefRegistrySyncable* registry, 325 void RegisterLocalizedFontPref(user_prefs::PrefRegistrySyncable* registry,
325 const char* path, 326 const char* path,
326 int default_message_id) { 327 int default_message_id) {
327 int val = 0; 328 int val = 0;
328 bool success = base::StringToInt(l10n_util::GetStringUTF8( 329 bool success = base::StringToInt(l10n_util::GetStringUTF8(
329 default_message_id), &val); 330 default_message_id), &val);
330 DCHECK(success); 331 DCHECK(success);
331 registry->RegisterIntegerPref(path, val); 332 registry->RegisterIntegerPref(path, val);
332 } 333 }
334 #endif
333 335
334 } // namespace 336 } // namespace
335 337
336 // Watching all these settings per tab is slow when a user has a lot of tabs and 338 // Watching all these settings per tab is slow when a user has a lot of tabs and
337 // and they use session restore. So watch them once per profile. 339 // and they use session restore. So watch them once per profile.
338 // http://crbug.com/452693 340 // http://crbug.com/452693
339 class PrefWatcher : public KeyedService { 341 class PrefWatcher : public KeyedService {
340 public: 342 public:
341 explicit PrefWatcher(Profile* profile) : profile_(profile) { 343 explicit PrefWatcher(Profile* profile) : profile_(profile) {
342 pref_change_registrar_.Init(profile_->GetPrefs()); 344 pref_change_registrar_.Init(profile_->GetPrefs());
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 // can possibly be removed later if users can easily access per-script font 575 // can possibly be removed later if users can easily access per-script font
574 // prefs (e.g., via the extensions workflow), or the problem turns out to 576 // prefs (e.g., via the extensions workflow), or the problem turns out to
575 // not be really critical after all. 577 // not be really critical after all.
576 if (browser_script != pref_script) { 578 if (browser_script != pref_script) {
577 registry->RegisterStringPref(pref.pref_name, 579 registry->RegisterStringPref(pref.pref_name,
578 l10n_util::GetStringUTF8(pref.resource_id)); 580 l10n_util::GetStringUTF8(pref.resource_id));
579 fonts_with_defaults.insert(pref.pref_name); 581 fonts_with_defaults.insert(pref.pref_name);
580 } 582 }
581 } 583 }
582 584
583 // Register per-script font prefs that don't have defaults. 585 // Register font prefs. This is only configurable on desktop Chrome.
584 #if !defined(OS_ANDROID) 586 #if !defined(OS_ANDROID)
585 RegisterFontFamilyPrefs(registry, fonts_with_defaults); 587 RegisterFontFamilyPrefs(registry, fonts_with_defaults);
586 #endif
587 588
588 RegisterLocalizedFontPref(registry, prefs::kWebKitDefaultFontSize, 589 RegisterLocalizedFontPref(registry, prefs::kWebKitDefaultFontSize,
589 IDS_DEFAULT_FONT_SIZE); 590 IDS_DEFAULT_FONT_SIZE);
590 RegisterLocalizedFontPref(registry, prefs::kWebKitDefaultFixedFontSize, 591 RegisterLocalizedFontPref(registry, prefs::kWebKitDefaultFixedFontSize,
591 IDS_DEFAULT_FIXED_FONT_SIZE); 592 IDS_DEFAULT_FIXED_FONT_SIZE);
592 RegisterLocalizedFontPref(registry, prefs::kWebKitMinimumFontSize, 593 RegisterLocalizedFontPref(registry, prefs::kWebKitMinimumFontSize,
593 IDS_MINIMUM_FONT_SIZE); 594 IDS_MINIMUM_FONT_SIZE);
594 RegisterLocalizedFontPref(registry, prefs::kWebKitMinimumLogicalFontSize, 595 RegisterLocalizedFontPref(registry, prefs::kWebKitMinimumLogicalFontSize,
595 IDS_MINIMUM_LOGICAL_FONT_SIZE); 596 IDS_MINIMUM_LOGICAL_FONT_SIZE);
597 #endif
596 } 598 }
597 599
598 // static 600 // static
599 void PrefsTabHelper::GetServiceInstance() { 601 void PrefsTabHelper::GetServiceInstance() {
600 PrefWatcherFactory::GetInstance(); 602 PrefWatcherFactory::GetInstance();
601 } 603 }
602 604
603 void PrefsTabHelper::Observe(int type, 605 void PrefsTabHelper::Observe(int type,
604 const content::NotificationSource& source, 606 const content::NotificationSource& source,
605 const content::NotificationDetails& details) { 607 const content::NotificationDetails& details) {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 } 674 }
673 675
674 void PrefsTabHelper::NotifyWebkitPreferencesChanged( 676 void PrefsTabHelper::NotifyWebkitPreferencesChanged(
675 const std::string& pref_name) { 677 const std::string& pref_name) {
676 #if !defined(OS_ANDROID) 678 #if !defined(OS_ANDROID)
677 OnFontFamilyPrefChanged(pref_name); 679 OnFontFamilyPrefChanged(pref_name);
678 #endif 680 #endif
679 681
680 web_contents_->GetRenderViewHost()->OnWebkitPreferencesChanged(); 682 web_contents_->GetRenderViewHost()->OnWebkitPreferencesChanged();
681 } 683 }
OLDNEW
« no previous file with comments | « chrome/browser/prefs/chrome_pref_service_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698