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 "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
9 #include "base/utf_string_conversions.h" | |
10 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
11 #include "chrome/browser/prefs/overlay_user_pref_store.h" | 10 #include "chrome/browser/prefs/overlay_user_pref_store.h" |
12 #include "chrome/browser/prefs/pref_service.h" | 11 #include "chrome/browser/prefs/pref_service.h" |
13 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/renderer_preferences_util.h" | 13 #include "chrome/browser/renderer_preferences_util.h" |
15 #include "chrome/browser/themes/theme_service.h" | 14 #include "chrome/browser/themes/theme_service.h" |
16 #include "chrome/browser/themes/theme_service_factory.h" | 15 #include "chrome/browser/themes/theme_service_factory.h" |
17 #include "chrome/browser/ui/constrained_window_tab_helper.h" | 16 #include "chrome/browser/ui/constrained_window_tab_helper.h" |
18 #include "chrome/common/chrome_notification_types.h" | 17 #include "chrome/common/chrome_notification_types.h" |
19 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
20 #include "content/public/browser/notification_details.h" | 19 #include "content/public/browser/notification_details.h" |
21 #include "content/public/browser/notification_service.h" | 20 #include "content/public/browser/notification_service.h" |
22 #include "content/public/browser/render_view_host.h" | 21 #include "content/public/browser/render_view_host.h" |
23 #include "content/public/browser/render_view_host_delegate.h" | 22 #include "content/public/browser/render_view_host_delegate.h" |
24 #include "content/public/browser/web_contents.h" | 23 #include "content/public/browser/web_contents.h" |
25 #include "grit/locale_settings.h" | 24 #include "grit/locale_settings.h" |
26 #include "grit/platform_locale_settings.h" | 25 #include "grit/platform_locale_settings.h" |
27 #include "webkit/glue/webpreferences.h" | 26 #include "webkit/glue/webpreferences.h" |
28 | 27 |
29 using content::WebContents; | 28 using content::WebContents; |
30 | 29 |
31 namespace { | 30 namespace { |
32 | 31 |
33 const char* kPerTabPrefsToObserve[] = { | |
34 prefs::kDefaultCharset, | |
35 prefs::kWebKitJavascriptEnabled, | |
36 prefs::kWebKitJavascriptCanOpenWindowsAutomatically, | |
37 prefs::kWebKitLoadsImagesAutomatically, | |
38 prefs::kWebKitImagesEnabled, | |
39 prefs::kWebKitPluginsEnabled, | |
40 prefs::kWebKitCursiveFontFamily, | |
41 prefs::kWebKitFantasyFontFamily, | |
42 prefs::kWebKitFixedFontFamily, | |
43 prefs::kWebKitSansSerifFontFamily, | |
44 prefs::kWebKitSerifFontFamily, | |
45 prefs::kWebKitStandardFontFamily, | |
46 prefs::kWebKitDefaultFontSize, | |
47 prefs::kWebKitDefaultFixedFontSize, | |
48 prefs::kWebKitMinimumFontSize, | |
49 prefs::kWebKitMinimumLogicalFontSize, | |
50 prefs::kWebKitXSSAuditorEnabled | |
51 }; | |
52 | |
53 const int kPerTabPrefsToObserveLength = arraysize(kPerTabPrefsToObserve); | |
54 | |
55 static void RegisterFontsAndCharsetPrefs(PrefService* prefs) { | 32 static void RegisterFontsAndCharsetPrefs(PrefService* prefs) { |
56 WebPreferences pref_defaults; | 33 WebPreferences pref_defaults; |
57 | 34 |
58 prefs->RegisterLocalizedStringPref(prefs::kDefaultCharset, | 35 prefs->RegisterLocalizedStringPref(prefs::kDefaultCharset, |
59 IDS_DEFAULT_ENCODING, | 36 IDS_DEFAULT_ENCODING, |
60 PrefService::SYNCABLE_PREF); | 37 PrefService::SYNCABLE_PREF); |
61 prefs->RegisterLocalizedStringPref(prefs::kWebKitStandardFontFamily, | 38 prefs->RegisterLocalizedStringPref(prefs::kWebKitStandardFontFamily, |
62 IDS_STANDARD_FONT_FAMILY, | 39 IDS_STANDARD_FONT_FAMILY, |
63 PrefService::UNSYNCABLE_PREF); | 40 PrefService::UNSYNCABLE_PREF); |
64 prefs->RegisterLocalizedStringPref(prefs::kWebKitFixedFontFamily, | 41 prefs->RegisterLocalizedStringPref(prefs::kWebKitFixedFontFamily, |
(...skipping 18 matching lines...) Expand all Loading... | |
83 IDS_DEFAULT_FIXED_FONT_SIZE, | 60 IDS_DEFAULT_FIXED_FONT_SIZE, |
84 PrefService::UNSYNCABLE_PREF); | 61 PrefService::UNSYNCABLE_PREF); |
85 prefs->RegisterLocalizedIntegerPref(prefs::kWebKitMinimumFontSize, | 62 prefs->RegisterLocalizedIntegerPref(prefs::kWebKitMinimumFontSize, |
86 IDS_MINIMUM_FONT_SIZE, | 63 IDS_MINIMUM_FONT_SIZE, |
87 PrefService::UNSYNCABLE_PREF); | 64 PrefService::UNSYNCABLE_PREF); |
88 prefs->RegisterLocalizedIntegerPref(prefs::kWebKitMinimumLogicalFontSize, | 65 prefs->RegisterLocalizedIntegerPref(prefs::kWebKitMinimumLogicalFontSize, |
89 IDS_MINIMUM_LOGICAL_FONT_SIZE, | 66 IDS_MINIMUM_LOGICAL_FONT_SIZE, |
90 PrefService::UNSYNCABLE_PREF); | 67 PrefService::UNSYNCABLE_PREF); |
91 } | 68 } |
92 | 69 |
93 static void RegisterPerTabUserPrefs(PrefService* prefs) { | |
94 WebPreferences pref_defaults; | |
95 | |
96 prefs->RegisterBooleanPref(prefs::kWebKitJavascriptEnabled, | |
97 pref_defaults.javascript_enabled, | |
98 PrefService::UNSYNCABLE_PREF); | |
99 prefs->RegisterBooleanPref( | |
100 prefs::kWebKitJavascriptCanOpenWindowsAutomatically, | |
101 true, | |
102 PrefService::UNSYNCABLE_PREF); | |
103 prefs->RegisterBooleanPref(prefs::kWebKitLoadsImagesAutomatically, | |
104 pref_defaults.loads_images_automatically, | |
105 PrefService::UNSYNCABLE_PREF); | |
106 prefs->RegisterBooleanPref(prefs::kWebKitImagesEnabled, | |
107 pref_defaults.images_enabled, | |
108 PrefService::UNSYNCABLE_PREF); | |
109 prefs->RegisterBooleanPref(prefs::kWebKitPluginsEnabled, | |
110 pref_defaults.plugins_enabled, | |
111 PrefService::UNSYNCABLE_PREF); | |
112 prefs->RegisterBooleanPref(prefs::kWebKitXSSAuditorEnabled, | |
113 pref_defaults.xss_auditor_enabled, | |
114 PrefService::UNSYNCABLE_PREF); | |
115 RegisterFontsAndCharsetPrefs(prefs); | |
116 } | |
117 | |
118 // The list of prefs we want to observe. | 70 // The list of prefs we want to observe. |
119 const char* kPrefsToObserve[] = { | 71 const char* kPrefsToObserve[] = { |
120 prefs::kDefaultZoomLevel, | 72 prefs::kDefaultZoomLevel, |
121 prefs::kGlobalDefaultCharset, | 73 prefs::kGlobalDefaultCharset, |
122 prefs::kEnableReferrers, | 74 prefs::kEnableReferrers, |
123 prefs::kWebKitAllowDisplayingInsecureContent, | 75 prefs::kWebKitAllowDisplayingInsecureContent, |
124 prefs::kWebKitAllowRunningInsecureContent, | 76 prefs::kWebKitAllowRunningInsecureContent, |
125 prefs::kWebKitGlobalCursiveFontFamily, | 77 prefs::kWebKitGlobalCursiveFontFamily, |
126 prefs::kWebKitGlobalDefaultFixedFontSize, | 78 prefs::kWebKitGlobalDefaultFixedFontSize, |
127 prefs::kWebKitGlobalDefaultFontSize, | 79 prefs::kWebKitGlobalDefaultFontSize, |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
345 RegisterFontFamilyMapObserver(&pref_change_registrar_, | 297 RegisterFontFamilyMapObserver(&pref_change_registrar_, |
346 prefs::kWebKitSerifFontFamilyMap, this); | 298 prefs::kWebKitSerifFontFamilyMap, this); |
347 RegisterFontFamilyMapObserver(&pref_change_registrar_, | 299 RegisterFontFamilyMapObserver(&pref_change_registrar_, |
348 prefs::kWebKitSansSerifFontFamilyMap, this); | 300 prefs::kWebKitSansSerifFontFamilyMap, this); |
349 RegisterFontFamilyMapObserver(&pref_change_registrar_, | 301 RegisterFontFamilyMapObserver(&pref_change_registrar_, |
350 prefs::kWebKitCursiveFontFamilyMap, this); | 302 prefs::kWebKitCursiveFontFamilyMap, this); |
351 RegisterFontFamilyMapObserver(&pref_change_registrar_, | 303 RegisterFontFamilyMapObserver(&pref_change_registrar_, |
352 prefs::kWebKitFantasyFontFamilyMap, this); | 304 prefs::kWebKitFantasyFontFamilyMap, this); |
353 } | 305 } |
354 | 306 |
355 per_tab_prefs_.reset( | |
356 GetProfile()->GetPrefs()->CreatePrefServiceWithPerTabPrefStore()); | |
357 RegisterPerTabUserPrefs(per_tab_prefs_.get()); | |
358 per_tab_pref_change_registrar_.Init(per_tab_prefs_.get()); | |
359 for (int i = 0; i < kPerTabPrefsToObserveLength; ++i) { | |
360 per_tab_pref_change_registrar_.Add(kPerTabPrefsToObserve[i], this); | |
361 } | |
362 | |
363 renderer_preferences_util::UpdateFromSystemSettings( | 307 renderer_preferences_util::UpdateFromSystemSettings( |
364 web_contents()->GetMutableRendererPrefs(), GetProfile()); | 308 web_contents()->GetMutableRendererPrefs(), GetProfile()); |
365 | 309 |
366 registrar_.Add(this, chrome::NOTIFICATION_USER_STYLE_SHEET_UPDATED, | 310 registrar_.Add(this, chrome::NOTIFICATION_USER_STYLE_SHEET_UPDATED, |
367 content::NotificationService::AllSources()); | 311 content::NotificationService::AllSources()); |
368 #if defined(OS_POSIX) && !defined(OS_MACOSX) && defined(ENABLE_THEMES) | 312 #if defined(OS_POSIX) && !defined(OS_MACOSX) && defined(ENABLE_THEMES) |
369 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, | 313 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, |
370 content::Source<ThemeService>( | 314 content::Source<ThemeService>( |
371 ThemeServiceFactory::GetForProfile(GetProfile()))); | 315 ThemeServiceFactory::GetForProfile(GetProfile()))); |
372 #endif | 316 #endif |
373 } | 317 } |
374 | 318 |
375 PrefsTabHelper::~PrefsTabHelper() { | 319 PrefsTabHelper::~PrefsTabHelper() { |
376 } | 320 } |
377 | 321 |
378 // static | 322 // static |
379 void PrefsTabHelper::InitIncognitoUserPrefStore( | 323 void PrefsTabHelper::InitIncognitoUserPrefStore( |
380 OverlayUserPrefStore* pref_store) { | 324 OverlayUserPrefStore* pref_store) { |
381 // List of keys that cannot be changed in the user prefs file by the incognito | 325 // List of keys that cannot be changed in the user prefs file by the incognito |
382 // profile. All preferences that store information about the browsing history | 326 // profile. All preferences that store information about the browsing history |
383 // or behavior of the user should have this property. | 327 // or behavior of the user should have this property. |
384 pref_store->RegisterOverlayPref(prefs::kBrowserWindowPlacement); | 328 pref_store->RegisterOverlayPref(prefs::kBrowserWindowPlacement); |
385 } | 329 } |
386 | 330 |
387 // static | 331 // static |
388 void PrefsTabHelper::InitPerTabUserPrefStore( | |
389 OverlayUserPrefStore* pref_store) { | |
390 // List of keys that have per-tab and per-profile (Global) counterpart. | |
391 // Setting a per-profile preference affects all tabs sharing the profile, | |
392 // unless a tab has specified its own per-tab property value. Changing a | |
393 // per-profile preference on a per-tab pref store delegates to the underlying | |
394 // per-profile pref store. | |
395 pref_store->RegisterOverlayPref( | |
396 prefs::kWebKitJavascriptEnabled, | |
397 prefs::kWebKitGlobalJavascriptEnabled); | |
398 pref_store->RegisterOverlayPref( | |
399 prefs::kWebKitJavascriptCanOpenWindowsAutomatically, | |
400 prefs::kWebKitGlobalJavascriptCanOpenWindowsAutomatically); | |
401 pref_store->RegisterOverlayPref( | |
402 prefs::kWebKitLoadsImagesAutomatically, | |
403 prefs::kWebKitGlobalLoadsImagesAutomatically); | |
404 pref_store->RegisterOverlayPref( | |
405 prefs::kWebKitImagesEnabled); | |
406 pref_store->RegisterOverlayPref( | |
407 prefs::kWebKitPluginsEnabled, | |
408 prefs::kWebKitGlobalPluginsEnabled); | |
409 pref_store->RegisterOverlayPref( | |
410 prefs::kDefaultCharset, | |
411 prefs::kGlobalDefaultCharset); | |
412 pref_store->RegisterOverlayPref( | |
413 prefs::kWebKitStandardFontFamily, | |
414 prefs::kWebKitGlobalStandardFontFamily); | |
415 pref_store->RegisterOverlayPref( | |
416 prefs::kWebKitFixedFontFamily, | |
417 prefs::kWebKitGlobalFixedFontFamily); | |
418 pref_store->RegisterOverlayPref( | |
419 prefs::kWebKitSerifFontFamily, | |
420 prefs::kWebKitGlobalSerifFontFamily); | |
421 pref_store->RegisterOverlayPref( | |
422 prefs::kWebKitSansSerifFontFamily, | |
423 prefs::kWebKitGlobalSansSerifFontFamily); | |
424 pref_store->RegisterOverlayPref( | |
425 prefs::kWebKitCursiveFontFamily, | |
426 prefs::kWebKitGlobalCursiveFontFamily); | |
427 pref_store->RegisterOverlayPref( | |
428 prefs::kWebKitFantasyFontFamily, | |
429 prefs::kWebKitGlobalFantasyFontFamily); | |
430 pref_store->RegisterOverlayPref( | |
431 prefs::kWebKitDefaultFontSize, | |
432 prefs::kWebKitGlobalDefaultFontSize); | |
433 pref_store->RegisterOverlayPref( | |
434 prefs::kWebKitDefaultFixedFontSize, | |
435 prefs::kWebKitGlobalDefaultFixedFontSize); | |
436 pref_store->RegisterOverlayPref( | |
437 prefs::kWebKitMinimumFontSize, | |
438 prefs::kWebKitGlobalMinimumFontSize); | |
439 pref_store->RegisterOverlayPref( | |
440 prefs::kWebKitMinimumLogicalFontSize, | |
441 prefs::kWebKitGlobalMinimumLogicalFontSize); | |
442 pref_store->RegisterOverlayPref( | |
443 prefs::kWebKitXSSAuditorEnabled); | |
444 } | |
445 | |
446 // static | |
447 void PrefsTabHelper::RegisterUserPrefs(PrefService* prefs) { | 332 void PrefsTabHelper::RegisterUserPrefs(PrefService* prefs) { |
448 WebPreferences pref_defaults; | 333 WebPreferences pref_defaults; |
449 prefs->RegisterBooleanPref(prefs::kWebKitGlobalJavascriptEnabled, | 334 prefs->RegisterBooleanPref(prefs::kWebKitGlobalJavascriptEnabled, |
450 pref_defaults.javascript_enabled, | 335 pref_defaults.javascript_enabled, |
451 PrefService::UNSYNCABLE_PREF); | 336 PrefService::UNSYNCABLE_PREF); |
452 prefs->RegisterBooleanPref(prefs::kWebKitWebSecurityEnabled, | 337 prefs->RegisterBooleanPref(prefs::kWebKitWebSecurityEnabled, |
453 pref_defaults.web_security_enabled, | 338 pref_defaults.web_security_enabled, |
454 PrefService::UNSYNCABLE_PREF); | 339 PrefService::UNSYNCABLE_PREF); |
455 prefs->RegisterBooleanPref( | 340 prefs->RegisterBooleanPref( |
456 prefs::kWebKitGlobalJavascriptCanOpenWindowsAutomatically, | 341 prefs::kWebKitGlobalJavascriptCanOpenWindowsAutomatically, |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
563 PrefService::SYNCABLE_PREF); | 448 PrefService::SYNCABLE_PREF); |
564 prefs->RegisterLocalizedStringPref(prefs::kStaticEncodings, | 449 prefs->RegisterLocalizedStringPref(prefs::kStaticEncodings, |
565 IDS_STATIC_ENCODING_LIST, | 450 IDS_STATIC_ENCODING_LIST, |
566 PrefService::UNSYNCABLE_PREF); | 451 PrefService::UNSYNCABLE_PREF); |
567 prefs->RegisterStringPref(prefs::kRecentlySelectedEncoding, | 452 prefs->RegisterStringPref(prefs::kRecentlySelectedEncoding, |
568 "", | 453 "", |
569 PrefService::UNSYNCABLE_PREF); | 454 PrefService::UNSYNCABLE_PREF); |
570 MigratePreferences(prefs); | 455 MigratePreferences(prefs); |
571 } | 456 } |
572 | 457 |
573 void PrefsTabHelper::RenderViewCreated( | |
574 content::RenderViewHost* render_view_host) { | |
575 UpdateWebPreferences(); | |
falken
2012/03/23 10:41:12
It's OK to remove this, right? It was introduced h
mnaganov (inactive)
2012/03/23 10:47:04
I think so. This was needed because we had overrid
| |
576 } | |
577 | |
578 void PrefsTabHelper::WebContentsDestroyed(WebContents* tab) { | |
579 per_tab_pref_change_registrar_.RemoveAll(); | |
580 } | |
581 | |
582 void PrefsTabHelper::Observe(int type, | 458 void PrefsTabHelper::Observe(int type, |
583 const content::NotificationSource& source, | 459 const content::NotificationSource& source, |
584 const content::NotificationDetails& details) { | 460 const content::NotificationDetails& details) { |
585 switch (type) { | 461 switch (type) { |
586 case chrome::NOTIFICATION_USER_STYLE_SHEET_UPDATED: | 462 case chrome::NOTIFICATION_USER_STYLE_SHEET_UPDATED: |
587 UpdateWebPreferences(); | 463 UpdateWebPreferences(); |
588 break; | 464 break; |
589 #if defined(OS_POSIX) && !defined(OS_MACOSX) && defined(ENABLE_THEMES) | 465 #if defined(OS_POSIX) && !defined(OS_MACOSX) && defined(ENABLE_THEMES) |
590 case chrome::NOTIFICATION_BROWSER_THEME_CHANGED: { | 466 case chrome::NOTIFICATION_BROWSER_THEME_CHANGED: { |
591 UpdateRendererPreferences(); | 467 UpdateRendererPreferences(); |
592 break; | 468 break; |
593 } | 469 } |
594 #endif | 470 #endif |
595 case chrome::NOTIFICATION_PREF_CHANGED: { | 471 case chrome::NOTIFICATION_PREF_CHANGED: { |
596 std::string* pref_name_in = content::Details<std::string>(details).ptr(); | 472 std::string* pref_name_in = content::Details<std::string>(details).ptr(); |
597 DCHECK(content::Source<PrefService>(source).ptr() == | 473 DCHECK(content::Source<PrefService>(source).ptr() == |
598 GetProfile()->GetPrefs() || | 474 GetProfile()->GetPrefs()); |
599 content::Source<PrefService>(source).ptr() == per_tab_prefs_); | |
600 if ((*pref_name_in == prefs::kDefaultCharset || | 475 if ((*pref_name_in == prefs::kDefaultCharset || |
601 *pref_name_in == prefs::kGlobalDefaultCharset) || | 476 *pref_name_in == prefs::kGlobalDefaultCharset) || |
602 StartsWithASCII(*pref_name_in, "webkit.webprefs.", true)) { | 477 StartsWithASCII(*pref_name_in, "webkit.webprefs.", true)) { |
603 UpdateWebPreferences(); | 478 UpdateWebPreferences(); |
604 } else if (*pref_name_in == prefs::kDefaultZoomLevel || | 479 } else if (*pref_name_in == prefs::kDefaultZoomLevel || |
605 *pref_name_in == prefs::kEnableReferrers) { | 480 *pref_name_in == prefs::kEnableReferrers) { |
606 UpdateRendererPreferences(); | 481 UpdateRendererPreferences(); |
607 } else { | 482 } else { |
608 NOTREACHED() << "unexpected pref change notification" << *pref_name_in; | 483 NOTREACHED() << "unexpected pref change notification" << *pref_name_in; |
609 } | 484 } |
610 break; | 485 break; |
611 } | 486 } |
612 default: | 487 default: |
613 NOTREACHED(); | 488 NOTREACHED(); |
614 } | 489 } |
615 } | 490 } |
616 | 491 |
617 void PrefsTabHelper::UpdateWebPreferences() { | 492 void PrefsTabHelper::UpdateWebPreferences() { |
618 content::RenderViewHostDelegate* rvhd = | 493 content::RenderViewHostDelegate* rvhd = |
619 web_contents()->GetRenderViewHost()->GetDelegate(); | 494 web_contents()->GetRenderViewHost()->GetDelegate(); |
620 WebPreferences prefs = rvhd->GetWebkitPrefs(); | 495 web_contents()->GetRenderViewHost()->UpdateWebkitPreferences( |
Bernhard Bauer
2012/03/23 10:48:14
Where do we fill in the WebPreferences struct now?
mnaganov (inactive)
2012/03/23 10:58:23
RenderViewHostDelegate does this. Here we were onl
falken
2012/03/23 11:01:41
For reference, this just reverts to the code befor
| |
621 prefs.javascript_enabled = | 496 rvhd->GetWebkitPrefs()); |
622 per_tab_prefs_->GetBoolean(prefs::kWebKitJavascriptEnabled); | |
623 prefs.javascript_can_open_windows_automatically = | |
624 per_tab_prefs_->GetBoolean( | |
625 prefs::kWebKitJavascriptCanOpenWindowsAutomatically); | |
626 prefs.loads_images_automatically = | |
627 per_tab_prefs_->GetBoolean(prefs::kWebKitLoadsImagesAutomatically); | |
628 prefs.images_enabled = | |
629 per_tab_prefs_->GetBoolean(prefs::kWebKitImagesEnabled); | |
630 prefs.plugins_enabled = | |
631 per_tab_prefs_->GetBoolean(prefs::kWebKitPluginsEnabled); | |
632 prefs.standard_font_family = | |
633 UTF8ToUTF16(per_tab_prefs_->GetString(prefs::kWebKitStandardFontFamily)); | |
634 prefs.fixed_font_family = | |
635 UTF8ToUTF16(per_tab_prefs_->GetString(prefs::kWebKitFixedFontFamily)); | |
636 prefs.serif_font_family = | |
637 UTF8ToUTF16(per_tab_prefs_->GetString(prefs::kWebKitSerifFontFamily)); | |
638 prefs.sans_serif_font_family = | |
639 UTF8ToUTF16(per_tab_prefs_->GetString(prefs::kWebKitSansSerifFontFamily)); | |
640 prefs.cursive_font_family = | |
641 UTF8ToUTF16(per_tab_prefs_->GetString(prefs::kWebKitCursiveFontFamily)); | |
642 prefs.fantasy_font_family = | |
643 UTF8ToUTF16(per_tab_prefs_->GetString(prefs::kWebKitFantasyFontFamily)); | |
644 prefs.default_font_size = | |
645 per_tab_prefs_->GetInteger(prefs::kWebKitDefaultFontSize); | |
646 prefs.default_fixed_font_size = | |
647 per_tab_prefs_->GetInteger(prefs::kWebKitDefaultFixedFontSize); | |
648 prefs.minimum_font_size = | |
649 per_tab_prefs_->GetInteger(prefs::kWebKitMinimumFontSize); | |
650 prefs.minimum_logical_font_size = | |
651 per_tab_prefs_->GetInteger(prefs::kWebKitMinimumLogicalFontSize); | |
652 prefs.xss_auditor_enabled = | |
653 per_tab_prefs_->GetBoolean(prefs::kWebKitXSSAuditorEnabled); | |
654 prefs.default_encoding = | |
655 per_tab_prefs_->GetString(prefs::kDefaultCharset); | |
656 | |
657 web_contents()->GetRenderViewHost()->UpdateWebkitPreferences(prefs); | |
658 } | 497 } |
659 | 498 |
660 void PrefsTabHelper::UpdateRendererPreferences() { | 499 void PrefsTabHelper::UpdateRendererPreferences() { |
661 renderer_preferences_util::UpdateFromSystemSettings( | 500 renderer_preferences_util::UpdateFromSystemSettings( |
662 web_contents()->GetMutableRendererPrefs(), GetProfile()); | 501 web_contents()->GetMutableRendererPrefs(), GetProfile()); |
663 web_contents()->GetRenderViewHost()->SyncRendererPrefs(); | 502 web_contents()->GetRenderViewHost()->SyncRendererPrefs(); |
664 } | 503 } |
665 | 504 |
666 Profile* PrefsTabHelper::GetProfile() { | 505 Profile* PrefsTabHelper::GetProfile() { |
667 return Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 506 return Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
668 } | 507 } |
OLD | NEW |