OLD | NEW |
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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 #endif | 58 #endif |
59 | 59 |
60 using content::WebContents; | 60 using content::WebContents; |
61 using content::WebPreferences; | 61 using content::WebPreferences; |
62 | 62 |
63 DEFINE_WEB_CONTENTS_USER_DATA_KEY(PrefsTabHelper); | 63 DEFINE_WEB_CONTENTS_USER_DATA_KEY(PrefsTabHelper); |
64 | 64 |
65 namespace { | 65 namespace { |
66 | 66 |
67 // The list of prefs we want to observe. | 67 // The list of prefs we want to observe. |
68 const char* kPrefsToObserve[] = { | 68 const char* const kPrefsToObserve[] = { |
69 #if defined(ENABLE_EXTENSIONS) | 69 #if defined(ENABLE_EXTENSIONS) |
70 prefs::kAnimationPolicy, | 70 prefs::kAnimationPolicy, |
71 #endif | 71 #endif |
72 prefs::kDataSaverEnabled, | 72 prefs::kDataSaverEnabled, |
73 prefs::kDefaultCharset, | 73 prefs::kDefaultCharset, |
74 prefs::kDisable3DAPIs, | 74 prefs::kDisable3DAPIs, |
75 prefs::kEnableHyperlinkAuditing, | 75 prefs::kEnableHyperlinkAuditing, |
76 prefs::kWebKitAllowDisplayingInsecureContent, | 76 prefs::kWebKitAllowDisplayingInsecureContent, |
77 prefs::kWebKitAllowRunningInsecureContent, | 77 prefs::kWebKitAllowRunningInsecureContent, |
78 prefs::kWebKitDefaultFixedFontSize, | 78 prefs::kWebKitDefaultFixedFontSize, |
79 prefs::kWebKitDefaultFontSize, | 79 prefs::kWebKitDefaultFontSize, |
80 prefs::kWebKitDomPasteEnabled, | 80 prefs::kWebKitDomPasteEnabled, |
81 #if defined(OS_ANDROID) | 81 #if defined(OS_ANDROID) |
82 prefs::kWebKitFontScaleFactor, | 82 prefs::kWebKitFontScaleFactor, |
83 prefs::kWebKitForceEnableZoom, | 83 prefs::kWebKitForceEnableZoom, |
84 prefs::kWebKitPasswordEchoEnabled, | 84 prefs::kWebKitPasswordEchoEnabled, |
85 #endif | 85 #endif |
86 prefs::kWebKitJavascriptCanOpenWindowsAutomatically, | 86 prefs::kWebKitJavascriptCanOpenWindowsAutomatically, |
87 prefs::kWebKitJavascriptEnabled, | 87 prefs::kWebKitJavascriptEnabled, |
88 prefs::kWebKitLoadsImagesAutomatically, | 88 prefs::kWebKitLoadsImagesAutomatically, |
89 prefs::kWebKitMinimumFontSize, | 89 prefs::kWebKitMinimumFontSize, |
90 prefs::kWebKitMinimumLogicalFontSize, | 90 prefs::kWebKitMinimumLogicalFontSize, |
91 prefs::kWebKitPluginsEnabled, | 91 prefs::kWebKitPluginsEnabled, |
92 prefs::kWebkitTabsToLinks, | 92 prefs::kWebkitTabsToLinks, |
93 prefs::kWebKitTextAreasAreResizable, | 93 prefs::kWebKitTextAreasAreResizable, |
94 prefs::kWebKitUsesUniversalDetector, | |
95 prefs::kWebKitWebSecurityEnabled, | 94 prefs::kWebKitWebSecurityEnabled, |
96 }; | 95 }; |
97 | 96 |
98 const int kPrefsToObserveLength = arraysize(kPrefsToObserve); | 97 const int kPrefsToObserveLength = arraysize(kPrefsToObserve); |
99 | 98 |
100 #if !defined(OS_ANDROID) | 99 #if !defined(OS_ANDROID) |
101 // Registers a preference under the path |pref_name| for each script used for | 100 // Registers a preference under the path |pref_name| for each script used for |
102 // per-script font prefs. | 101 // per-script font prefs. |
103 // For example, for WEBKIT_WEBPREFS_FONTS_SERIF ("fonts.serif"): | 102 // For example, for WEBKIT_WEBPREFS_FONTS_SERIF ("fonts.serif"): |
104 // "fonts.serif.Arab", "fonts.serif.Hang", etc. are registered. | 103 // "fonts.serif.Arab", "fonts.serif.Hang", etc. are registered. |
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 RegisterLocalizedFontPref(registry, prefs::kWebKitDefaultFontSize, | 593 RegisterLocalizedFontPref(registry, prefs::kWebKitDefaultFontSize, |
595 IDS_DEFAULT_FONT_SIZE); | 594 IDS_DEFAULT_FONT_SIZE); |
596 RegisterLocalizedFontPref(registry, prefs::kWebKitDefaultFixedFontSize, | 595 RegisterLocalizedFontPref(registry, prefs::kWebKitDefaultFixedFontSize, |
597 IDS_DEFAULT_FIXED_FONT_SIZE); | 596 IDS_DEFAULT_FIXED_FONT_SIZE); |
598 RegisterLocalizedFontPref(registry, prefs::kWebKitMinimumFontSize, | 597 RegisterLocalizedFontPref(registry, prefs::kWebKitMinimumFontSize, |
599 IDS_MINIMUM_FONT_SIZE); | 598 IDS_MINIMUM_FONT_SIZE); |
600 RegisterLocalizedFontPref(registry, prefs::kWebKitMinimumLogicalFontSize, | 599 RegisterLocalizedFontPref(registry, prefs::kWebKitMinimumLogicalFontSize, |
601 IDS_MINIMUM_LOGICAL_FONT_SIZE); | 600 IDS_MINIMUM_LOGICAL_FONT_SIZE); |
602 registry->RegisterBooleanPref( | 601 registry->RegisterBooleanPref( |
603 prefs::kWebKitUsesUniversalDetector, | 602 prefs::kWebKitUsesUniversalDetector, |
604 l10n_util::GetStringUTF8(IDS_USES_UNIVERSAL_DETECTOR) == "true", | 603 true, |
605 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | 604 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
606 } | 605 } |
607 | 606 |
608 // static | 607 // static |
609 void PrefsTabHelper::GetServiceInstance() { | 608 void PrefsTabHelper::GetServiceInstance() { |
610 PrefWatcherFactory::GetInstance(); | 609 PrefWatcherFactory::GetInstance(); |
611 } | 610 } |
612 | 611 |
613 void PrefsTabHelper::Observe(int type, | 612 void PrefsTabHelper::Observe(int type, |
614 const content::NotificationSource& source, | 613 const content::NotificationSource& source, |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 } | 671 } |
673 } | 672 } |
674 | 673 |
675 void PrefsTabHelper::OnWebPrefChanged(const std::string& pref_name) { | 674 void PrefsTabHelper::OnWebPrefChanged(const std::string& pref_name) { |
676 #if !defined(OS_ANDROID) | 675 #if !defined(OS_ANDROID) |
677 OnFontFamilyPrefChanged(pref_name); | 676 OnFontFamilyPrefChanged(pref_name); |
678 #endif | 677 #endif |
679 | 678 |
680 web_contents_->GetRenderViewHost()->OnWebkitPreferencesChanged(); | 679 web_contents_->GetRenderViewHost()->OnWebkitPreferencesChanged(); |
681 } | 680 } |
OLD | NEW |