OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/stringprintf.h" | 7 #include "base/stringprintf.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
11 #include "chrome/browser/prefs/overlay_user_pref_store.h" | |
11 #include "chrome/browser/prefs/pref_service.h" | 12 #include "chrome/browser/prefs/pref_service.h" |
12 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/renderer_preferences_util.h" | 14 #include "chrome/browser/renderer_preferences_util.h" |
14 #include "chrome/browser/themes/theme_service.h" | 15 #include "chrome/browser/themes/theme_service.h" |
15 #include "chrome/browser/themes/theme_service_factory.h" | 16 #include "chrome/browser/themes/theme_service_factory.h" |
16 #include "chrome/browser/ui/constrained_window_tab_helper.h" | 17 #include "chrome/browser/ui/constrained_window_tab_helper.h" |
17 #include "chrome/common/chrome_notification_types.h" | 18 #include "chrome/common/chrome_notification_types.h" |
18 #include "chrome/common/pref_names.h" | 19 #include "chrome/common/pref_names.h" |
19 #include "content/browser/renderer_host/render_view_host.h" | 20 #include "content/browser/renderer_host/render_view_host.h" |
20 #include "content/browser/renderer_host/render_view_host_delegate.h" | 21 #include "content/browser/renderer_host/render_view_host_delegate.h" |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
359 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, | 360 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, |
360 content::Source<ThemeService>( | 361 content::Source<ThemeService>( |
361 ThemeServiceFactory::GetForProfile(GetProfile()))); | 362 ThemeServiceFactory::GetForProfile(GetProfile()))); |
362 #endif | 363 #endif |
363 } | 364 } |
364 | 365 |
365 PrefsTabHelper::~PrefsTabHelper() { | 366 PrefsTabHelper::~PrefsTabHelper() { |
366 } | 367 } |
367 | 368 |
368 // static | 369 // static |
370 void PrefsTabHelper::InitIncognitoUserPrefStore( | |
371 OverlayUserPrefStore* pref_store) { | |
372 // List of keys that cannot be changed in the user prefs file by the incognito | |
373 // profile. All preferences that store information about the browsing history | |
374 // or behavior of the user should have this property. | |
375 pref_store->RegisterOverlayPref(prefs::kBrowserWindowPlacement); | |
376 } | |
377 | |
378 // static | |
379 void PrefsTabHelper::InitPerTabUserPrefStore( | |
380 OverlayUserPrefStore* pref_store) { | |
381 // List of keys that have per-tab and per-profile (Global) counterpart. | |
382 // Setting a per-profile preference affects all tabs sharing the profile, | |
383 // unless a tab has specified its own per-tab property value. Changing a | |
384 // per-profile preference on a per-tab pref store delegates to underlay | |
Peter Kasting
2012/01/05 17:23:43
Nit: "underlay" -> "the underlying"
mnaganov (inactive)
2012/01/05 17:31:30
Done.
| |
385 // per-profile pref store. | |
386 pref_store->RegisterOverlayPref( | |
387 prefs::kWebKitJavascriptEnabled, | |
388 prefs::kWebKitGlobalJavascriptEnabled); | |
389 pref_store->RegisterOverlayPref( | |
390 prefs::kWebKitJavascriptCanOpenWindowsAutomatically, | |
391 prefs::kWebKitGlobalJavascriptCanOpenWindowsAutomatically); | |
392 pref_store->RegisterOverlayPref( | |
393 prefs::kWebKitLoadsImagesAutomatically, | |
394 prefs::kWebKitGlobalLoadsImagesAutomatically); | |
395 pref_store->RegisterOverlayPref( | |
396 prefs::kWebKitPluginsEnabled, | |
397 prefs::kWebKitGlobalPluginsEnabled); | |
398 pref_store->RegisterOverlayPref( | |
399 prefs::kDefaultCharset, | |
400 prefs::kGlobalDefaultCharset); | |
401 pref_store->RegisterOverlayPref( | |
402 prefs::kWebKitStandardFontFamily, | |
403 prefs::kWebKitGlobalStandardFontFamily); | |
404 pref_store->RegisterOverlayPref( | |
405 prefs::kWebKitFixedFontFamily, | |
406 prefs::kWebKitGlobalFixedFontFamily); | |
407 pref_store->RegisterOverlayPref( | |
408 prefs::kWebKitSerifFontFamily, | |
409 prefs::kWebKitGlobalSerifFontFamily); | |
410 pref_store->RegisterOverlayPref( | |
411 prefs::kWebKitSansSerifFontFamily, | |
412 prefs::kWebKitGlobalSansSerifFontFamily); | |
413 pref_store->RegisterOverlayPref( | |
414 prefs::kWebKitCursiveFontFamily, | |
415 prefs::kWebKitGlobalCursiveFontFamily); | |
416 pref_store->RegisterOverlayPref( | |
417 prefs::kWebKitFantasyFontFamily, | |
418 prefs::kWebKitGlobalFantasyFontFamily); | |
419 pref_store->RegisterOverlayPref( | |
420 prefs::kWebKitDefaultFontSize, | |
421 prefs::kWebKitGlobalDefaultFontSize); | |
422 pref_store->RegisterOverlayPref( | |
423 prefs::kWebKitDefaultFixedFontSize, | |
424 prefs::kWebKitGlobalDefaultFixedFontSize); | |
425 pref_store->RegisterOverlayPref( | |
426 prefs::kWebKitMinimumFontSize, | |
427 prefs::kWebKitGlobalMinimumFontSize); | |
428 pref_store->RegisterOverlayPref( | |
429 prefs::kWebKitMinimumLogicalFontSize, | |
430 prefs::kWebKitGlobalMinimumLogicalFontSize); | |
431 } | |
432 | |
433 // static | |
369 void PrefsTabHelper::RegisterUserPrefs(PrefService* prefs) { | 434 void PrefsTabHelper::RegisterUserPrefs(PrefService* prefs) { |
370 WebPreferences pref_defaults; | 435 WebPreferences pref_defaults; |
371 prefs->RegisterBooleanPref(prefs::kWebKitGlobalJavascriptEnabled, | 436 prefs->RegisterBooleanPref(prefs::kWebKitGlobalJavascriptEnabled, |
372 pref_defaults.javascript_enabled, | 437 pref_defaults.javascript_enabled, |
373 PrefService::UNSYNCABLE_PREF); | 438 PrefService::UNSYNCABLE_PREF); |
374 prefs->RegisterBooleanPref(prefs::kWebKitWebSecurityEnabled, | 439 prefs->RegisterBooleanPref(prefs::kWebKitWebSecurityEnabled, |
375 pref_defaults.web_security_enabled, | 440 pref_defaults.web_security_enabled, |
376 PrefService::UNSYNCABLE_PREF); | 441 PrefService::UNSYNCABLE_PREF); |
377 prefs->RegisterBooleanPref( | 442 prefs->RegisterBooleanPref( |
378 prefs::kWebKitGlobalJavascriptCanOpenWindowsAutomatically, | 443 prefs::kWebKitGlobalJavascriptCanOpenWindowsAutomatically, |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
576 | 641 |
577 void PrefsTabHelper::UpdateRendererPreferences() { | 642 void PrefsTabHelper::UpdateRendererPreferences() { |
578 renderer_preferences_util::UpdateFromSystemSettings( | 643 renderer_preferences_util::UpdateFromSystemSettings( |
579 web_contents()->GetMutableRendererPrefs(), GetProfile()); | 644 web_contents()->GetMutableRendererPrefs(), GetProfile()); |
580 web_contents()->GetRenderViewHost()->SyncRendererPrefs(); | 645 web_contents()->GetRenderViewHost()->SyncRendererPrefs(); |
581 } | 646 } |
582 | 647 |
583 Profile* PrefsTabHelper::GetProfile() { | 648 Profile* PrefsTabHelper::GetProfile() { |
584 return Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 649 return Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
585 } | 650 } |
OLD | NEW |