| Index: chrome/browser/tab_contents/infobar_delegate.cc
|
| ===================================================================
|
| --- chrome/browser/tab_contents/infobar_delegate.cc (revision 72158)
|
| +++ chrome/browser/tab_contents/infobar_delegate.cc (working copy)
|
| @@ -1,4 +1,4 @@
|
| -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
| +// 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.
|
|
|
| @@ -12,29 +12,37 @@
|
| #include "chrome/browser/tab_contents/tab_contents.h"
|
| #include "grit/generated_resources.h"
|
|
|
| -// InfoBarDelegate: ------------------------------------------------------------
|
| +// InfoBarDelegate ------------------------------------------------------------
|
|
|
| +InfoBarDelegate::~InfoBarDelegate() {
|
| +}
|
| +
|
| bool InfoBarDelegate::EqualsDelegate(InfoBarDelegate* delegate) const {
|
| return false;
|
| }
|
|
|
| bool InfoBarDelegate::ShouldExpire(
|
| const NavigationController::LoadCommittedDetails& details) const {
|
| - bool is_reload =
|
| - PageTransition::StripQualifier(details.entry->transition_type()) ==
|
| - PageTransition::RELOAD;
|
| - return is_reload || (contents_unique_id_ != details.entry->unique_id());
|
| + 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;
|
| }
|
|
|
| -AlertInfoBarDelegate* InfoBarDelegate::AsAlertInfoBarDelegate() {
|
| - return NULL;
|
| +InfoBarDelegate::Type InfoBarDelegate::GetInfoBarType() const {
|
| + return WARNING_TYPE;
|
| }
|
|
|
| -LinkInfoBarDelegate* InfoBarDelegate::AsLinkInfoBarDelegate() {
|
| +AlertInfoBarDelegate* InfoBarDelegate::AsAlertInfoBarDelegate() {
|
| return NULL;
|
| }
|
|
|
| @@ -42,26 +50,26 @@
|
| return NULL;
|
| }
|
|
|
| -ThemeInstalledInfoBarDelegate*
|
| -InfoBarDelegate::AsThemePreviewInfobarDelegate() {
|
| +CrashedExtensionInfoBarDelegate*
|
| +InfoBarDelegate::AsCrashedExtensionInfoBarDelegate() {
|
| return NULL;
|
| }
|
|
|
| -TranslateInfoBarDelegate* InfoBarDelegate::AsTranslateInfoBarDelegate() {
|
| +ExtensionInfoBarDelegate* InfoBarDelegate::AsExtensionInfoBarDelegate() {
|
| return NULL;
|
| }
|
|
|
| -ExtensionInfoBarDelegate* InfoBarDelegate::AsExtensionInfoBarDelegate() {
|
| +LinkInfoBarDelegate* InfoBarDelegate::AsLinkInfoBarDelegate() {
|
| return NULL;
|
| }
|
|
|
| -CrashedExtensionInfoBarDelegate*
|
| -InfoBarDelegate::AsCrashedExtensionInfoBarDelegate() {
|
| +ThemeInstalledInfoBarDelegate*
|
| + InfoBarDelegate::AsThemePreviewInfobarDelegate() {
|
| return NULL;
|
| }
|
|
|
| -InfoBarDelegate::Type InfoBarDelegate::GetInfoBarType() {
|
| - return WARNING_TYPE;
|
| +TranslateInfoBarDelegate* InfoBarDelegate::AsTranslateInfoBarDelegate() {
|
| + return NULL;
|
| }
|
|
|
| InfoBarDelegate::InfoBarDelegate(TabContents* contents)
|
| @@ -75,29 +83,28 @@
|
| contents_unique_id_ = active_entry ? active_entry->unique_id() : 0;
|
| }
|
|
|
| -// AlertInfoBarDelegate: -------------------------------------------------------
|
|
|
| -SkBitmap* AlertInfoBarDelegate::GetIcon() const {
|
| - return NULL;
|
| -}
|
| +// AlertInfoBarDelegate -------------------------------------------------------
|
|
|
| bool AlertInfoBarDelegate::EqualsDelegate(InfoBarDelegate* delegate) const {
|
| AlertInfoBarDelegate* alert_delegate = delegate->AsAlertInfoBarDelegate();
|
| - if (!alert_delegate)
|
| - return false;
|
| + return alert_delegate &&
|
| + (alert_delegate->GetMessageText() == GetMessageText());
|
| +}
|
|
|
| - return alert_delegate->GetMessageText() == GetMessageText();
|
| +AlertInfoBarDelegate::AlertInfoBarDelegate(TabContents* contents)
|
| + : InfoBarDelegate(contents) {
|
| }
|
|
|
| +AlertInfoBarDelegate::~AlertInfoBarDelegate() {
|
| +}
|
| +
|
| AlertInfoBarDelegate* AlertInfoBarDelegate::AsAlertInfoBarDelegate() {
|
| return this;
|
| }
|
|
|
| -AlertInfoBarDelegate::AlertInfoBarDelegate(TabContents* contents)
|
| - : InfoBarDelegate(contents) {
|
| -}
|
|
|
| -// LinkInfoBarDelegate: --------------------------------------------------------
|
| +// LinkInfoBarDelegate --------------------------------------------------------
|
|
|
| string16 LinkInfoBarDelegate::GetMessageTextWithOffset(
|
| size_t* link_offset) const {
|
| @@ -105,36 +112,30 @@
|
| return string16();
|
| }
|
|
|
| -SkBitmap* LinkInfoBarDelegate::GetIcon() const {
|
| - return NULL;
|
| -}
|
| -
|
| bool LinkInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) {
|
| return true;
|
| }
|
|
|
| +LinkInfoBarDelegate::LinkInfoBarDelegate(TabContents* contents)
|
| + : InfoBarDelegate(contents) {
|
| +}
|
| +
|
| +LinkInfoBarDelegate::~LinkInfoBarDelegate() {
|
| +}
|
| +
|
| LinkInfoBarDelegate* LinkInfoBarDelegate::AsLinkInfoBarDelegate() {
|
| return this;
|
| }
|
|
|
| -LinkInfoBarDelegate::LinkInfoBarDelegate(TabContents* contents)
|
| - : InfoBarDelegate(contents) {
|
| -}
|
|
|
| -// ConfirmInfoBarDelegate: -----------------------------------------------------
|
| +// ConfirmInfoBarDelegate -----------------------------------------------------
|
|
|
| int ConfirmInfoBarDelegate::GetButtons() const {
|
| return BUTTON_NONE;
|
| }
|
|
|
| -string16 ConfirmInfoBarDelegate::GetButtonLabel(
|
| - InfoBarButton button) const {
|
| - if (button == BUTTON_OK)
|
| - return l10n_util::GetStringUTF16(IDS_OK);
|
| - if (button == BUTTON_CANCEL)
|
| - return l10n_util::GetStringUTF16(IDS_CANCEL);
|
| - NOTREACHED();
|
| - return string16();
|
| +string16 ConfirmInfoBarDelegate::GetButtonLabel(InfoBarButton button) const {
|
| + return l10n_util::GetStringUTF16((button == BUTTON_OK) ? IDS_OK : IDS_CANCEL);
|
| }
|
|
|
| bool ConfirmInfoBarDelegate::NeedElevation(InfoBarButton button) const {
|
| @@ -157,43 +158,47 @@
|
| return true;
|
| }
|
|
|
| +ConfirmInfoBarDelegate::ConfirmInfoBarDelegate(TabContents* contents)
|
| + : AlertInfoBarDelegate(contents) {
|
| +}
|
| +
|
| +ConfirmInfoBarDelegate::~ConfirmInfoBarDelegate() {
|
| +}
|
| +
|
| ConfirmInfoBarDelegate* ConfirmInfoBarDelegate::AsConfirmInfoBarDelegate() {
|
| return this;
|
| }
|
|
|
| -ConfirmInfoBarDelegate::ConfirmInfoBarDelegate(TabContents* contents)
|
| - : AlertInfoBarDelegate(contents) {
|
| -}
|
|
|
| -// SimpleAlertInfoBarDelegate: -------------------------------------------------
|
| +// SimpleAlertInfoBarDelegate -------------------------------------------------
|
|
|
| SimpleAlertInfoBarDelegate::SimpleAlertInfoBarDelegate(
|
| TabContents* contents,
|
| + SkBitmap* icon,
|
| const string16& message,
|
| - SkBitmap* icon,
|
| bool auto_expire)
|
| : AlertInfoBarDelegate(contents),
|
| + icon_(icon),
|
| message_(message),
|
| - icon_(icon),
|
| auto_expire_(auto_expire) {
|
| }
|
|
|
| +SimpleAlertInfoBarDelegate::~SimpleAlertInfoBarDelegate() {
|
| +}
|
| +
|
| bool SimpleAlertInfoBarDelegate::ShouldExpire(
|
| const NavigationController::LoadCommittedDetails& details) const {
|
| - if (auto_expire_)
|
| - return AlertInfoBarDelegate::ShouldExpire(details);
|
| -
|
| - return false;
|
| + return auto_expire_ && AlertInfoBarDelegate::ShouldExpire(details);
|
| }
|
|
|
| -string16 SimpleAlertInfoBarDelegate::GetMessageText() const {
|
| - return message_;
|
| +void SimpleAlertInfoBarDelegate::InfoBarClosed() {
|
| + delete this;
|
| }
|
|
|
| SkBitmap* SimpleAlertInfoBarDelegate::GetIcon() const {
|
| return icon_;
|
| }
|
|
|
| -void SimpleAlertInfoBarDelegate::InfoBarClosed() {
|
| - delete this;
|
| +string16 SimpleAlertInfoBarDelegate::GetMessageText() const {
|
| + return message_;
|
| }
|
|
|