diff options
Diffstat (limited to 'chrome/browser/ui')
14 files changed, 69 insertions, 248 deletions
diff --git a/chrome/browser/ui/autologin_infobar_delegate.cc b/chrome/browser/ui/autologin_infobar_delegate.cc index ddf3c95..0b2f078 100644 --- a/chrome/browser/ui/autologin_infobar_delegate.cc +++ b/chrome/browser/ui/autologin_infobar_delegate.cc @@ -10,6 +10,7 @@ #include "base/string_split.h" #include "base/stringprintf.h" #include "base/utf_string_conversions.h" +#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/net/gaia/token_service.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" @@ -249,7 +250,7 @@ void AutoLoginInfoBarDelegate::Observe(int type, const NotificationDetails& details) { if (type == content::NOTIFICATION_LOAD_STOP) { // The wrapper takes ownership of this delegate. - tab_contents_wrapper_->AddInfoBar(this); + tab_contents_wrapper_->infobar_tab_helper()->AddInfoBar(this); registrar_.RemoveAll(); } else if (type == content::NOTIFICATION_TAB_CONTENTS_DESTROYED) { // The tab contents was destroyed before the naviagation completed, so diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index e7d3e46..92491f8 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -51,6 +51,7 @@ #include "chrome/browser/first_run/first_run.h" #include "chrome/browser/google/google_url_tracker.h" #include "chrome/browser/google/google_util.h" +#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/instant/instant_controller.h" #include "chrome/browser/instant/instant_unload_handler.h" #include "chrome/browser/intents/register_intent_handler_infobar_delegate.h" @@ -2435,7 +2436,7 @@ void Browser::JSOutOfMemoryHelper(TabContents* tab) { TabContentsWrapper* tcw = TabContentsWrapper::GetCurrentWrapperForContents( tab); if (tcw) { - tcw->AddInfoBar(new SimpleAlertInfoBarDelegate( + tcw->infobar_tab_helper()->AddInfoBar(new SimpleAlertInfoBarDelegate( tab, NULL, l10n_util::GetStringUTF16(IDS_JS_OUT_OF_MEMORY_PROMPT), true)); } @@ -2469,9 +2470,8 @@ void Browser::RegisterProtocolHandlerHelper(TabContents* tab, registry->CanSchemeBeOverridden(handler.protocol())) { UserMetrics::RecordAction( UserMetricsAction("RegisterProtocolHandler.InfoBar_Shown")); - tcw->AddInfoBar(new RegisterProtocolHandlerInfoBarDelegate(tab, - registry, - handler)); + tcw->infobar_tab_helper()->AddInfoBar( + new RegisterProtocolHandlerInfoBarDelegate(tab, registry, handler)); } } @@ -2500,7 +2500,8 @@ void Browser::RegisterIntentHandlerHelper(TabContents* tab, intent.action = action; intent.type = type; intent.title = title; - tcw->AddInfoBar(new RegisterIntentHandlerInfoBarDelegate(tab, intent)); + tcw->infobar_tab_helper()->AddInfoBar( + new RegisterIntentHandlerInfoBarDelegate(tab, intent)); } // static @@ -3710,7 +3711,7 @@ void Browser::RendererResponsive(TabContents* source) { void Browser::WorkerCrashed(TabContents* source) { TabContentsWrapper* wrapper = TabContentsWrapper::GetCurrentWrapperForContents(source); - wrapper->AddInfoBar(new SimpleAlertInfoBarDelegate( + wrapper->infobar_tab_helper()->AddInfoBar(new SimpleAlertInfoBarDelegate( source, NULL, l10n_util::GetStringUTF16(IDS_WEBWORKER_CRASHED_PROMPT), true)); } diff --git a/chrome/browser/ui/browser_init.cc b/chrome/browser/ui/browser_init.cc index 1e082ba..7aed22f 100644 --- a/chrome/browser/ui/browser_init.cc +++ b/chrome/browser/ui/browser_init.cc @@ -30,6 +30,7 @@ #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/pack_extension_job.h" #include "chrome/browser/first_run/first_run.h" +#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/net/predictor_api.h" #include "chrome/browser/net/url_fixer_upper.h" #include "chrome/browser/notifications/desktop_notification_service.h" @@ -258,9 +259,10 @@ void NotifyNotDefaultBrowserTask::Run() { // In ChromeBot tests, there might be a race. This line appears to get // called during shutdown and |tab| can be NULL. TabContentsWrapper* tab = browser->GetSelectedTabContentsWrapper(); - if (!tab || tab->infobar_count() > 0) + if (!tab || tab->infobar_tab_helper()->infobar_count() > 0) return; - tab->AddInfoBar(new DefaultBrowserInfoBarDelegate(tab->tab_contents())); + tab->infobar_tab_helper()->AddInfoBar( + new DefaultBrowserInfoBarDelegate(tab->tab_contents())); } @@ -1104,7 +1106,7 @@ void BrowserInit::LaunchWithProfile::AddCrashedInfoBarIfNecessary( // The last session didn't exit cleanly. Show an infobar to the user // so that they can restore if they want. The delegate deletes itself when // it is closed. - tab->AddInfoBar( + tab->infobar_tab_helper()->AddInfoBar( new SessionCrashedInfoBarDelegate(profile_, tab->tab_contents())); } } @@ -1130,10 +1132,13 @@ void BrowserInit::LaunchWithProfile::AddBadFlagsInfoBarIfNecessary( } if (bad_flag) { - tab->AddInfoBar(new SimpleAlertInfoBarDelegate(tab->tab_contents(), NULL, - l10n_util::GetStringFUTF16(IDS_BAD_FLAGS_WARNING_MESSAGE, - UTF8ToUTF16(std::string("--") + bad_flag)), - false)); + tab->infobar_tab_helper()->AddInfoBar( + new SimpleAlertInfoBarDelegate( + tab->tab_contents(), NULL, + l10n_util::GetStringFUTF16( + IDS_BAD_FLAGS_WARNING_MESSAGE, + UTF8ToUTF16(std::string("--") + bad_flag)), + false)); } } @@ -1197,9 +1202,10 @@ void BrowserInit::LaunchWithProfile:: "http://dev.chromium.org/dnscertprovenancechecking"; string16 message = l10n_util::GetStringUTF16( IDS_DNS_CERT_PROVENANCE_CHECKING_WARNING_MESSAGE); - tab->AddInfoBar(new LearnMoreInfoBar(tab->tab_contents(), - message, - GURL(kLearnMoreURL))); + tab->infobar_tab_helper()->AddInfoBar( + new LearnMoreInfoBar(tab->tab_contents(), + message, + GURL(kLearnMoreURL))); } void BrowserInit::LaunchWithProfile::AddObsoleteSystemInfoBarIfNecessary( @@ -1220,9 +1226,10 @@ void BrowserInit::LaunchWithProfile::AddObsoleteSystemInfoBarIfNecessary( // Link to an article in the help center on minimum system requirements. const char* kLearnMoreURL = "http://www.google.com/support/chrome/bin/answer.py?answer=95411"; - tab->AddInfoBar(new LearnMoreInfoBar(tab->tab_contents(), - message, - GURL(kLearnMoreURL))); + tab->infobar_tab_helper()->AddInfoBar( + new LearnMoreInfoBar(tab->tab_contents(), + message, + GURL(kLearnMoreURL))); } #endif } diff --git a/chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.mm b/chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.mm index 34fa8f9..35b43f1 100644 --- a/chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.mm +++ b/chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.mm @@ -10,6 +10,7 @@ #include "base/sys_string_conversions.h" #include "chrome/browser/content_settings/host_content_settings_map.h" #include "chrome/browser/content_settings/tab_specific_content_settings.h" +#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/cocoa/constrained_window_mac.h" #import "chrome/browser/ui/cocoa/content_settings/cookie_details_view_controller.h" @@ -219,7 +220,8 @@ void CollectedCookiesMac::OnSheetDidEnd(NSWindow* sheet) { - (void)windowWillClose:(NSNotification*)notif { if (contentSettingsChanged_) { TabContentsWrapper::GetCurrentWrapperForContents(tabContents_)-> - AddInfoBar(new CollectedCookiesInfoBarDelegate(tabContents_)); + infobar_tab_helper()->AddInfoBar( + new CollectedCookiesInfoBarDelegate(tabContents_)); } [allowedOutlineView_ setDelegate:nil]; [blockedOutlineView_ setDelegate:nil]; diff --git a/chrome/browser/ui/cocoa/extensions/extension_installed_bubble_bridge.mm b/chrome/browser/ui/cocoa/extensions/extension_installed_bubble_bridge.mm index 94e5cbd..66757a7 100644 --- a/chrome/browser/ui/cocoa/extensions/extension_installed_bubble_bridge.mm +++ b/chrome/browser/ui/cocoa/extensions/extension_installed_bubble_bridge.mm @@ -6,6 +6,7 @@ #include "base/i18n/rtl.h" #include "base/utf_string_conversions.h" +#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" #include "chrome/browser/tab_contents/simple_alert_infobar_delegate.h" #include "chrome/browser/ui/browser.h" @@ -43,7 +44,7 @@ static void ShowGenericExtensionInstalledInfoBar( l10n_util::GetStringUTF16(IDS_EXTENSION_INSTALLED_MANAGE_INFO_MAC); InfoBarDelegate* delegate = new SimpleAlertInfoBarDelegate( wrapper->tab_contents(), new gfx::Image(new SkBitmap(icon)), msg, true); - wrapper->AddInfoBar(delegate); + wrapper->infobar_tab_helper()->AddInfoBar(delegate); } namespace browser { diff --git a/chrome/browser/ui/cocoa/infobars/infobar_container_controller.mm b/chrome/browser/ui/cocoa/infobars/infobar_container_controller.mm index e377d18..0d19573 100644 --- a/chrome/browser/ui/cocoa/infobars/infobar_container_controller.mm +++ b/chrome/browser/ui/cocoa/infobars/infobar_container_controller.mm @@ -4,6 +4,7 @@ #include "base/logging.h" #include "base/mac/mac_util.h" +#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" #include "chrome/browser/tab_contents/infobar.h" #import "chrome/browser/ui/cocoa/animatable_view.h" @@ -139,9 +140,11 @@ class InfoBarNotificationObserver : public NotificationObserver { currentTabContents_ = contents; if (currentTabContents_) { - for (size_t i = 0; i < currentTabContents_->infobar_count(); ++i) { - InfoBar* infobar = currentTabContents_->GetInfoBarDelegateAt(i)-> - CreateInfoBar(currentTabContents_); + InfoBarTabHelper* infobar_helper = + currentTabContents_->infobar_tab_helper(); + for (size_t i = 0; i < infobar_helper->infobar_count(); ++i) { + InfoBar* infobar = infobar_helper-> + GetInfoBarDelegateAt(i)->CreateInfoBar(currentTabContents_); [self addInfoBar:infobar animate:NO]; } diff --git a/chrome/browser/ui/cocoa/infobars/infobar_controller.mm b/chrome/browser/ui/cocoa/infobars/infobar_controller.mm index b0659b9..f8640f8 100644 --- a/chrome/browser/ui/cocoa/infobars/infobar_controller.mm +++ b/chrome/browser/ui/cocoa/infobars/infobar_controller.mm @@ -7,6 +7,7 @@ #include "base/logging.h" // for NOTREACHED() #include "base/mac/mac_util.h" #include "base/sys_string_conversions.h" +#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" #include "chrome/browser/tab_contents/link_infobar_delegate.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" @@ -281,7 +282,7 @@ const float kTextBaselineShift = -1.0; // so that inner event loops don't cause us to try and remove the infobar // twice? http://crbug.com/54253 if (owner_) - owner_->RemoveInfoBar(delegate_); + owner_->infobar_tab_helper()->RemoveInfoBar(delegate_); owner_ = NULL; } diff --git a/chrome/browser/ui/cocoa/keystone_infobar.mm b/chrome/browser/ui/cocoa/keystone_infobar.mm index 81700f4..653d07a 100644 --- a/chrome/browser/ui/cocoa/keystone_infobar.mm +++ b/chrome/browser/ui/cocoa/keystone_infobar.mm @@ -12,6 +12,7 @@ #include "base/message_loop.h" #include "base/task.h" #include "chrome/browser/first_run/first_run.h" +#include "chrome/browser/infobars/infobar_tab_helper.h" #import "chrome/browser/mac/keystone_glue.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" @@ -190,9 +191,9 @@ bool KeystonePromotionInfoBarDelegate::Cancel() { // Only show if no other info bars are showing, because that's how the // default browser info bar works. - if (wrapper && wrapper->infobar_count() == 0) { - wrapper->AddInfoBar(new KeystonePromotionInfoBarDelegate( - wrapper->tab_contents())); + if (wrapper && wrapper->infobar_tab_helper()->infobar_count() == 0) { + wrapper->infobar_tab_helper()->AddInfoBar( + new KeystonePromotionInfoBarDelegate(wrapper->tab_contents())); } } } diff --git a/chrome/browser/ui/content_settings/content_setting_bubble_model.cc b/chrome/browser/ui/content_settings/content_setting_bubble_model.cc index fa18272..bda976a 100644 --- a/chrome/browser/ui/content_settings/content_setting_bubble_model.cc +++ b/chrome/browser/ui/content_settings/content_setting_bubble_model.cc @@ -9,6 +9,7 @@ #include "chrome/browser/content_settings/host_content_settings_map.h" #include "chrome/browser/content_settings/tab_specific_content_settings.h" #include "chrome/browser/favicon/favicon_tab_helper.h" +#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" @@ -317,7 +318,7 @@ class ContentSettingCookiesBubbleModel : public ContentSettingSingleRadioGroup { virtual ~ContentSettingCookiesBubbleModel() { if (settings_changed()) { - tab_contents()->AddInfoBar( + tab_contents()->infobar_tab_helper()->AddInfoBar( new CollectedCookiesInfoBarDelegate(tab_contents()->tab_contents())); } } diff --git a/chrome/browser/ui/gtk/collected_cookies_gtk.cc b/chrome/browser/ui/gtk/collected_cookies_gtk.cc index e73a8a2..cb9e5e1 100644 --- a/chrome/browser/ui/gtk/collected_cookies_gtk.cc +++ b/chrome/browser/ui/gtk/collected_cookies_gtk.cc @@ -9,6 +9,7 @@ #include "chrome/browser/content_settings/host_content_settings_map.h" #include "chrome/browser/content_settings/tab_specific_content_settings.h" #include "chrome/browser/cookies_tree_model.h" +#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/collected_cookies_infobar_delegate.h" #include "chrome/browser/ui/gtk/constrained_window_gtk.h" @@ -432,8 +433,9 @@ void CollectedCookiesGtk::Observe(int type, void CollectedCookiesGtk::OnClose(GtkWidget* close_button) { if (status_changed_) { - TabContentsWrapper::GetCurrentWrapperForContents(tab_contents_)->AddInfoBar( - new CollectedCookiesInfoBarDelegate(tab_contents_)); + TabContentsWrapper::GetCurrentWrapperForContents(tab_contents_)-> + infobar_tab_helper()->AddInfoBar( + new CollectedCookiesInfoBarDelegate(tab_contents_)); } window_->CloseConstrainedWindow(); } diff --git a/chrome/browser/ui/shell_dialogs.cc b/chrome/browser/ui/shell_dialogs.cc index 603c75f..13fddd9 100644 --- a/chrome/browser/ui/shell_dialogs.cc +++ b/chrome/browser/ui/shell_dialogs.cc @@ -7,6 +7,7 @@ #include "base/logging.h" #include "base/message_loop.h" #include "chrome/browser/browser_process.h" +#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/tab_contents/simple_alert_infobar_delegate.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" @@ -54,7 +55,7 @@ void SelectFileDialog::SelectFile(Type type, if (source_contents) { TabContentsWrapper* wrapper = TabContentsWrapper::GetCurrentWrapperForContents(source_contents); - wrapper->AddInfoBar(new SimpleAlertInfoBarDelegate( + wrapper->infobar_tab_helper()->AddInfoBar(new SimpleAlertInfoBarDelegate( source_contents, NULL, l10n_util::GetStringUTF16(IDS_FILE_SELECTION_DIALOG_INFOBAR), diff --git a/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc b/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc index 4c42de2..4f68103 100644 --- a/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc +++ b/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc @@ -6,9 +6,8 @@ #include "base/utf_string_conversions.h" -#include "base/command_line.h" #include "base/lazy_instance.h" -#include "base/utf_string_conversions.h" +#include "base/stringprintf.h" #include "chrome/browser/autocomplete_history_manager.h" #include "chrome/browser/autofill/autofill_manager.h" #include "chrome/browser/automation/automation_tab_helper.h" @@ -20,10 +19,9 @@ #include "chrome/browser/extensions/extension_webnavigation_api.h" #include "chrome/browser/external_protocol/external_protocol_observer.h" #include "chrome/browser/favicon/favicon_tab_helper.h" -#include "chrome/browser/file_select_helper.h" #include "chrome/browser/google/google_util.h" #include "chrome/browser/history/history_tab_helper.h" -#include "chrome/browser/intents/web_intent_data.h" +#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/omnibox_search_hint.h" #include "chrome/browser/password_manager/password_manager.h" #include "chrome/browser/password_manager_delegate_impl.h" @@ -33,17 +31,11 @@ #include "chrome/browser/prerender/prerender_tab_helper.h" #include "chrome/browser/printing/print_preview_message_handler.h" #include "chrome/browser/printing/print_view_manager.h" -#include "chrome/browser/profiles/profile.h" #include "chrome/browser/remoting/firewall_traversal_observer.h" #include "chrome/browser/renderer_host/web_cache_manager.h" #include "chrome/browser/renderer_preferences_util.h" #include "chrome/browser/sessions/restore_tab_helper.h" #include "chrome/browser/safe_browsing/client_side_detection_host.h" -#include "chrome/browser/sync/glue/synced_tab_delegate.h" -#include "chrome/browser/tab_contents/infobar.h" -#include "chrome/browser/tab_contents/infobar_delegate.h" -#include "chrome/browser/tab_contents/insecure_content_infobar_delegate.h" -#include "chrome/browser/tab_contents/simple_alert_infobar_delegate.h" #include "chrome/browser/tab_contents/tab_contents_ssl_helper.h" #include "chrome/browser/tab_contents/thumbnail_generator.h" #include "chrome/browser/themes/theme_service.h" @@ -60,12 +52,8 @@ #include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" #include "chrome/common/render_messages.h" -#include "content/browser/child_process_security_policy.h" #include "content/browser/renderer_host/render_view_host.h" -#include "content/browser/tab_contents/navigation_details.h" -#include "content/browser/tab_contents/tab_contents.h" #include "content/browser/tab_contents/tab_contents_view.h" -#include "content/browser/user_metrics.h" #include "content/common/notification_service.h" #include "content/common/view_messages.h" #include "grit/generated_resources.h" @@ -212,7 +200,6 @@ const size_t kPerScriptFontDefaultsLength = arraysize(kPerScriptFontDefaults); TabContentsWrapper::TabContentsWrapper(TabContents* contents) : TabContentsObserver(contents), delegate_(NULL), - infobars_enabled_(true), ALLOW_THIS_IN_INITIALIZER_LIST( synced_tab_delegate_(new TabContentsWrapperSyncedTabDelegate(this))), in_destructor_(false), @@ -233,6 +220,7 @@ TabContentsWrapper::TabContentsWrapper(TabContents* contents) favicon_tab_helper_.reset(new FaviconTabHelper(contents)); find_tab_helper_.reset(new FindTabHelper(contents)); history_tab_helper_.reset(new HistoryTabHelper(contents)); + infobar_tab_helper_.reset(new InfoBarTabHelper(this)); password_manager_delegate_.reset(new PasswordManagerDelegateImpl(this)); password_manager_.reset( new PasswordManager(contents, password_manager_delegate_.get())); @@ -298,13 +286,8 @@ TabContentsWrapper::TabContentsWrapper(TabContents* contents) TabContentsWrapper::~TabContentsWrapper() { in_destructor_ = true; - // Destroy all remaining InfoBars. It's important to not animate here so that - // we guarantee that we'll delete all delegates before we do anything else. - // - // TODO(pkasting): If there is no InfoBarContainer, this leaks all the - // InfoBarDelegates. This will be fixed once we call CloseSoon() directly on - // Infobars. - RemoveAllInfoBars(false); + // Need to tear down infobars before the TabContents goes away. + infobar_tab_helper_.reset(); } PropertyAccessor<TabContentsWrapper*>* TabContentsWrapper::property_accessor() { @@ -521,8 +504,6 @@ void TabContentsWrapper::RenderViewCreated(RenderViewHost* render_view_host) { } void TabContentsWrapper::RenderViewGone() { - RemoveAllInfoBars(true); - // Tell the view that we've crashed so it can prepare the sad tab page. // Only do this if we're not in browser shutdown, so that TabContents // objects that are not in a browser (e.g., HTML dialogs) and thus are @@ -544,10 +525,6 @@ bool TabContentsWrapper::OnMessageReceived(const IPC::Message& message) { IPC_MESSAGE_HANDLER(ChromeViewHostMsg_Snapshot, OnSnapshot) IPC_MESSAGE_HANDLER(ChromeViewHostMsg_PDFHasUnsupportedFeature, OnPDFHasUnsupportedFeature) - IPC_MESSAGE_HANDLER(ChromeViewHostMsg_DidBlockDisplayingInsecureContent, - OnDidBlockDisplayingInsecureContent) - IPC_MESSAGE_HANDLER(ChromeViewHostMsg_DidBlockRunningInsecureContent, - OnDidBlockRunningInsecureContent) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() return handled; @@ -564,24 +541,6 @@ void TabContentsWrapper::Observe(int type, const NotificationSource& source, const NotificationDetails& details) { switch (type) { - case content::NOTIFICATION_NAV_ENTRY_COMMITTED: { - DCHECK(&tab_contents_->controller() == - Source<NavigationController>(source).ptr()); - - content::LoadCommittedDetails& committed_details = - *(Details<content::LoadCommittedDetails>(details).ptr()); - - // NOTE: It is not safe to change the following code to count upwards or - // use iterators, as the RemoveInfoBar() call synchronously modifies our - // delegate list. - for (size_t i = infobars_.size(); i > 0; --i) { - InfoBarDelegate* delegate = GetInfoBarDelegateAt(i - 1); - if (delegate->ShouldExpire(committed_details)) - RemoveInfoBar(delegate); - } - - break; - } case chrome::NOTIFICATION_GOOGLE_URL_UPDATED: UpdateAlternateErrorPageURL(render_view_host()); break; @@ -619,67 +578,6 @@ void TabContentsWrapper::Observe(int type, } } -void TabContentsWrapper::AddInfoBar(InfoBarDelegate* delegate) { - if (!infobars_enabled_) { - delegate->InfoBarClosed(); - return; - } - - for (size_t i = 0; i < infobars_.size(); ++i) { - if (GetInfoBarDelegateAt(i)->EqualsDelegate(delegate)) { - delegate->InfoBarClosed(); - return; - } - } - - infobars_.push_back(delegate); - NotificationService::current()->Notify( - chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, - Source<TabContentsWrapper>(this), Details<InfoBarAddedDetails>(delegate)); - - // Add ourselves as an observer for navigations the first time a delegate is - // added. We use this notification to expire InfoBars that need to expire on - // page transitions. - if (infobars_.size() == 1) { - registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, - Source<NavigationController>(&tab_contents_->controller())); - } -} - -void TabContentsWrapper::RemoveInfoBar(InfoBarDelegate* delegate) { - RemoveInfoBarInternal(delegate, true); -} - -void TabContentsWrapper::ReplaceInfoBar(InfoBarDelegate* old_delegate, - InfoBarDelegate* new_delegate) { - if (!infobars_enabled_) { - AddInfoBar(new_delegate); // Deletes the delegate. - return; - } - - size_t i; - for (i = 0; i < infobars_.size(); ++i) { - if (GetInfoBarDelegateAt(i) == old_delegate) - break; - } - DCHECK_LT(i, infobars_.size()); - - infobars_.insert(infobars_.begin() + i, new_delegate); - - old_delegate->clear_owner(); - InfoBarReplacedDetails replaced_details(old_delegate, new_delegate); - NotificationService::current()->Notify( - chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REPLACED, - Source<TabContentsWrapper>(this), - Details<InfoBarReplacedDetails>(&replaced_details)); - - infobars_.erase(infobars_.begin() + i + 1); -} - -InfoBarDelegate* TabContentsWrapper::GetInfoBarDelegateAt(size_t index) { - return infobars_[index]; -} - //////////////////////////////////////////////////////////////////////////////// // Internal helpers @@ -694,33 +592,6 @@ void TabContentsWrapper::OnPDFHasUnsupportedFeature() { PDFHasUnsupportedFeature(this); } -void TabContentsWrapper::OnDidBlockDisplayingInsecureContent() { - // At most one infobar and do not supersede the stronger running content bar. - for (size_t i = 0; i < infobars_.size(); ++i) { - if (GetInfoBarDelegateAt(i)->AsInsecureContentInfoBarDelegate()) - return; - } - AddInfoBar(new InsecureContentInfoBarDelegate(this, - InsecureContentInfoBarDelegate::DISPLAY)); -} - -void TabContentsWrapper::OnDidBlockRunningInsecureContent() { - // At most one infobar superseding any weaker displaying content bar. - for (size_t i = 0; i < infobars_.size(); ++i) { - InsecureContentInfoBarDelegate* delegate = - GetInfoBarDelegateAt(i)->AsInsecureContentInfoBarDelegate(); - if (delegate) { - if (delegate->type() != InsecureContentInfoBarDelegate::RUN) { - ReplaceInfoBar(delegate, new InsecureContentInfoBarDelegate(this, - InsecureContentInfoBarDelegate::RUN)); - } - return; - } - } - AddInfoBar(new InsecureContentInfoBarDelegate(this, - InsecureContentInfoBarDelegate::RUN)); -} - GURL TabContentsWrapper::GetAlternateErrorPageURL() const { GURL url; // Disable alternate error pages when in Incognito mode. @@ -771,41 +642,6 @@ void TabContentsWrapper::UpdateSafebrowsingDetectionHost() { #endif } -void TabContentsWrapper::RemoveInfoBarInternal(InfoBarDelegate* delegate, - bool animate) { - if (!infobars_enabled_) { - DCHECK(infobars_.empty()); - return; - } - - size_t i; - for (i = 0; i < infobars_.size(); ++i) { - if (GetInfoBarDelegateAt(i) == delegate) - break; - } - DCHECK_LT(i, infobars_.size()); - InfoBarDelegate* infobar = infobars_[i]; - - infobar->clear_owner(); - InfoBarRemovedDetails removed_details(infobar, animate); - NotificationService::current()->Notify( - chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, - Source<TabContentsWrapper>(this), - Details<InfoBarRemovedDetails>(&removed_details)); - - infobars_.erase(infobars_.begin() + i); - // Remove ourselves as an observer if we are tracking no more InfoBars. - if (infobars_.empty()) { - registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, - Source<NavigationController>(&tab_contents_->controller())); - } -} - -void TabContentsWrapper::RemoveAllInfoBars(bool animate) { - while (!infobars_.empty()) - RemoveInfoBarInternal(GetInfoBarDelegateAt(infobar_count() - 1), animate); -} - void TabContentsWrapper::ExitFullscreenMode() { Send(new ViewMsg_ExitFullscreen(routing_id())); } diff --git a/chrome/browser/ui/tab_contents/tab_contents_wrapper.h b/chrome/browser/ui/tab_contents/tab_contents_wrapper.h index 4eec779..019c0b7 100644 --- a/chrome/browser/ui/tab_contents/tab_contents_wrapper.h +++ b/chrome/browser/ui/tab_contents/tab_contents_wrapper.h @@ -32,7 +32,7 @@ class FaviconTabHelper; class FileSelectObserver; class FindTabHelper; class FirewallTraversalObserver; -class InfoBarDelegate; +class InfoBarTabHelper; class HistoryTabHelper; class NavigationController; class OmniboxSearchHint; @@ -104,6 +104,9 @@ class TabContentsWrapper : public TabContentsObserver, // Captures a snapshot of the page. void CaptureSnapshot(); + // Stop this tab rendering in fullscreen mode. + void ExitFullscreenMode(); + // Helper to retrieve the existing instance that wraps a given TabContents. // Returns NULL if there is no such existing instance. // NOTE: This is not intended for general use. It is intended for situations @@ -166,6 +169,7 @@ class TabContentsWrapper : public TabContentsObserver, FaviconTabHelper* favicon_tab_helper() { return favicon_tab_helper_.get(); } FindTabHelper* find_tab_helper() { return find_tab_helper_.get(); } HistoryTabHelper* history_tab_helper() { return history_tab_helper_.get(); } + InfoBarTabHelper* infobar_tab_helper() { return infobar_tab_helper_.get(); } PasswordManager* password_manager() { return password_manager_.get(); } prerender::PrerenderTabHelper* prerender_tab_helper() { @@ -220,48 +224,12 @@ class TabContentsWrapper : public TabContentsObserver, const NotificationSource& source, const NotificationDetails& details) OVERRIDE; - // Infobars ------------------------------------------------------------------ - - // Adds an InfoBar for the specified |delegate|. - // - // If infobars are disabled for this tab or the tab already has a delegate - // which returns true for InfoBarDelegate::EqualsDelegate(delegate), - // |delegate| is closed immediately without being added. - void AddInfoBar(InfoBarDelegate* delegate); - - // Removes the InfoBar for the specified |delegate|. - // - // If infobars are disabled for this tab, this will do nothing, on the - // assumption that the matching AddInfoBar() call will have already closed the - // delegate (see above). - void RemoveInfoBar(InfoBarDelegate* delegate); - - // Replaces one infobar with another, without any animation in between. - // - // If infobars are disabled for this tab, |new_delegate| is closed immediately - // without being added, and nothing else happens. - // - // NOTE: This does not perform any EqualsDelegate() checks like AddInfoBar(). - void ReplaceInfoBar(InfoBarDelegate* old_delegate, - InfoBarDelegate* new_delegate); - - // Enumeration and access functions. - size_t infobar_count() const { return infobars_.size(); } - // WARNING: This does not sanity-check |index|! - InfoBarDelegate* GetInfoBarDelegateAt(size_t index); - void set_infobars_enabled(bool value) { infobars_enabled_ = value; } - - // Stop this tab rendering in fullscreen mode. - void ExitFullscreenMode(); - private: // Internal helpers ---------------------------------------------------------- // Message handlers. void OnSnapshot(const SkBitmap& bitmap); void OnPDFHasUnsupportedFeature(); - void OnDidBlockDisplayingInsecureContent(); - void OnDidBlockRunningInsecureContent(); // Returns the server that can provide alternate error pages. If the returned // URL is empty, the default error page built into WebKit will be used. @@ -280,18 +248,11 @@ class TabContentsWrapper : public TabContentsObserver, // safe browsing preference has changed. void UpdateSafebrowsingDetectionHost(); - void RemoveInfoBarInternal(InfoBarDelegate* delegate, bool animate); - void RemoveAllInfoBars(bool animate); - // Data for core operation --------------------------------------------------- // Delegate for notifying our owner about stuff. Not owned by us. TabContentsWrapperDelegate* delegate_; - // Delegates for InfoBars associated with this TabContentsWrapper. - std::vector<InfoBarDelegate*> infobars_; - bool infobars_enabled_; - NotificationRegistrar registrar_; PrefChangeRegistrar pref_change_registrar_; @@ -317,6 +278,7 @@ class TabContentsWrapper : public TabContentsObserver, scoped_ptr<FaviconTabHelper> favicon_tab_helper_; scoped_ptr<FindTabHelper> find_tab_helper_; scoped_ptr<HistoryTabHelper> history_tab_helper_; + scoped_ptr<InfoBarTabHelper> infobar_tab_helper_; // PasswordManager and its delegate. The delegate must outlive the manager, // per documentation in password_manager.h. diff --git a/chrome/browser/ui/views/collected_cookies_win.cc b/chrome/browser/ui/views/collected_cookies_win.cc index 833c973..3ab5d43 100644 --- a/chrome/browser/ui/views/collected_cookies_win.cc +++ b/chrome/browser/ui/views/collected_cookies_win.cc @@ -7,6 +7,7 @@ #include "chrome/browser/content_settings/host_content_settings_map.h" #include "chrome/browser/content_settings/tab_specific_content_settings.h" #include "chrome/browser/cookies_tree_model.h" +#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/collected_cookies_infobar_delegate.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" @@ -378,8 +379,9 @@ void CollectedCookiesWin::DeleteDelegate() { bool CollectedCookiesWin::Cancel() { if (status_changed_) { - TabContentsWrapper::GetCurrentWrapperForContents(tab_contents_)->AddInfoBar( - new CollectedCookiesInfoBarDelegate(tab_contents_)); + TabContentsWrapper::GetCurrentWrapperForContents(tab_contents_)-> + infobar_tab_helper()->AddInfoBar( + new CollectedCookiesInfoBarDelegate(tab_contents_)); } return true; |