diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-04 23:30:29 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-04 23:30:29 +0000 |
commit | a40f6e9f4973f79a1c2682ddac655592fa44884d (patch) | |
tree | f0a437d868010029ce88d30ccb6fbc5addbf01f8 /content | |
parent | b36004059e4d2a026959ffc8beaf65973e019595 (diff) | |
download | chromium_src-a40f6e9f4973f79a1c2682ddac655592fa44884d.zip chromium_src-a40f6e9f4973f79a1c2682ddac655592fa44884d.tar.gz chromium_src-a40f6e9f4973f79a1c2682ddac655592fa44884d.tar.bz2 |
Move infobar_delegate.[cc,h] back to chrome/browser/tab_contents.
BUG=None
TEST=None
Review URL: http://codereview.chromium.org/6621009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76996 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r-- | content/browser/tab_contents/infobar_delegate.cc | 83 | ||||
-rw-r--r-- | content/browser/tab_contents/infobar_delegate.h | 118 | ||||
-rw-r--r-- | content/browser/tab_contents/tab_contents.cc | 2 | ||||
-rw-r--r-- | content/browser/tab_contents/test_tab_contents.cc | 2 | ||||
-rw-r--r-- | content/content_browser.gypi | 2 |
5 files changed, 2 insertions, 205 deletions
diff --git a/content/browser/tab_contents/infobar_delegate.cc b/content/browser/tab_contents/infobar_delegate.cc deleted file mode 100644 index 77b76c9..0000000 --- a/content/browser/tab_contents/infobar_delegate.cc +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "content/browser/tab_contents/infobar_delegate.h" - -#include "base/logging.h" -#include "build/build_config.h" -#include "content/browser/tab_contents/navigation_entry.h" -#include "content/browser/tab_contents/navigation_controller.h" -#include "content/browser/tab_contents/tab_contents.h" - -// InfoBarDelegate ------------------------------------------------------------ - -InfoBarDelegate::~InfoBarDelegate() { -} - -bool InfoBarDelegate::EqualsDelegate(InfoBarDelegate* delegate) const { - return false; -} - -bool InfoBarDelegate::ShouldExpire( - const NavigationController::LoadCommittedDetails& details) const { - return (contents_unique_id_ != details.entry->unique_id()) || - (PageTransition::StripQualifier(details.entry->transition_type()) == - PageTransition::RELOAD); -} - -void InfoBarDelegate::InfoBarDismissed() { -} - -void InfoBarDelegate::InfoBarClosed() { -} - -SkBitmap* InfoBarDelegate::GetIcon() const { - return NULL; -} - -InfoBarDelegate::Type InfoBarDelegate::GetInfoBarType() const { - return WARNING_TYPE; -} - -ConfirmInfoBarDelegate* InfoBarDelegate::AsConfirmInfoBarDelegate() { - return NULL; -} - -CrashedExtensionInfoBarDelegate* - InfoBarDelegate::AsCrashedExtensionInfoBarDelegate() { - return NULL; -} - -ExtensionInfoBarDelegate* InfoBarDelegate::AsExtensionInfoBarDelegate() { - return NULL; -} - -LinkInfoBarDelegate* InfoBarDelegate::AsLinkInfoBarDelegate() { - return NULL; -} - -PluginInstallerInfoBarDelegate* - InfoBarDelegate::AsPluginInstallerInfoBarDelegate() { - return NULL; -} - -ThemeInstalledInfoBarDelegate* - InfoBarDelegate::AsThemePreviewInfobarDelegate() { - return NULL; -} - -TranslateInfoBarDelegate* InfoBarDelegate::AsTranslateInfoBarDelegate() { - return NULL; -} - -InfoBarDelegate::InfoBarDelegate(TabContents* contents) - : contents_unique_id_(0) { - if (contents) - StoreActiveEntryUniqueID(contents); -} - -void InfoBarDelegate::StoreActiveEntryUniqueID(TabContents* contents) { - NavigationEntry* active_entry = contents->controller().GetActiveEntry(); - contents_unique_id_ = active_entry ? active_entry->unique_id() : 0; -} diff --git a/content/browser/tab_contents/infobar_delegate.h b/content/browser/tab_contents/infobar_delegate.h deleted file mode 100644 index b4c6921..0000000 --- a/content/browser/tab_contents/infobar_delegate.h +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CONTENT_BROWSER_TAB_CONTENTS_INFOBAR_DELEGATE_H_ -#define CONTENT_BROWSER_TAB_CONTENTS_INFOBAR_DELEGATE_H_ -#pragma once - -#include "base/basictypes.h" -#include "base/string16.h" -#include "content/browser/tab_contents/navigation_controller.h" -#include "webkit/glue/window_open_disposition.h" - -class ConfirmInfoBarDelegate; -class CrashedExtensionInfoBarDelegate; -class ExtensionInfoBarDelegate; -class InfoBar; -class LinkInfoBarDelegate; -class PluginInstallerInfoBarDelegate; -class SkBitmap; -class ThemeInstalledInfoBarDelegate; -class TranslateInfoBarDelegate; - -// An interface implemented by objects wishing to control an InfoBar. -// Implementing this interface is not sufficient to use an InfoBar, since it -// does not map to a specific InfoBar type. Instead, you must implement either -// LinkInfoBarDelegate or ConfirmInfoBarDelegate, or override with your own -// delegate for your own InfoBar variety. -// -// --- WARNING --- -// When creating your InfoBarDelegate subclass, it is recommended that you -// design it such that you instantiate a brand new delegate for every call to -// AddInfoBar, rather than re-using/sharing a delegate object. Otherwise, -// you need to consider the fact that more than one InfoBar instance can exist -// and reference the same delegate -- even though it is also true that we only -// ever fully show one infobar (they don't stack). The dual-references occur -// because a second InfoBar can be added while the first one is in the process -// of closing (the animations). This can cause problems because when the first -// one does finally fully close InfoBarDelegate::InfoBarClosed() is called, -// and the delegate is free to clean itself up or reset state, which may have -// fatal consequences for the InfoBar that was in the process of opening (or is -// now fully opened) -- it is referencing a delegate that may not even exist -// anymore. -// As such, it is generally much safer to dedicate a delegate instance to -// AddInfoBar! -class InfoBarDelegate { - public: - // The type of the infobar. It controls its appearance, such as its background - // color. - enum Type { - WARNING_TYPE, - PAGE_ACTION_TYPE, - }; - - virtual ~InfoBarDelegate(); - - // Called to create the InfoBar. Implementation of this method is - // platform-specific. - virtual InfoBar* CreateInfoBar() = 0; - - // Returns true if the supplied |delegate| is equal to this one. Equality is - // left to the implementation to define. This function is called by the - // TabContents when determining whether or not a delegate should be added - // because a matching one already exists. If this function returns true, the - // TabContents will not add the new delegate because it considers one to - // already be present. - virtual bool EqualsDelegate(InfoBarDelegate* delegate) const; - - // Returns true if the InfoBar should be closed automatically after the page - // is navigated. The default behavior is to return true if the page is - // navigated somewhere else or reloaded. - virtual bool ShouldExpire( - const NavigationController::LoadCommittedDetails& details) const; - - // Called when the user clicks on the close button to dismiss the infobar. - virtual void InfoBarDismissed(); - - // Called after the InfoBar is closed. The delegate is free to delete itself - // at this point. - virtual void InfoBarClosed(); - - // Return the icon to be shown for this InfoBar. If the returned bitmap is - // NULL, no icon is shown. - virtual SkBitmap* GetIcon() const; - - // Returns the type of the infobar. The type determines the appearance (such - // as background color) of the infobar. - virtual Type GetInfoBarType() const; - - // Type-checking downcast routines: - virtual ConfirmInfoBarDelegate* AsConfirmInfoBarDelegate(); - virtual CrashedExtensionInfoBarDelegate* AsCrashedExtensionInfoBarDelegate(); - virtual ExtensionInfoBarDelegate* AsExtensionInfoBarDelegate(); - virtual LinkInfoBarDelegate* AsLinkInfoBarDelegate(); - virtual PluginInstallerInfoBarDelegate* AsPluginInstallerInfoBarDelegate(); - virtual ThemeInstalledInfoBarDelegate* AsThemePreviewInfobarDelegate(); - virtual TranslateInfoBarDelegate* AsTranslateInfoBarDelegate(); - - protected: - // Provided to subclasses as a convenience to initialize the state of this - // object. If |contents| is non-NULL, its active entry's unique ID will be - // stored using StoreActiveEntryUniqueID automatically. - explicit InfoBarDelegate(TabContents* contents); - - // Store the unique id for the active entry in the specified TabContents, to - // be used later upon navigation to determine if this InfoBarDelegate should - // be expired from |contents_|. - void StoreActiveEntryUniqueID(TabContents* contents); - - private: - // The unique id of the active NavigationEntry of the TabContents that we were - // opened for. Used to help expire on navigations. - int contents_unique_id_; - - DISALLOW_COPY_AND_ASSIGN(InfoBarDelegate); -}; - -#endif // CONTENT_BROWSER_TAB_CONTENTS_INFOBAR_DELEGATE_H_ diff --git a/content/browser/tab_contents/tab_contents.cc b/content/browser/tab_contents/tab_contents.cc index 2668403..df3c768 100644 --- a/content/browser/tab_contents/tab_contents.cc +++ b/content/browser/tab_contents/tab_contents.cc @@ -54,6 +54,7 @@ #include "chrome/browser/renderer_preferences_util.h" #include "chrome/browser/safe_browsing/client_side_detection_host.h" #include "chrome/browser/sessions/session_types.h" +#include "chrome/browser/tab_contents/infobar_delegate.h" #include "chrome/browser/tab_contents/tab_contents_ssl_helper.h" #include "chrome/browser/tab_contents/thumbnail_generator.h" #include "chrome/browser/translate/page_translated_details.h" @@ -83,7 +84,6 @@ #include "content/browser/renderer_host/render_widget_host_view.h" #include "content/browser/renderer_host/resource_request_details.h" #include "content/browser/site_instance.h" -#include "content/browser/tab_contents/infobar_delegate.h" #include "content/browser/tab_contents/interstitial_page.h" #include "content/browser/tab_contents/navigation_entry.h" #include "content/browser/tab_contents/provisional_load_details.h" diff --git a/content/browser/tab_contents/test_tab_contents.cc b/content/browser/tab_contents/test_tab_contents.cc index 87bed9a..85d6fce 100644 --- a/content/browser/tab_contents/test_tab_contents.cc +++ b/content/browser/tab_contents/test_tab_contents.cc @@ -7,6 +7,7 @@ #include <utility> #include "chrome/browser/browser_url_handler.h" +#include "chrome/browser/tab_contents/infobar_delegate.h" #include "chrome/common/notification_details.h" #include "chrome/common/notification_source.h" #include "chrome/common/page_transition_types.h" @@ -14,7 +15,6 @@ #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/renderer_host/test_render_view_host.h" #include "content/browser/site_instance.h" -#include "content/browser/tab_contents/infobar_delegate.h" TestTabContents::TestTabContents(Profile* profile, SiteInstance* instance) : TabContents(profile, instance, MSG_ROUTING_NONE, NULL, NULL), diff --git a/content/content_browser.gypi b/content/content_browser.gypi index 494b39e..f1bbae9 100644 --- a/content/content_browser.gypi +++ b/content/content_browser.gypi @@ -279,8 +279,6 @@ 'browser/speech/speech_recognizer.cc', 'browser/speech/speech_recognizer.h', 'browser/tab_contents/constrained_window.h', - 'browser/tab_contents/infobar_delegate.cc', - 'browser/tab_contents/infobar_delegate.h', 'browser/tab_contents/interstitial_page.cc', 'browser/tab_contents/interstitial_page.h', 'browser/tab_contents/language_state.cc', |