Chromium Code Reviews| 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/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
| 9 #include "chrome/browser/autocomplete_history_manager.h" | 9 #include "chrome/browser/autocomplete_history_manager.h" |
| 10 #include "chrome/browser/autofill/autofill_manager.h" | 10 #include "chrome/browser/autofill/autofill_manager.h" |
| 11 #include "chrome/browser/automation/automation_tab_helper.h" | 11 #include "chrome/browser/automation/automation_tab_helper.h" |
| 12 #include "chrome/browser/browser_process.h" | |
| 12 #include "chrome/browser/browser_shutdown.h" | 13 #include "chrome/browser/browser_shutdown.h" |
| 13 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 14 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
| 14 #include "chrome/browser/custom_handlers/protocol_handler.h" | 15 #include "chrome/browser/custom_handlers/protocol_handler.h" |
| 15 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" | 16 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
| 16 #include "chrome/browser/custom_handlers/register_protocol_handler_infobar_deleg ate.h" | 17 #include "chrome/browser/custom_handlers/register_protocol_handler_infobar_deleg ate.h" |
| 17 #include "chrome/browser/extensions/extension_tab_helper.h" | 18 #include "chrome/browser/extensions/extension_tab_helper.h" |
| 18 #include "chrome/browser/extensions/extension_webnavigation_api.h" | 19 #include "chrome/browser/extensions/extension_webnavigation_api.h" |
| 19 #include "chrome/browser/external_protocol/external_protocol_observer.h" | 20 #include "chrome/browser/external_protocol/external_protocol_observer.h" |
| 20 #include "chrome/browser/favicon/favicon_tab_helper.h" | 21 #include "chrome/browser/favicon/favicon_tab_helper.h" |
| 21 #include "chrome/browser/file_select_helper.h" | 22 #include "chrome/browser/file_select_helper.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 68 | 69 |
| 69 static base::LazyInstance<PropertyAccessor<TabContentsWrapper*> > | 70 static base::LazyInstance<PropertyAccessor<TabContentsWrapper*> > |
| 70 g_tab_contents_wrapper_property_accessor(base::LINKER_INITIALIZED); | 71 g_tab_contents_wrapper_property_accessor(base::LINKER_INITIALIZED); |
| 71 | 72 |
| 72 // The list of prefs we want to observe. | 73 // The list of prefs we want to observe. |
| 73 const char* kPrefsToObserve[] = { | 74 const char* kPrefsToObserve[] = { |
| 74 prefs::kAlternateErrorPagesEnabled, | 75 prefs::kAlternateErrorPagesEnabled, |
| 75 prefs::kDefaultCharset, | 76 prefs::kDefaultCharset, |
| 76 prefs::kDefaultZoomLevel, | 77 prefs::kDefaultZoomLevel, |
| 77 prefs::kEnableReferrers, | 78 prefs::kEnableReferrers, |
| 79 prefs::kSafeBrowsingEnabled, | |
|
mattm
2011/07/12 21:41:58
may need the ifdef?
Miranda Callahan
2011/07/13 18:13:51
Done.
| |
| 78 prefs::kWebKitAllowDisplayingInsecureContent, | 80 prefs::kWebKitAllowDisplayingInsecureContent, |
| 79 prefs::kWebKitAllowRunningInsecureContent, | 81 prefs::kWebKitAllowRunningInsecureContent, |
| 80 prefs::kWebKitDefaultFixedFontSize, | 82 prefs::kWebKitDefaultFixedFontSize, |
| 81 prefs::kWebKitDefaultFontSize, | 83 prefs::kWebKitDefaultFontSize, |
| 82 prefs::kWebKitFixedFontFamily, | 84 prefs::kWebKitFixedFontFamily, |
| 83 prefs::kWebKitJavaEnabled, | 85 prefs::kWebKitJavaEnabled, |
| 84 prefs::kWebKitJavascriptEnabled, | 86 prefs::kWebKitJavascriptEnabled, |
| 85 prefs::kWebKitLoadsImagesAutomatically, | 87 prefs::kWebKitLoadsImagesAutomatically, |
| 86 prefs::kWebKitMinimumFontSize, | 88 prefs::kWebKitMinimumFontSize, |
| 87 prefs::kWebKitMinimumLogicalFontSize, | 89 prefs::kWebKitMinimumLogicalFontSize, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 121 download_tab_helper_.reset(new DownloadTabHelper(this)); | 123 download_tab_helper_.reset(new DownloadTabHelper(this)); |
| 122 extension_tab_helper_.reset(new ExtensionTabHelper(this)); | 124 extension_tab_helper_.reset(new ExtensionTabHelper(this)); |
| 123 favicon_tab_helper_.reset(new FaviconTabHelper(contents)); | 125 favicon_tab_helper_.reset(new FaviconTabHelper(contents)); |
| 124 find_tab_helper_.reset(new FindTabHelper(contents)); | 126 find_tab_helper_.reset(new FindTabHelper(contents)); |
| 125 history_tab_helper_.reset(new HistoryTabHelper(contents)); | 127 history_tab_helper_.reset(new HistoryTabHelper(contents)); |
| 126 restore_tab_helper_.reset(new RestoreTabHelper(this)); | 128 restore_tab_helper_.reset(new RestoreTabHelper(this)); |
| 127 password_manager_delegate_.reset(new PasswordManagerDelegateImpl(this)); | 129 password_manager_delegate_.reset(new PasswordManagerDelegateImpl(this)); |
| 128 password_manager_.reset( | 130 password_manager_.reset( |
| 129 new PasswordManager(contents, password_manager_delegate_.get())); | 131 new PasswordManager(contents, password_manager_delegate_.get())); |
| 130 #if defined(ENABLE_SAFE_BROWSING) | 132 #if defined(ENABLE_SAFE_BROWSING) |
| 131 safebrowsing_detection_host_.reset( | 133 if (profile()->GetPrefs()->GetBoolean(prefs::kSafeBrowsingEnabled) && |
| 132 safe_browsing::ClientSideDetectionHost::Create(contents)); | 134 g_browser_process->safe_browsing_detection_service()) { |
| 135 safebrowsing_detection_host_.reset( | |
| 136 safe_browsing::ClientSideDetectionHost::Create(contents)); | |
| 137 } | |
| 133 #endif | 138 #endif |
| 134 search_engine_tab_helper_.reset(new SearchEngineTabHelper(contents)); | 139 search_engine_tab_helper_.reset(new SearchEngineTabHelper(contents)); |
| 135 ssl_helper_.reset(new TabContentsSSLHelper(this)); | 140 ssl_helper_.reset(new TabContentsSSLHelper(this)); |
| 136 content_settings_.reset(new TabSpecificContentSettings(contents)); | 141 content_settings_.reset(new TabSpecificContentSettings(contents)); |
| 137 translate_tab_helper_.reset(new TranslateTabHelper(contents)); | 142 translate_tab_helper_.reset(new TranslateTabHelper(contents)); |
| 138 print_view_manager_.reset(new printing::PrintViewManager(this)); | 143 print_view_manager_.reset(new printing::PrintViewManager(this)); |
| 139 | 144 |
| 140 // Create the per-tab observers. | 145 // Create the per-tab observers. |
| 141 external_protocol_observer_.reset(new ExternalProtocolObserver(contents)); | 146 external_protocol_observer_.reset(new ExternalProtocolObserver(contents)); |
| 142 file_select_observer_.reset(new FileSelectObserver(contents)); | 147 file_select_observer_.reset(new FileSelectObserver(contents)); |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 451 if (*pref_name_in == prefs::kAlternateErrorPagesEnabled) { | 456 if (*pref_name_in == prefs::kAlternateErrorPagesEnabled) { |
| 452 UpdateAlternateErrorPageURL(render_view_host()); | 457 UpdateAlternateErrorPageURL(render_view_host()); |
| 453 } else if ((*pref_name_in == prefs::kDefaultCharset) || | 458 } else if ((*pref_name_in == prefs::kDefaultCharset) || |
| 454 StartsWithASCII(*pref_name_in, "webkit.webprefs.", true)) { | 459 StartsWithASCII(*pref_name_in, "webkit.webprefs.", true)) { |
| 455 UpdateWebPreferences(); | 460 UpdateWebPreferences(); |
| 456 } else if (*pref_name_in == prefs::kDefaultZoomLevel) { | 461 } else if (*pref_name_in == prefs::kDefaultZoomLevel) { |
| 457 Send(new ViewMsg_SetZoomLevel( | 462 Send(new ViewMsg_SetZoomLevel( |
| 458 routing_id(), tab_contents()->GetZoomLevel())); | 463 routing_id(), tab_contents()->GetZoomLevel())); |
| 459 } else if (*pref_name_in == prefs::kEnableReferrers) { | 464 } else if (*pref_name_in == prefs::kEnableReferrers) { |
| 460 UpdateRendererPreferences(); | 465 UpdateRendererPreferences(); |
| 466 } else if (*pref_name_in == prefs::kSafeBrowsingEnabled) { | |
| 467 UpdateSafebrowsingDetectionHost(); | |
| 461 } else { | 468 } else { |
| 462 NOTREACHED() << "unexpected pref change notification" << *pref_name_in; | 469 NOTREACHED() << "unexpected pref change notification" << *pref_name_in; |
| 463 } | 470 } |
| 464 break; | 471 break; |
| 465 } | 472 } |
| 466 default: | 473 default: |
| 467 NOTREACHED(); | 474 NOTREACHED(); |
| 468 } | 475 } |
| 469 } | 476 } |
| 470 | 477 |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 624 RenderViewHostDelegate* rvhd = tab_contents(); | 631 RenderViewHostDelegate* rvhd = tab_contents(); |
| 625 Send(new ViewMsg_UpdateWebPreferences(routing_id(), rvhd->GetWebkitPrefs())); | 632 Send(new ViewMsg_UpdateWebPreferences(routing_id(), rvhd->GetWebkitPrefs())); |
| 626 } | 633 } |
| 627 | 634 |
| 628 void TabContentsWrapper::UpdateRendererPreferences() { | 635 void TabContentsWrapper::UpdateRendererPreferences() { |
| 629 renderer_preferences_util::UpdateFromSystemSettings( | 636 renderer_preferences_util::UpdateFromSystemSettings( |
| 630 tab_contents()->GetMutableRendererPrefs(), profile()); | 637 tab_contents()->GetMutableRendererPrefs(), profile()); |
| 631 render_view_host()->SyncRendererPrefs(); | 638 render_view_host()->SyncRendererPrefs(); |
| 632 } | 639 } |
| 633 | 640 |
| 641 void TabContentsWrapper::UpdateSafebrowsingDetectionHost() { | |
|
mattm
2011/07/12 21:41:58
ifdef
Miranda Callahan
2011/07/13 18:13:51
Done.
| |
| 642 PrefService* prefs = profile()->GetPrefs(); | |
| 643 bool safe_browsing = prefs->GetBoolean(prefs::kSafeBrowsingEnabled); | |
| 644 if (safe_browsing && | |
| 645 g_browser_process->safe_browsing_detection_service()) { | |
| 646 if (!safebrowsing_detection_host_.get()) { | |
| 647 safebrowsing_detection_host_.reset( | |
| 648 safe_browsing::ClientSideDetectionHost::Create(tab_contents())); | |
| 649 } | |
| 650 } else { | |
| 651 safebrowsing_detection_host_.reset(); | |
| 652 } | |
| 653 render_view_host()->Send( | |
| 654 new ViewMsg_SetClientSidePhishingDetection(routing_id(), safe_browsing)); | |
| 655 } | |
| 656 | |
| 634 void TabContentsWrapper::RemoveInfoBarInternal(InfoBarDelegate* delegate, | 657 void TabContentsWrapper::RemoveInfoBarInternal(InfoBarDelegate* delegate, |
| 635 bool animate) { | 658 bool animate) { |
| 636 if (!infobars_enabled_) { | 659 if (!infobars_enabled_) { |
| 637 DCHECK(infobars_.empty()); | 660 DCHECK(infobars_.empty()); |
| 638 return; | 661 return; |
| 639 } | 662 } |
| 640 | 663 |
| 641 size_t i; | 664 size_t i; |
| 642 for (i = 0; i < infobars_.size(); ++i) { | 665 for (i = 0; i < infobars_.size(); ++i) { |
| 643 if (GetInfoBarDelegateAt(i) == delegate) | 666 if (GetInfoBarDelegateAt(i) == delegate) |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 657 if (infobars_.empty()) { | 680 if (infobars_.empty()) { |
| 658 registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 681 registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
| 659 Source<NavigationController>(&tab_contents_->controller())); | 682 Source<NavigationController>(&tab_contents_->controller())); |
| 660 } | 683 } |
| 661 } | 684 } |
| 662 | 685 |
| 663 void TabContentsWrapper::RemoveAllInfoBars(bool animate) { | 686 void TabContentsWrapper::RemoveAllInfoBars(bool animate) { |
| 664 while (!infobars_.empty()) | 687 while (!infobars_.empty()) |
| 665 RemoveInfoBarInternal(GetInfoBarDelegateAt(infobar_count() - 1), animate); | 688 RemoveInfoBarInternal(GetInfoBarDelegateAt(infobar_count() - 1), animate); |
| 666 } | 689 } |
| OLD | NEW |