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/tab_contents/tab_contents_wrapper.h" | 5 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
6 | 6 |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 #include "chrome/browser/themes/theme_service_factory.h" | 42 #include "chrome/browser/themes/theme_service_factory.h" |
43 #include "chrome/browser/translate/translate_tab_helper.h" | 43 #include "chrome/browser/translate/translate_tab_helper.h" |
44 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" | 44 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" |
45 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" | 45 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" |
46 #include "chrome/browser/ui/constrained_window_tab_helper.h" | 46 #include "chrome/browser/ui/constrained_window_tab_helper.h" |
47 #include "chrome/browser/ui/find_bar/find_tab_helper.h" | 47 #include "chrome/browser/ui/find_bar/find_tab_helper.h" |
48 #include "chrome/browser/ui/intents/web_intent_picker_factory_impl.h" | 48 #include "chrome/browser/ui/intents/web_intent_picker_factory_impl.h" |
49 #include "chrome/browser/ui/intents/web_intent_picker_controller.h" | 49 #include "chrome/browser/ui/intents/web_intent_picker_controller.h" |
50 #include "chrome/browser/ui/sad_tab_observer.h" | 50 #include "chrome/browser/ui/sad_tab_observer.h" |
51 #include "chrome/browser/ui/search_engines/search_engine_tab_helper.h" | 51 #include "chrome/browser/ui/search_engines/search_engine_tab_helper.h" |
| 52 #include "chrome/browser/ui/tab_contents/per_tab_prefs_tab_helper.h" |
52 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper_delegate.h" | 53 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper_delegate.h" |
53 #include "chrome/common/chrome_notification_types.h" | 54 #include "chrome/common/chrome_notification_types.h" |
54 #include "chrome/common/chrome_switches.h" | 55 #include "chrome/common/chrome_switches.h" |
55 #include "chrome/common/pref_names.h" | 56 #include "chrome/common/pref_names.h" |
56 #include "chrome/common/render_messages.h" | 57 #include "chrome/common/render_messages.h" |
57 #include "content/browser/renderer_host/render_view_host.h" | 58 #include "content/browser/renderer_host/render_view_host.h" |
58 #include "content/browser/tab_contents/tab_contents_view.h" | 59 #include "content/browser/tab_contents/tab_contents_view.h" |
59 #include "content/public/browser/notification_service.h" | 60 #include "content/public/browser/notification_service.h" |
60 #include "grit/generated_resources.h" | 61 #include "grit/generated_resources.h" |
61 #include "grit/locale_settings.h" | 62 #include "grit/locale_settings.h" |
(...skipping 15 matching lines...) Expand all Loading... |
77 #if defined (ENABLE_SAFE_BROWSING) | 78 #if defined (ENABLE_SAFE_BROWSING) |
78 prefs::kSafeBrowsingEnabled, | 79 prefs::kSafeBrowsingEnabled, |
79 #endif | 80 #endif |
80 prefs::kWebKitAllowDisplayingInsecureContent, | 81 prefs::kWebKitAllowDisplayingInsecureContent, |
81 prefs::kWebKitAllowRunningInsecureContent, | 82 prefs::kWebKitAllowRunningInsecureContent, |
82 prefs::kWebKitCursiveFontFamily, | 83 prefs::kWebKitCursiveFontFamily, |
83 prefs::kWebKitDefaultFixedFontSize, | 84 prefs::kWebKitDefaultFixedFontSize, |
84 prefs::kWebKitDefaultFontSize, | 85 prefs::kWebKitDefaultFontSize, |
85 prefs::kWebKitFantasyFontFamily, | 86 prefs::kWebKitFantasyFontFamily, |
86 prefs::kWebKitFixedFontFamily, | 87 prefs::kWebKitFixedFontFamily, |
| 88 prefs::kWebKitGlobalJavascriptEnabled, |
87 prefs::kWebKitJavaEnabled, | 89 prefs::kWebKitJavaEnabled, |
88 prefs::kWebKitJavascriptEnabled, | |
89 prefs::kWebKitLoadsImagesAutomatically, | 90 prefs::kWebKitLoadsImagesAutomatically, |
90 prefs::kWebKitMinimumFontSize, | 91 prefs::kWebKitMinimumFontSize, |
91 prefs::kWebKitMinimumLogicalFontSize, | 92 prefs::kWebKitMinimumLogicalFontSize, |
92 prefs::kWebKitPluginsEnabled, | 93 prefs::kWebKitPluginsEnabled, |
93 prefs::kWebKitSansSerifFontFamily, | 94 prefs::kWebKitSansSerifFontFamily, |
94 prefs::kWebKitSerifFontFamily, | 95 prefs::kWebKitSerifFontFamily, |
95 prefs::kWebKitStandardFontFamily, | 96 prefs::kWebKitStandardFontFamily, |
96 prefs::kWebkitTabsToLinks, | 97 prefs::kWebkitTabsToLinks, |
97 prefs::kWebKitUsesUniversalDetector | 98 prefs::kWebKitUsesUniversalDetector |
98 }; | 99 }; |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 bookmark_tab_helper_.reset(new BookmarkTabHelper(this)); | 276 bookmark_tab_helper_.reset(new BookmarkTabHelper(this)); |
276 constrained_window_tab_helper_.reset(new ConstrainedWindowTabHelper(this)); | 277 constrained_window_tab_helper_.reset(new ConstrainedWindowTabHelper(this)); |
277 extension_tab_helper_.reset(new ExtensionTabHelper(this)); | 278 extension_tab_helper_.reset(new ExtensionTabHelper(this)); |
278 favicon_tab_helper_.reset(new FaviconTabHelper(contents)); | 279 favicon_tab_helper_.reset(new FaviconTabHelper(contents)); |
279 find_tab_helper_.reset(new FindTabHelper(contents)); | 280 find_tab_helper_.reset(new FindTabHelper(contents)); |
280 history_tab_helper_.reset(new HistoryTabHelper(contents)); | 281 history_tab_helper_.reset(new HistoryTabHelper(contents)); |
281 infobar_tab_helper_.reset(new InfoBarTabHelper(contents)); | 282 infobar_tab_helper_.reset(new InfoBarTabHelper(contents)); |
282 password_manager_delegate_.reset(new PasswordManagerDelegateImpl(this)); | 283 password_manager_delegate_.reset(new PasswordManagerDelegateImpl(this)); |
283 password_manager_.reset( | 284 password_manager_.reset( |
284 new PasswordManager(contents, password_manager_delegate_.get())); | 285 new PasswordManager(contents, password_manager_delegate_.get())); |
| 286 per_tab_prefs_tab_helper_.reset(new PerTabPrefsTabHelper(this)); |
285 prerender_tab_helper_.reset(new prerender::PrerenderTabHelper(this)); | 287 prerender_tab_helper_.reset(new prerender::PrerenderTabHelper(this)); |
286 print_view_manager_.reset(new printing::PrintViewManager(this)); | 288 print_view_manager_.reset(new printing::PrintViewManager(this)); |
287 restore_tab_helper_.reset(new RestoreTabHelper(this)); | 289 restore_tab_helper_.reset(new RestoreTabHelper(this)); |
288 #if defined(ENABLE_SAFE_BROWSING) | 290 #if defined(ENABLE_SAFE_BROWSING) |
289 if (profile()->GetPrefs()->GetBoolean(prefs::kSafeBrowsingEnabled) && | 291 if (profile()->GetPrefs()->GetBoolean(prefs::kSafeBrowsingEnabled) && |
290 g_browser_process->safe_browsing_detection_service()) { | 292 g_browser_process->safe_browsing_detection_service()) { |
291 safebrowsing_detection_host_.reset( | 293 safebrowsing_detection_host_.reset( |
292 safe_browsing::ClientSideDetectionHost::Create(contents)); | 294 safe_browsing::ClientSideDetectionHost::Create(contents)); |
293 } | 295 } |
294 #endif | 296 #endif |
295 search_engine_tab_helper_.reset(new SearchEngineTabHelper(contents)); | 297 search_engine_tab_helper_.reset(new SearchEngineTabHelper(contents)); |
296 ssl_helper_.reset(new TabContentsSSLHelper(this)); | 298 ssl_helper_.reset(new TabContentsSSLHelper(this)); |
297 content_settings_.reset(new TabSpecificContentSettings(contents)); | 299 content_settings_.reset(new TabSpecificContentSettings(contents)); |
298 translate_tab_helper_.reset(new TranslateTabHelper(contents)); | 300 translate_tab_helper_.reset(new TranslateTabHelper(contents)); |
299 web_intent_picker_controller_.reset(new WebIntentPickerController( | 301 web_intent_picker_controller_.reset(new WebIntentPickerController( |
300 this, new WebIntentPickerFactoryImpl())); | 302 this, new WebIntentPickerFactoryImpl())); |
301 | 303 |
302 // Create the per-tab observers. | 304 // Create the per-tab observers. |
303 download_request_limiter_observer_.reset( | 305 download_request_limiter_observer_.reset( |
304 new DownloadRequestLimiterObserver(contents)); | 306 new DownloadRequestLimiterObserver(contents)); |
305 webnavigation_observer_.reset( | 307 webnavigation_observer_.reset( |
306 new ExtensionWebNavigationTabObserver(contents)); | 308 new ExtensionWebNavigationTabObserver(contents)); |
307 external_protocol_observer_.reset(new ExternalProtocolObserver(contents)); | 309 external_protocol_observer_.reset(new ExternalProtocolObserver(contents)); |
308 plugin_observer_.reset(new PluginObserver(this)); | 310 plugin_observer_.reset(new PluginObserver(this)); |
309 per_tab_prefs_.reset( | |
310 profile()->GetPrefs()->CreatePrefServiceWithPerTabPrefStore()); | |
311 print_preview_.reset(new printing::PrintPreviewMessageHandler(contents)); | 311 print_preview_.reset(new printing::PrintPreviewMessageHandler(contents)); |
312 sad_tab_observer_.reset(new SadTabObserver(contents)); | 312 sad_tab_observer_.reset(new SadTabObserver(contents)); |
313 // Start the in-browser thumbnailing if the feature is enabled. | 313 // Start the in-browser thumbnailing if the feature is enabled. |
314 if (switches::IsInBrowserThumbnailingEnabled()) { | 314 if (switches::IsInBrowserThumbnailingEnabled()) { |
315 thumbnail_generation_observer_.reset(new ThumbnailGenerator); | 315 thumbnail_generation_observer_.reset(new ThumbnailGenerator); |
316 thumbnail_generation_observer_->StartThumbnailing(tab_contents_.get()); | 316 thumbnail_generation_observer_->StartThumbnailing(tab_contents_.get()); |
317 } | 317 } |
318 | 318 |
319 // Set-up the showing of the omnibox search infobar if applicable. | 319 // Set-up the showing of the omnibox search infobar if applicable. |
320 if (OmniboxSearchHint::IsEnabled(profile())) | 320 if (OmniboxSearchHint::IsEnabled(profile())) |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 return g_tab_contents_wrapper_property_accessor.Pointer(); | 367 return g_tab_contents_wrapper_property_accessor.Pointer(); |
368 } | 368 } |
369 | 369 |
370 // static | 370 // static |
371 void TabContentsWrapper::RegisterUserPrefs(PrefService* prefs) { | 371 void TabContentsWrapper::RegisterUserPrefs(PrefService* prefs) { |
372 prefs->RegisterBooleanPref(prefs::kAlternateErrorPagesEnabled, | 372 prefs->RegisterBooleanPref(prefs::kAlternateErrorPagesEnabled, |
373 true, | 373 true, |
374 PrefService::SYNCABLE_PREF); | 374 PrefService::SYNCABLE_PREF); |
375 | 375 |
376 WebPreferences pref_defaults; | 376 WebPreferences pref_defaults; |
377 prefs->RegisterBooleanPref(prefs::kWebKitJavascriptEnabled, | 377 prefs->RegisterBooleanPref(prefs::kWebKitGlobalJavascriptEnabled, |
378 pref_defaults.javascript_enabled, | 378 pref_defaults.javascript_enabled, |
379 PrefService::UNSYNCABLE_PREF); | 379 PrefService::UNSYNCABLE_PREF); |
380 prefs->RegisterBooleanPref(prefs::kWebKitWebSecurityEnabled, | 380 prefs->RegisterBooleanPref(prefs::kWebKitWebSecurityEnabled, |
381 pref_defaults.web_security_enabled, | 381 pref_defaults.web_security_enabled, |
382 PrefService::UNSYNCABLE_PREF); | 382 PrefService::UNSYNCABLE_PREF); |
383 prefs->RegisterBooleanPref( | 383 prefs->RegisterBooleanPref( |
384 prefs::kWebKitJavascriptCanOpenWindowsAutomatically, | 384 prefs::kWebKitJavascriptCanOpenWindowsAutomatically, |
385 true, | 385 true, |
386 PrefService::UNSYNCABLE_PREF); | 386 PrefService::UNSYNCABLE_PREF); |
387 prefs->RegisterBooleanPref(prefs::kWebKitLoadsImagesAutomatically, | 387 prefs->RegisterBooleanPref(prefs::kWebKitLoadsImagesAutomatically, |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
625 break; | 625 break; |
626 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 626 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
627 case chrome::NOTIFICATION_BROWSER_THEME_CHANGED: { | 627 case chrome::NOTIFICATION_BROWSER_THEME_CHANGED: { |
628 UpdateRendererPreferences(); | 628 UpdateRendererPreferences(); |
629 break; | 629 break; |
630 } | 630 } |
631 #endif | 631 #endif |
632 case chrome::NOTIFICATION_PREF_CHANGED: { | 632 case chrome::NOTIFICATION_PREF_CHANGED: { |
633 std::string* pref_name_in = content::Details<std::string>(details).ptr(); | 633 std::string* pref_name_in = content::Details<std::string>(details).ptr(); |
634 DCHECK(content::Source<PrefService>(source).ptr() == | 634 DCHECK(content::Source<PrefService>(source).ptr() == |
635 profile()->GetPrefs()); | 635 profile()->GetPrefs() || |
| 636 content::Source<PrefService>(source).ptr() == |
| 637 per_tab_prefs_tab_helper_->prefs()); |
636 if (*pref_name_in == prefs::kAlternateErrorPagesEnabled) { | 638 if (*pref_name_in == prefs::kAlternateErrorPagesEnabled) { |
637 UpdateAlternateErrorPageURL(render_view_host()); | 639 UpdateAlternateErrorPageURL(render_view_host()); |
638 } else if ((*pref_name_in == prefs::kDefaultCharset) || | 640 } else if ((*pref_name_in == prefs::kDefaultCharset) || |
639 StartsWithASCII(*pref_name_in, "webkit.webprefs.", true)) { | 641 StartsWithASCII(*pref_name_in, "webkit.webprefs.", true)) { |
640 UpdateWebPreferences(); | 642 UpdateWebPreferences(); |
641 } else if (*pref_name_in == prefs::kDefaultZoomLevel) { | 643 } else if (*pref_name_in == prefs::kDefaultZoomLevel) { |
642 tab_contents()->render_view_host()->SetZoomLevel( | 644 tab_contents()->render_view_host()->SetZoomLevel( |
643 tab_contents()->GetZoomLevel()); | 645 tab_contents()->GetZoomLevel()); |
644 } else if (*pref_name_in == prefs::kEnableReferrers) { | 646 } else if (*pref_name_in == prefs::kEnableReferrers) { |
645 UpdateRendererPreferences(); | 647 UpdateRendererPreferences(); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
683 } | 685 } |
684 return url; | 686 return url; |
685 } | 687 } |
686 | 688 |
687 void TabContentsWrapper::UpdateAlternateErrorPageURL(RenderViewHost* rvh) { | 689 void TabContentsWrapper::UpdateAlternateErrorPageURL(RenderViewHost* rvh) { |
688 rvh->SetAltErrorPageURL(GetAlternateErrorPageURL()); | 690 rvh->SetAltErrorPageURL(GetAlternateErrorPageURL()); |
689 } | 691 } |
690 | 692 |
691 void TabContentsWrapper::UpdateWebPreferences() { | 693 void TabContentsWrapper::UpdateWebPreferences() { |
692 RenderViewHostDelegate* rvhd = tab_contents(); | 694 RenderViewHostDelegate* rvhd = tab_contents(); |
693 tab_contents()->render_view_host()->UpdateWebkitPreferences( | 695 WebPreferences prefs = rvhd->GetWebkitPrefs(); |
694 rvhd->GetWebkitPrefs()); | 696 per_tab_prefs_tab_helper_->OverrideWebPreferences(&prefs); |
| 697 tab_contents()->render_view_host()->UpdateWebkitPreferences(prefs); |
695 } | 698 } |
696 | 699 |
697 void TabContentsWrapper::UpdateRendererPreferences() { | 700 void TabContentsWrapper::UpdateRendererPreferences() { |
698 renderer_preferences_util::UpdateFromSystemSettings( | 701 renderer_preferences_util::UpdateFromSystemSettings( |
699 tab_contents()->GetMutableRendererPrefs(), profile()); | 702 tab_contents()->GetMutableRendererPrefs(), profile()); |
700 render_view_host()->SyncRendererPrefs(); | 703 render_view_host()->SyncRendererPrefs(); |
701 } | 704 } |
702 | 705 |
703 void TabContentsWrapper::UpdateSafebrowsingDetectionHost() { | 706 void TabContentsWrapper::UpdateSafebrowsingDetectionHost() { |
704 #if defined(ENABLE_SAFE_BROWSING) | 707 #if defined(ENABLE_SAFE_BROWSING) |
(...skipping 11 matching lines...) Expand all Loading... |
716 render_view_host()->Send( | 719 render_view_host()->Send( |
717 new ChromeViewMsg_SetClientSidePhishingDetection(routing_id(), | 720 new ChromeViewMsg_SetClientSidePhishingDetection(routing_id(), |
718 safe_browsing)); | 721 safe_browsing)); |
719 #endif | 722 #endif |
720 } | 723 } |
721 | 724 |
722 void TabContentsWrapper::ExitFullscreenMode() { | 725 void TabContentsWrapper::ExitFullscreenMode() { |
723 if (tab_contents() && render_view_host()) | 726 if (tab_contents() && render_view_host()) |
724 tab_contents()->render_view_host()->ExitFullscreen(); | 727 tab_contents()->render_view_host()->ExitFullscreen(); |
725 } | 728 } |
OLD | NEW |