| 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 prefs->RegisterLocalizedStringPref(prefs::kWebKitGlobalFantasyFontFamily, | 89 prefs->RegisterLocalizedStringPref(prefs::kWebKitGlobalFantasyFontFamily, |
| 90 IDS_FANTASY_FONT_FAMILY, | 90 IDS_FANTASY_FONT_FAMILY, |
| 91 PrefService::UNSYNCABLE_PREF); | 91 PrefService::UNSYNCABLE_PREF); |
| 92 } | 92 } |
| 93 | 93 |
| 94 // The list of prefs we want to observe. | 94 // The list of prefs we want to observe. |
| 95 const char* kPrefsToObserve[] = { | 95 const char* kPrefsToObserve[] = { |
| 96 prefs::kDefaultZoomLevel, | 96 prefs::kDefaultZoomLevel, |
| 97 prefs::kDefaultCharset, | 97 prefs::kDefaultCharset, |
| 98 prefs::kEnableReferrers, | 98 prefs::kEnableReferrers, |
| 99 prefs::kEnableDoNotTrack, |
| 99 prefs::kWebKitAllowDisplayingInsecureContent, | 100 prefs::kWebKitAllowDisplayingInsecureContent, |
| 100 prefs::kWebKitAllowRunningInsecureContent, | 101 prefs::kWebKitAllowRunningInsecureContent, |
| 101 prefs::kWebKitDefaultFixedFontSize, | 102 prefs::kWebKitDefaultFixedFontSize, |
| 102 prefs::kWebKitDefaultFontSize, | 103 prefs::kWebKitDefaultFontSize, |
| 103 prefs::kWebKitJavascriptEnabled, | 104 prefs::kWebKitJavascriptEnabled, |
| 104 prefs::kWebKitJavaEnabled, | 105 prefs::kWebKitJavaEnabled, |
| 105 prefs::kWebKitLoadsImagesAutomatically, | 106 prefs::kWebKitLoadsImagesAutomatically, |
| 106 prefs::kWebKitMinimumFontSize, | 107 prefs::kWebKitMinimumFontSize, |
| 107 prefs::kWebKitMinimumLogicalFontSize, | 108 prefs::kWebKitMinimumLogicalFontSize, |
| 108 prefs::kWebKitPluginsEnabled, | 109 prefs::kWebKitPluginsEnabled, |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 } | 519 } |
| 519 #endif | 520 #endif |
| 520 case chrome::NOTIFICATION_PREF_CHANGED: { | 521 case chrome::NOTIFICATION_PREF_CHANGED: { |
| 521 std::string* pref_name_in = content::Details<std::string>(details).ptr(); | 522 std::string* pref_name_in = content::Details<std::string>(details).ptr(); |
| 522 DCHECK(content::Source<PrefService>(source).ptr() == | 523 DCHECK(content::Source<PrefService>(source).ptr() == |
| 523 GetProfile()->GetPrefs()); | 524 GetProfile()->GetPrefs()); |
| 524 if (*pref_name_in == prefs::kDefaultCharset || | 525 if (*pref_name_in == prefs::kDefaultCharset || |
| 525 StartsWithASCII(*pref_name_in, "webkit.webprefs.", true)) { | 526 StartsWithASCII(*pref_name_in, "webkit.webprefs.", true)) { |
| 526 UpdateWebPreferences(); | 527 UpdateWebPreferences(); |
| 527 } else if (*pref_name_in == prefs::kDefaultZoomLevel || | 528 } else if (*pref_name_in == prefs::kDefaultZoomLevel || |
| 528 *pref_name_in == prefs::kEnableReferrers) { | 529 *pref_name_in == prefs::kEnableReferrers || |
| 530 *pref_name_in == prefs::kEnableDoNotTrack) { |
| 529 UpdateRendererPreferences(); | 531 UpdateRendererPreferences(); |
| 530 } else { | 532 } else { |
| 531 NOTREACHED() << "unexpected pref change notification" << *pref_name_in; | 533 NOTREACHED() << "unexpected pref change notification" << *pref_name_in; |
| 532 } | 534 } |
| 533 break; | 535 break; |
| 534 } | 536 } |
| 535 default: | 537 default: |
| 536 NOTREACHED(); | 538 NOTREACHED(); |
| 537 } | 539 } |
| 538 } | 540 } |
| 539 | 541 |
| 540 void PrefsTabHelper::UpdateWebPreferences() { | 542 void PrefsTabHelper::UpdateWebPreferences() { |
| 541 web_contents_->GetRenderViewHost()->UpdateWebkitPreferences( | 543 web_contents_->GetRenderViewHost()->UpdateWebkitPreferences( |
| 542 web_contents_->GetRenderViewHost()->GetWebkitPreferences()); | 544 web_contents_->GetRenderViewHost()->GetWebkitPreferences()); |
| 543 } | 545 } |
| 544 | 546 |
| 545 void PrefsTabHelper::UpdateRendererPreferences() { | 547 void PrefsTabHelper::UpdateRendererPreferences() { |
| 546 renderer_preferences_util::UpdateFromSystemSettings( | 548 renderer_preferences_util::UpdateFromSystemSettings( |
| 547 web_contents_->GetMutableRendererPrefs(), GetProfile()); | 549 web_contents_->GetMutableRendererPrefs(), GetProfile()); |
| 548 web_contents_->GetRenderViewHost()->SyncRendererPrefs(); | 550 web_contents_->GetRenderViewHost()->SyncRendererPrefs(); |
| 549 } | 551 } |
| 550 | 552 |
| 551 Profile* PrefsTabHelper::GetProfile() { | 553 Profile* PrefsTabHelper::GetProfile() { |
| 552 return Profile::FromBrowserContext(web_contents_->GetBrowserContext()); | 554 return Profile::FromBrowserContext(web_contents_->GetBrowserContext()); |
| 553 } | 555 } |
| OLD | NEW |