Chromium Code Reviews| 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* kPrefsToObserve[] = { |
|
Lei Zhang
2016/09/06 19:03:40
Can you make this a const char* const, while you a
Jinsuk Kim
2016/09/06 20:42:13
Done.
| |
| 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 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 592 #endif | 591 #endif |
| 593 | 592 |
| 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( | |
| 603 prefs::kWebKitUsesUniversalDetector, | |
| 604 l10n_util::GetStringUTF8(IDS_USES_UNIVERSAL_DETECTOR) == "true", | |
| 605 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | |
| 606 } | 601 } |
| 607 | 602 |
| 608 // static | 603 // static |
| 609 void PrefsTabHelper::GetServiceInstance() { | 604 void PrefsTabHelper::GetServiceInstance() { |
| 610 PrefWatcherFactory::GetInstance(); | 605 PrefWatcherFactory::GetInstance(); |
| 611 } | 606 } |
| 612 | 607 |
| 613 void PrefsTabHelper::Observe(int type, | 608 void PrefsTabHelper::Observe(int type, |
| 614 const content::NotificationSource& source, | 609 const content::NotificationSource& source, |
| 615 const content::NotificationDetails& details) { | 610 const content::NotificationDetails& details) { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 672 } | 667 } |
| 673 } | 668 } |
| 674 | 669 |
| 675 void PrefsTabHelper::OnWebPrefChanged(const std::string& pref_name) { | 670 void PrefsTabHelper::OnWebPrefChanged(const std::string& pref_name) { |
| 676 #if !defined(OS_ANDROID) | 671 #if !defined(OS_ANDROID) |
| 677 OnFontFamilyPrefChanged(pref_name); | 672 OnFontFamilyPrefChanged(pref_name); |
| 678 #endif | 673 #endif |
| 679 | 674 |
| 680 web_contents_->GetRenderViewHost()->OnWebkitPreferencesChanged(); | 675 web_contents_->GetRenderViewHost()->OnWebkitPreferencesChanged(); |
| 681 } | 676 } |
| OLD | NEW |