diff options
Diffstat (limited to 'chrome/browser/tab_contents')
-rw-r--r-- | chrome/browser/tab_contents/background_contents.cc | 12 | ||||
-rw-r--r-- | chrome/browser/tab_contents/background_contents.h | 6 | ||||
-rw-r--r-- | chrome/browser/tab_contents/infobar_delegate.cc | 96 | ||||
-rw-r--r-- | chrome/browser/tab_contents/infobar_delegate.h | 79 |
4 files changed, 134 insertions, 59 deletions
diff --git a/chrome/browser/tab_contents/background_contents.cc b/chrome/browser/tab_contents/background_contents.cc index 5067805..96ed7af 100644 --- a/chrome/browser/tab_contents/background_contents.cc +++ b/chrome/browser/tab_contents/background_contents.cc @@ -58,6 +58,18 @@ BackgroundContents::~BackgroundContents() { render_view_host_->Shutdown(); // deletes render_view_host } +BackgroundContents* BackgroundContents::GetAsBackgroundContents() { + return this; +} + +RenderViewHostDelegate::View* BackgroundContents::GetViewDelegate() { + return this; +} + +const GURL& BackgroundContents::GetURL() const { + return url_; +} + ViewType::Type BackgroundContents::GetRenderViewType() const { return ViewType::BACKGROUND_CONTENTS; } diff --git a/chrome/browser/tab_contents/background_contents.h b/chrome/browser/tab_contents/background_contents.h index 24dadef..3e2f307 100644 --- a/chrome/browser/tab_contents/background_contents.h +++ b/chrome/browser/tab_contents/background_contents.h @@ -58,9 +58,9 @@ class BackgroundContents : public RenderViewHostDelegate, RenderViewHost* render_view_host() { return render_view_host_; } // RenderViewHostDelegate implementation. - virtual BackgroundContents* GetAsBackgroundContents() { return this; } - virtual RenderViewHostDelegate::View* GetViewDelegate() { return this; } - virtual const GURL& GetURL() const { return url_; } + virtual BackgroundContents* GetAsBackgroundContents(); + virtual RenderViewHostDelegate::View* GetViewDelegate(); + virtual const GURL& GetURL() const; virtual ViewType::Type GetRenderViewType() const; virtual int GetBrowserWindowID() const; virtual void DidNavigate(RenderViewHost* render_view_host, diff --git a/chrome/browser/tab_contents/infobar_delegate.cc b/chrome/browser/tab_contents/infobar_delegate.cc index aae8553..671d17b 100644 --- a/chrome/browser/tab_contents/infobar_delegate.cc +++ b/chrome/browser/tab_contents/infobar_delegate.cc @@ -14,6 +14,10 @@ // InfoBarDelegate: ------------------------------------------------------------ +bool InfoBarDelegate::EqualsDelegate(InfoBarDelegate* delegate) const { + return false; +} + bool InfoBarDelegate::ShouldExpire( const NavigationController::LoadCommittedDetails& details) const { bool is_reload = @@ -22,6 +26,44 @@ bool InfoBarDelegate::ShouldExpire( return is_reload || (contents_unique_id_ != details.entry->unique_id()); } +SkBitmap* InfoBarDelegate::GetIcon() const { + return NULL; +} + +AlertInfoBarDelegate* InfoBarDelegate::AsAlertInfoBarDelegate() { + return NULL; +} + +LinkInfoBarDelegate* InfoBarDelegate::AsLinkInfoBarDelegate() { + return NULL; +} + +ConfirmInfoBarDelegate* InfoBarDelegate::AsConfirmInfoBarDelegate() { + return NULL; +} + +ThemeInstalledInfoBarDelegate* +InfoBarDelegate::AsThemePreviewInfobarDelegate() { + return NULL; +} + +TranslateInfoBarDelegate* InfoBarDelegate::AsTranslateInfoBarDelegate() { + return NULL; +} + +ExtensionInfoBarDelegate* InfoBarDelegate::AsExtensionInfoBarDelegate() { + return NULL; +} + +CrashedExtensionInfoBarDelegate* +InfoBarDelegate::AsCrashedExtensionInfoBarDelegate() { + return NULL; +} + +InfoBarDelegate::Type InfoBarDelegate::GetInfoBarType() { + return WARNING_TYPE; +} + InfoBarDelegate::InfoBarDelegate(TabContents* contents) : contents_unique_id_(0) { if (contents) @@ -35,6 +77,10 @@ void InfoBarDelegate::StoreActiveEntryUniqueID(TabContents* contents) { // AlertInfoBarDelegate: ------------------------------------------------------- +SkBitmap* AlertInfoBarDelegate::GetIcon() const { + return NULL; +} + bool AlertInfoBarDelegate::EqualsDelegate(InfoBarDelegate* delegate) const { AlertInfoBarDelegate* alert_delegate = delegate->AsAlertInfoBarDelegate(); if (!alert_delegate) @@ -43,18 +89,44 @@ bool AlertInfoBarDelegate::EqualsDelegate(InfoBarDelegate* delegate) const { return alert_delegate->GetMessageText() == GetMessageText(); } +AlertInfoBarDelegate* AlertInfoBarDelegate::AsAlertInfoBarDelegate() { + return this; +} + AlertInfoBarDelegate::AlertInfoBarDelegate(TabContents* contents) : InfoBarDelegate(contents) { } // LinkInfoBarDelegate: -------------------------------------------------------- +string16 LinkInfoBarDelegate::GetMessageTextWithOffset( + size_t* link_offset) const { + *link_offset = string16::npos; + return string16(); +} + +SkBitmap* LinkInfoBarDelegate::GetIcon() const { + return NULL; +} + +bool LinkInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) { + return true; +} + +LinkInfoBarDelegate* LinkInfoBarDelegate::AsLinkInfoBarDelegate() { + return this; +} + LinkInfoBarDelegate::LinkInfoBarDelegate(TabContents* contents) : InfoBarDelegate(contents) { } // ConfirmInfoBarDelegate: ----------------------------------------------------- +int ConfirmInfoBarDelegate::GetButtons() const { + return BUTTON_NONE; +} + string16 ConfirmInfoBarDelegate::GetButtonLabel( InfoBarButton button) const { if (button == BUTTON_OK) @@ -65,6 +137,30 @@ string16 ConfirmInfoBarDelegate::GetButtonLabel( return string16(); } +bool ConfirmInfoBarDelegate::NeedElevation(InfoBarButton button) const { + return false; +} + +bool ConfirmInfoBarDelegate::Accept() { + return true; +} + +bool ConfirmInfoBarDelegate::Cancel() { + return true; +} + +string16 ConfirmInfoBarDelegate::GetLinkText() { + return string16(); +} + +bool ConfirmInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) { + return true; +} + +ConfirmInfoBarDelegate* ConfirmInfoBarDelegate::AsConfirmInfoBarDelegate() { + return this; +} + ConfirmInfoBarDelegate::ConfirmInfoBarDelegate(TabContents* contents) : AlertInfoBarDelegate(contents) { } diff --git a/chrome/browser/tab_contents/infobar_delegate.h b/chrome/browser/tab_contents/infobar_delegate.h index 4da3510..af9b9c9 100644 --- a/chrome/browser/tab_contents/infobar_delegate.h +++ b/chrome/browser/tab_contents/infobar_delegate.h @@ -58,9 +58,7 @@ class InfoBarDelegate { // 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 { - return false; - } + 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 @@ -81,52 +79,36 @@ class InfoBarDelegate { // Return the icon to be shown for this InfoBar. If the returned bitmap is // NULL, no icon is shown. - virtual SkBitmap* GetIcon() const { return NULL; } + virtual SkBitmap* GetIcon() const; // Returns a pointer to the AlertInfoBarDelegate interface, if implemented. - virtual AlertInfoBarDelegate* AsAlertInfoBarDelegate() { - return NULL; - } + virtual AlertInfoBarDelegate* AsAlertInfoBarDelegate(); // Returns a pointer to the LinkInfoBarDelegate interface, if implemented. - virtual LinkInfoBarDelegate* AsLinkInfoBarDelegate() { - return NULL; - } + virtual LinkInfoBarDelegate* AsLinkInfoBarDelegate(); // Returns a pointer to the ConfirmInfoBarDelegate interface, if implemented. - virtual ConfirmInfoBarDelegate* AsConfirmInfoBarDelegate() { - return NULL; - } + virtual ConfirmInfoBarDelegate* AsConfirmInfoBarDelegate(); // Returns a pointer to the ThemeInstalledInfoBarDelegate interface, if // implemented. - virtual ThemeInstalledInfoBarDelegate* AsThemePreviewInfobarDelegate() { - return NULL; - } + virtual ThemeInstalledInfoBarDelegate* AsThemePreviewInfobarDelegate(); // Returns a pointer to the TranslateInfoBarDelegate interface, if // implemented. - virtual TranslateInfoBarDelegate* AsTranslateInfoBarDelegate() { - return NULL; - } + virtual TranslateInfoBarDelegate* AsTranslateInfoBarDelegate(); // Returns a pointer to the ExtensionInfoBarDelegate interface, if // implemented. - virtual ExtensionInfoBarDelegate* AsExtensionInfoBarDelegate() { - return NULL; - } + virtual ExtensionInfoBarDelegate* AsExtensionInfoBarDelegate(); // Returns a pointer to the CrashedExtensionInfoBarDelegate interface, if // implemented. - virtual CrashedExtensionInfoBarDelegate* AsCrashedExtensionInfoBarDelegate() { - return NULL; - } + virtual CrashedExtensionInfoBarDelegate* AsCrashedExtensionInfoBarDelegate(); // Returns the type of the infobar. The type determines the appearance (such // as background color) of the infobar. - virtual Type GetInfoBarType() { - return WARNING_TYPE; - } + virtual Type GetInfoBarType(); protected: // Provided to subclasses as a convenience to initialize the state of this @@ -157,12 +139,12 @@ class AlertInfoBarDelegate : public InfoBarDelegate { virtual string16 GetMessageText() const = 0; // Overridden from InfoBarDelegate. - virtual SkBitmap* GetIcon() const { return NULL; } + virtual SkBitmap* GetIcon() const; // Overridden from InfoBarDelegate: virtual bool EqualsDelegate(InfoBarDelegate* delegate) const; virtual InfoBar* CreateInfoBar(); - virtual AlertInfoBarDelegate* AsAlertInfoBarDelegate() { return this; } + virtual AlertInfoBarDelegate* AsAlertInfoBarDelegate(); protected: explicit AlertInfoBarDelegate(TabContents* contents); @@ -178,31 +160,24 @@ class LinkInfoBarDelegate : public InfoBarDelegate { // is the position where the link should be inserted. If |link_offset| is set // to string16::npos (it is by default), the link is right aligned within // the InfoBar rather than being embedded in the message text. - virtual string16 GetMessageTextWithOffset(size_t* link_offset) const { - *link_offset = string16::npos; - return string16(); - } + virtual string16 GetMessageTextWithOffset(size_t* link_offset) const; // Returns the text of the link to be displayed. virtual string16 GetLinkText() const = 0; // Overridden from InfoBarDelegate. - virtual SkBitmap* GetIcon() const { return NULL; } + virtual SkBitmap* GetIcon() const; // Called when the Link is clicked. The |disposition| specifies how the // resulting document should be loaded (based on the event flags present when // the link was clicked). This function returns true if the InfoBar should be // closed now or false if it should remain until the user explicitly closes // it. - virtual bool LinkClicked(WindowOpenDisposition disposition) { - return true; - } + virtual bool LinkClicked(WindowOpenDisposition disposition); // Overridden from InfoBarDelegate: virtual InfoBar* CreateInfoBar(); - virtual LinkInfoBarDelegate* AsLinkInfoBarDelegate() { - return this; - } + virtual LinkInfoBarDelegate* AsLinkInfoBarDelegate(); protected: explicit LinkInfoBarDelegate(TabContents* contents); @@ -223,30 +198,26 @@ class ConfirmInfoBarDelegate : public AlertInfoBarDelegate { }; // Return the buttons to be shown for this InfoBar. - virtual int GetButtons() const { - return BUTTON_NONE; - } + virtual int GetButtons() const; // Return the label for the specified button. The default implementation // returns "OK" for the OK button and "Cancel" for the Cancel button. virtual string16 GetButtonLabel(InfoBarButton button) const; // Return whether or not the specified button needs elevation. - virtual bool NeedElevation(InfoBarButton button) const { return false; } + virtual bool NeedElevation(InfoBarButton button) const; // Called when the OK button is pressed. If the function returns true, the // InfoBarDelegate should be removed from the associated TabContents. - virtual bool Accept() { return true; } + virtual bool Accept(); // Called when the Cancel button is pressed. If the function returns true, // the InfoBarDelegate should be removed from the associated TabContents. - virtual bool Cancel() { return true; } + virtual bool Cancel(); // Returns the text of the link to be displayed, if any. Otherwise returns // and empty string. - virtual string16 GetLinkText() { - return string16(); - } + virtual string16 GetLinkText(); // Called when the Link is clicked. The |disposition| specifies how the // resulting document should be loaded (based on the event flags present when @@ -254,15 +225,11 @@ class ConfirmInfoBarDelegate : public AlertInfoBarDelegate { // closed now or false if it should remain until the user explicitly closes // it. // Will only be called if GetLinkText() returns non-empty string. - virtual bool LinkClicked(WindowOpenDisposition disposition) { - return true; - } + virtual bool LinkClicked(WindowOpenDisposition disposition); // Overridden from InfoBarDelegate: virtual InfoBar* CreateInfoBar(); - virtual ConfirmInfoBarDelegate* AsConfirmInfoBarDelegate() { - return this; - } + virtual ConfirmInfoBarDelegate* AsConfirmInfoBarDelegate(); protected: explicit ConfirmInfoBarDelegate(TabContents* contents); |