summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/views
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/ui/views')
-rw-r--r--chrome/browser/ui/views/infobars/after_translate_infobar.cc8
-rw-r--r--chrome/browser/ui/views/infobars/after_translate_infobar.h3
-rw-r--r--chrome/browser/ui/views/infobars/alternate_nav_infobar_view.cc11
-rw-r--r--chrome/browser/ui/views/infobars/alternate_nav_infobar_view.h7
-rw-r--r--chrome/browser/ui/views/infobars/before_translate_infobar.cc5
-rw-r--r--chrome/browser/ui/views/infobars/before_translate_infobar.h4
-rw-r--r--chrome/browser/ui/views/infobars/confirm_infobar.cc11
-rw-r--r--chrome/browser/ui/views/infobars/confirm_infobar.h2
-rw-r--r--chrome/browser/ui/views/infobars/extension_infobar.cc26
-rw-r--r--chrome/browser/ui/views/infobars/extension_infobar.h14
-rw-r--r--chrome/browser/ui/views/infobars/infobar_container_view.cc2
-rw-r--r--chrome/browser/ui/views/infobars/infobar_view.cc12
-rw-r--r--chrome/browser/ui/views/infobars/infobar_view.h2
-rw-r--r--chrome/browser/ui/views/infobars/translate_infobar_base.cc21
-rw-r--r--chrome/browser/ui/views/infobars/translate_infobar_base.h3
-rw-r--r--chrome/browser/ui/views/infobars/translate_message_infobar.cc5
-rw-r--r--chrome/browser/ui/views/infobars/translate_message_infobar.h4
17 files changed, 60 insertions, 80 deletions
diff --git a/chrome/browser/ui/views/infobars/after_translate_infobar.cc b/chrome/browser/ui/views/infobars/after_translate_infobar.cc
index 7620e15b..93c0bf4 100644
--- a/chrome/browser/ui/views/infobars/after_translate_infobar.cc
+++ b/chrome/browser/ui/views/infobars/after_translate_infobar.cc
@@ -16,9 +16,8 @@
#include "ui/views/controls/menu/menu_item_view.h"
AfterTranslateInfoBar::AfterTranslateInfoBar(
- InfoBarService* owner,
- TranslateInfoBarDelegate* delegate)
- : TranslateInfoBarBase(owner, delegate),
+ scoped_ptr<TranslateInfoBarDelegate> delegate)
+ : TranslateInfoBarBase(delegate.Pass()),
label_1_(NULL),
label_2_(NULL),
label_3_(NULL),
@@ -28,7 +27,8 @@ AfterTranslateInfoBar::AfterTranslateInfoBar(
options_menu_button_(NULL),
swapped_language_buttons_(false) {
autodetermined_source_language_ =
- delegate->original_language_index() == TranslateInfoBarDelegate::kNoIndex;
+ GetDelegate()->original_language_index() ==
+ TranslateInfoBarDelegate::kNoIndex;
}
AfterTranslateInfoBar::~AfterTranslateInfoBar() {
diff --git a/chrome/browser/ui/views/infobars/after_translate_infobar.h b/chrome/browser/ui/views/infobars/after_translate_infobar.h
index 29e6acb..57fad6d 100644
--- a/chrome/browser/ui/views/infobars/after_translate_infobar.h
+++ b/chrome/browser/ui/views/infobars/after_translate_infobar.h
@@ -19,8 +19,7 @@ class MenuButton;
class AfterTranslateInfoBar : public TranslateInfoBarBase,
public views::MenuButtonListener {
public:
- AfterTranslateInfoBar(InfoBarService* owner,
- TranslateInfoBarDelegate* delegate);
+ explicit AfterTranslateInfoBar(scoped_ptr<TranslateInfoBarDelegate> delegate);
private:
virtual ~AfterTranslateInfoBar();
diff --git a/chrome/browser/ui/views/infobars/alternate_nav_infobar_view.cc b/chrome/browser/ui/views/infobars/alternate_nav_infobar_view.cc
index 87ad887..700be5c 100644
--- a/chrome/browser/ui/views/infobars/alternate_nav_infobar_view.cc
+++ b/chrome/browser/ui/views/infobars/alternate_nav_infobar_view.cc
@@ -13,17 +13,18 @@
// AlternateNavInfoBarDelegate -------------------------------------------------
-InfoBar* AlternateNavInfoBarDelegate::CreateInfoBar(InfoBarService* owner) {
- return new AlternateNavInfoBarView(owner, this);
+// static
+scoped_ptr<InfoBar> AlternateNavInfoBarDelegate::CreateInfoBar(
+ scoped_ptr<AlternateNavInfoBarDelegate> delegate) {
+ return scoped_ptr<InfoBar>(new AlternateNavInfoBarView(delegate.Pass()));
}
// AlternateNavInfoBarView -----------------------------------------------------
AlternateNavInfoBarView::AlternateNavInfoBarView(
- InfoBarService* owner,
- AlternateNavInfoBarDelegate* delegate)
- : InfoBarView(owner, delegate),
+ scoped_ptr<AlternateNavInfoBarDelegate> delegate)
+ : InfoBarView(delegate.PassAs<InfoBarDelegate>()),
label_1_(NULL),
link_(NULL),
label_2_(NULL) {
diff --git a/chrome/browser/ui/views/infobars/alternate_nav_infobar_view.h b/chrome/browser/ui/views/infobars/alternate_nav_infobar_view.h
index aba7c71..0d26a30 100644
--- a/chrome/browser/ui/views/infobars/alternate_nav_infobar_view.h
+++ b/chrome/browser/ui/views/infobars/alternate_nav_infobar_view.h
@@ -5,8 +5,7 @@
#ifndef CHROME_BROWSER_UI_VIEWS_INFOBARS_ALTERNATE_NAV_INFOBAR_VIEW_H_
#define CHROME_BROWSER_UI_VIEWS_INFOBARS_ALTERNATE_NAV_INFOBAR_VIEW_H_
-#include "base/basictypes.h"
-#include "base/compiler_specific.h"
+#include "base/memory/scoped_ptr.h"
#include "chrome/browser/ui/views/infobars/infobar_view.h"
#include "ui/views/controls/link_listener.h"
@@ -16,8 +15,8 @@ class AlternateNavInfoBarDelegate;
class AlternateNavInfoBarView : public InfoBarView,
public views::LinkListener {
public:
- AlternateNavInfoBarView(InfoBarService* owner,
- AlternateNavInfoBarDelegate* delegate);
+ explicit AlternateNavInfoBarView(
+ scoped_ptr<AlternateNavInfoBarDelegate> delegate);
private:
virtual ~AlternateNavInfoBarView();
diff --git a/chrome/browser/ui/views/infobars/before_translate_infobar.cc b/chrome/browser/ui/views/infobars/before_translate_infobar.cc
index bc865b9..4820b41 100644
--- a/chrome/browser/ui/views/infobars/before_translate_infobar.cc
+++ b/chrome/browser/ui/views/infobars/before_translate_infobar.cc
@@ -16,9 +16,8 @@
#include "ui/views/controls/menu/menu_item_view.h"
BeforeTranslateInfoBar::BeforeTranslateInfoBar(
- InfoBarService* owner,
- TranslateInfoBarDelegate* delegate)
- : TranslateInfoBarBase(owner, delegate),
+ scoped_ptr<TranslateInfoBarDelegate> delegate)
+ : TranslateInfoBarBase(delegate.Pass()),
label_1_(NULL),
label_2_(NULL),
language_menu_button_(NULL),
diff --git a/chrome/browser/ui/views/infobars/before_translate_infobar.h b/chrome/browser/ui/views/infobars/before_translate_infobar.h
index 3f368f2..855da51 100644
--- a/chrome/browser/ui/views/infobars/before_translate_infobar.h
+++ b/chrome/browser/ui/views/infobars/before_translate_infobar.h
@@ -19,8 +19,8 @@ class MenuButton;
class BeforeTranslateInfoBar : public TranslateInfoBarBase,
public views::MenuButtonListener {
public:
- BeforeTranslateInfoBar(InfoBarService* owner,
- TranslateInfoBarDelegate* delegate);
+ explicit BeforeTranslateInfoBar(
+ scoped_ptr<TranslateInfoBarDelegate> delegate);
private:
virtual ~BeforeTranslateInfoBar();
diff --git a/chrome/browser/ui/views/infobars/confirm_infobar.cc b/chrome/browser/ui/views/infobars/confirm_infobar.cc
index 82da528..34cd4f8 100644
--- a/chrome/browser/ui/views/infobars/confirm_infobar.cc
+++ b/chrome/browser/ui/views/infobars/confirm_infobar.cc
@@ -14,16 +14,17 @@
// ConfirmInfoBarDelegate -----------------------------------------------------
-InfoBar* ConfirmInfoBarDelegate::CreateInfoBar(InfoBarService* owner) {
- return new ConfirmInfoBar(owner, this);
+// static
+scoped_ptr<InfoBar> ConfirmInfoBarDelegate::CreateInfoBar(
+ scoped_ptr<ConfirmInfoBarDelegate> delegate) {
+ return scoped_ptr<InfoBar>(new ConfirmInfoBar(delegate.Pass()));
}
// ConfirmInfoBar -------------------------------------------------------------
-ConfirmInfoBar::ConfirmInfoBar(InfoBarService* owner,
- ConfirmInfoBarDelegate* delegate)
- : InfoBarView(owner, delegate),
+ConfirmInfoBar::ConfirmInfoBar(scoped_ptr<ConfirmInfoBarDelegate> delegate)
+ : InfoBarView(delegate.PassAs<InfoBarDelegate>()),
label_(NULL),
ok_button_(NULL),
cancel_button_(NULL),
diff --git a/chrome/browser/ui/views/infobars/confirm_infobar.h b/chrome/browser/ui/views/infobars/confirm_infobar.h
index ccde806..fd257d1 100644
--- a/chrome/browser/ui/views/infobars/confirm_infobar.h
+++ b/chrome/browser/ui/views/infobars/confirm_infobar.h
@@ -22,7 +22,7 @@ class Label;
class ConfirmInfoBar : public InfoBarView,
public views::LinkListener {
public:
- ConfirmInfoBar(InfoBarService* owner, ConfirmInfoBarDelegate* delegate);
+ explicit ConfirmInfoBar(scoped_ptr<ConfirmInfoBarDelegate> delegate);
private:
virtual ~ConfirmInfoBar();
diff --git a/chrome/browser/ui/views/infobars/extension_infobar.cc b/chrome/browser/ui/views/infobars/extension_infobar.cc
index 937cc9e..aa9393e 100644
--- a/chrome/browser/ui/views/infobars/extension_infobar.cc
+++ b/chrome/browser/ui/views/infobars/extension_infobar.cc
@@ -29,8 +29,11 @@
// ExtensionInfoBarDelegate ----------------------------------------------------
-InfoBar* ExtensionInfoBarDelegate::CreateInfoBar(InfoBarService* owner) {
- return new ExtensionInfoBar(owner, this, browser_);
+// static
+scoped_ptr<InfoBar> ExtensionInfoBarDelegate::CreateInfoBar(
+ scoped_ptr<ExtensionInfoBarDelegate> delegate) {
+ Browser* browser = delegate->browser_;
+ return scoped_ptr<InfoBar>(new ExtensionInfoBar(delegate.Pass(), browser));
}
@@ -78,25 +81,20 @@ class MenuImageSource: public gfx::CanvasImageSource {
} // namespace
-ExtensionInfoBar::ExtensionInfoBar(InfoBarService* owner,
- ExtensionInfoBarDelegate* delegate,
- Browser* browser)
- : InfoBarView(owner, delegate),
- delegate_(delegate),
+ExtensionInfoBar::ExtensionInfoBar(
+ scoped_ptr<ExtensionInfoBarDelegate> delegate,
+ Browser* browser)
+ : InfoBarView(delegate.PassAs<InfoBarDelegate>()),
browser_(browser),
infobar_icon_(NULL),
icon_as_menu_(NULL),
icon_as_image_(NULL),
weak_ptr_factory_(this) {
- GetDelegate()->set_observer(this);
-
int height = GetDelegate()->height();
SetBarTargetHeight((height > 0) ? (height + kSeparatorLineHeight) : 0);
}
ExtensionInfoBar::~ExtensionInfoBar() {
- if (GetDelegate())
- GetDelegate()->set_observer(NULL);
}
void ExtensionInfoBar::Layout() {
@@ -166,10 +164,6 @@ int ExtensionInfoBar::ContentMinimumWidth() const {
}
-void ExtensionInfoBar::OnDelegateDeleted() {
- delegate_ = NULL;
-}
-
void ExtensionInfoBar::OnMenuButtonClicked(views::View* source,
const gfx::Point& point) {
if (!owner())
@@ -215,5 +209,5 @@ void ExtensionInfoBar::OnImageLoaded(const gfx::Image& image) {
}
ExtensionInfoBarDelegate* ExtensionInfoBar::GetDelegate() {
- return delegate_ ? delegate_->AsExtensionInfoBarDelegate() : NULL;
+ return delegate()->AsExtensionInfoBarDelegate();
}
diff --git a/chrome/browser/ui/views/infobars/extension_infobar.h b/chrome/browser/ui/views/infobars/extension_infobar.h
index 459b9c3..953d390 100644
--- a/chrome/browser/ui/views/infobars/extension_infobar.h
+++ b/chrome/browser/ui/views/infobars/extension_infobar.h
@@ -6,11 +6,11 @@
#define CHROME_BROWSER_UI_VIEWS_INFOBARS_EXTENSION_INFOBAR_H_
#include "base/compiler_specific.h"
-#include "chrome/browser/extensions/extension_infobar_delegate.h"
#include "chrome/browser/ui/views/infobars/infobar_view.h"
#include "ui/views/controls/button/menu_button_listener.h"
class Browser;
+class ExtensionInfoBarDelegate;
namespace views {
class ImageView;
@@ -18,11 +18,9 @@ class MenuButton;
}
class ExtensionInfoBar : public InfoBarView,
- public ExtensionInfoBarDelegate::DelegateObserver,
public views::MenuButtonListener {
public:
- ExtensionInfoBar(InfoBarService* owner,
- ExtensionInfoBarDelegate* delegate,
+ ExtensionInfoBar(scoped_ptr<ExtensionInfoBarDelegate> delegate,
Browser* browser);
private:
@@ -34,9 +32,6 @@ class ExtensionInfoBar : public InfoBarView,
const ViewHierarchyChangedDetails& details) OVERRIDE;
virtual int ContentMinimumWidth() const OVERRIDE;
- // ExtensionInfoBarDelegate::DelegateObserver:
- virtual void OnDelegateDeleted() OVERRIDE;
-
// views::MenuButtonListener:
virtual void OnMenuButtonClicked(views::View* source,
const gfx::Point& point) OVERRIDE;
@@ -45,11 +40,6 @@ class ExtensionInfoBar : public InfoBarView,
ExtensionInfoBarDelegate* GetDelegate();
- // TODO(pkasting): This shadows InfoBarView::delegate_. Get rid of this once
- // InfoBars own their delegates (and thus we don't need the DelegateObserver
- // functionality). For now, almost everyone should use GetDelegate() instead.
- InfoBarDelegate* delegate_;
-
Browser* browser_;
// The infobar icon used for the extension infobar. The icon can be either a
diff --git a/chrome/browser/ui/views/infobars/infobar_container_view.cc b/chrome/browser/ui/views/infobars/infobar_container_view.cc
index bcb9ca53..193330a 100644
--- a/chrome/browser/ui/views/infobars/infobar_container_view.cc
+++ b/chrome/browser/ui/views/infobars/infobar_container_view.cc
@@ -4,7 +4,6 @@
#include "chrome/browser/ui/views/infobars/infobar_container_view.h"
-#include "base/message_loop/message_loop.h"
#include "chrome/browser/ui/view_ids.h"
#include "chrome/browser/ui/views/infobars/infobar_view.h"
#include "grit/generated_resources.h"
@@ -60,5 +59,4 @@ void InfoBarContainerView::PlatformSpecificAddInfoBar(InfoBar* infobar,
void InfoBarContainerView::PlatformSpecificRemoveInfoBar(InfoBar* infobar) {
RemoveChildView(static_cast<InfoBarView*>(infobar));
- base::MessageLoop::current()->DeleteSoon(FROM_HERE, infobar);
}
diff --git a/chrome/browser/ui/views/infobars/infobar_view.cc b/chrome/browser/ui/views/infobars/infobar_view.cc
index c89d2b3..105b037 100644
--- a/chrome/browser/ui/views/infobars/infobar_view.cc
+++ b/chrome/browser/ui/views/infobars/infobar_view.cc
@@ -54,8 +54,8 @@ const int InfoBarView::kButtonButtonSpacing = 10;
const int InfoBarView::kEndOfLabelSpacing = 16;
const int InfoBarView::kHorizontalPadding = 6;
-InfoBarView::InfoBarView(InfoBarService* owner, InfoBarDelegate* delegate)
- : InfoBar(owner, delegate),
+InfoBarView::InfoBarView(scoped_ptr<InfoBarDelegate> delegate)
+ : InfoBar(delegate.Pass()),
views::ExternalFocusTracker(this, NULL),
icon_(NULL),
close_button_(NULL) {
@@ -376,11 +376,9 @@ void InfoBarView::PlatformSpecificOnHeightsRecalculated() {
}
void InfoBarView::GetAccessibleState(ui::AccessibleViewState* state) {
- if (delegate()) {
- state->name = l10n_util::GetStringUTF16(
- (delegate()->GetInfoBarType() == InfoBarDelegate::WARNING_TYPE) ?
- IDS_ACCNAME_INFOBAR_WARNING : IDS_ACCNAME_INFOBAR_PAGE_ACTION);
- }
+ state->name = l10n_util::GetStringUTF16(
+ (delegate()->GetInfoBarType() == InfoBarDelegate::WARNING_TYPE) ?
+ IDS_ACCNAME_INFOBAR_WARNING : IDS_ACCNAME_INFOBAR_PAGE_ACTION);
state->role = ui::AccessibilityTypes::ROLE_ALERT;
}
diff --git a/chrome/browser/ui/views/infobars/infobar_view.h b/chrome/browser/ui/views/infobars/infobar_view.h
index 5797ec7..8914c17 100644
--- a/chrome/browser/ui/views/infobars/infobar_view.h
+++ b/chrome/browser/ui/views/infobars/infobar_view.h
@@ -35,7 +35,7 @@ class InfoBarView : public InfoBar,
public views::ButtonListener,
public views::ExternalFocusTracker {
public:
- InfoBarView(InfoBarService* owner, InfoBarDelegate* delegate);
+ explicit InfoBarView(scoped_ptr<InfoBarDelegate> delegate);
const SkPath& fill_path() const { return fill_path_; }
const SkPath& stroke_path() const { return stroke_path_; }
diff --git a/chrome/browser/ui/views/infobars/translate_infobar_base.cc b/chrome/browser/ui/views/infobars/translate_infobar_base.cc
index 896ac97..0c914e3 100644
--- a/chrome/browser/ui/views/infobars/translate_infobar_base.cc
+++ b/chrome/browser/ui/views/infobars/translate_infobar_base.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/ui/views/infobars/translate_infobar_base.h"
#include "base/strings/utf_string_conversions.h"
+#include "chrome/browser/infobars/infobar.h"
#include "chrome/browser/translate/translate_infobar_delegate.h"
#include "chrome/browser/ui/views/infobars/after_translate_infobar.h"
#include "chrome/browser/ui/views/infobars/before_translate_infobar.h"
@@ -19,12 +20,14 @@
// TranslateInfoBarDelegate ---------------------------------------------------
-InfoBar* TranslateInfoBarDelegate::CreateInfoBar(InfoBarService* owner) {
- if (infobar_type_ == BEFORE_TRANSLATE)
- return new BeforeTranslateInfoBar(owner, this);
- if (infobar_type_ == AFTER_TRANSLATE)
- return new AfterTranslateInfoBar(owner, this);
- return new TranslateMessageInfoBar(owner, this);
+// static
+scoped_ptr<InfoBar> TranslateInfoBarDelegate::CreateInfoBar(
+ scoped_ptr<TranslateInfoBarDelegate> delegate) {
+ if (delegate->infobar_type() == BEFORE_TRANSLATE)
+ return scoped_ptr<InfoBar>(new BeforeTranslateInfoBar(delegate.Pass()));
+ if (delegate->infobar_type() == AFTER_TRANSLATE)
+ return scoped_ptr<InfoBar>(new AfterTranslateInfoBar(delegate.Pass()));
+ return scoped_ptr<InfoBar>(new TranslateMessageInfoBar(delegate.Pass()));
}
@@ -42,9 +45,9 @@ void TranslateInfoBarBase::UpdateLanguageButtonText(views::MenuButton* button,
SchedulePaint();
}
-TranslateInfoBarBase::TranslateInfoBarBase(InfoBarService* owner,
- TranslateInfoBarDelegate* delegate)
- : InfoBarView(owner, delegate),
+TranslateInfoBarBase::TranslateInfoBarBase(
+ scoped_ptr<TranslateInfoBarDelegate> delegate)
+ : InfoBarView(delegate.PassAs<InfoBarDelegate>()),
error_background_(InfoBarDelegate::WARNING_TYPE) {
}
diff --git a/chrome/browser/ui/views/infobars/translate_infobar_base.h b/chrome/browser/ui/views/infobars/translate_infobar_base.h
index 971bf3f..2c7440f 100644
--- a/chrome/browser/ui/views/infobars/translate_infobar_base.h
+++ b/chrome/browser/ui/views/infobars/translate_infobar_base.h
@@ -24,8 +24,7 @@ class TranslateInfoBarBase : public InfoBarView {
const string16& text);
protected:
- TranslateInfoBarBase(InfoBarService* owner,
- TranslateInfoBarDelegate* delegate);
+ explicit TranslateInfoBarBase(scoped_ptr<TranslateInfoBarDelegate> delegate);
virtual ~TranslateInfoBarBase();
// InfoBarView:
diff --git a/chrome/browser/ui/views/infobars/translate_message_infobar.cc b/chrome/browser/ui/views/infobars/translate_message_infobar.cc
index b54e04e..d84a389 100644
--- a/chrome/browser/ui/views/infobars/translate_message_infobar.cc
+++ b/chrome/browser/ui/views/infobars/translate_message_infobar.cc
@@ -9,9 +9,8 @@
#include "ui/views/controls/label.h"
TranslateMessageInfoBar::TranslateMessageInfoBar(
- InfoBarService* owner,
- TranslateInfoBarDelegate* delegate)
- : TranslateInfoBarBase(owner, delegate),
+ scoped_ptr<TranslateInfoBarDelegate> delegate)
+ : TranslateInfoBarBase(delegate.Pass()),
label_(NULL),
button_(NULL) {
}
diff --git a/chrome/browser/ui/views/infobars/translate_message_infobar.h b/chrome/browser/ui/views/infobars/translate_message_infobar.h
index 0452b95..1eda310 100644
--- a/chrome/browser/ui/views/infobars/translate_message_infobar.h
+++ b/chrome/browser/ui/views/infobars/translate_message_infobar.h
@@ -9,8 +9,8 @@
class TranslateMessageInfoBar : public TranslateInfoBarBase {
public:
- TranslateMessageInfoBar(InfoBarService* owner,
- TranslateInfoBarDelegate* delegate);
+ explicit TranslateMessageInfoBar(
+ scoped_ptr<TranslateInfoBarDelegate> delegate);
private:
virtual ~TranslateMessageInfoBar();