Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1598)

Unified Diff: chrome/browser/ui/views/infobars/extension_infobar.cc

Issue 22694006: Infobar system refactor. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/infobars/extension_infobar.cc
===================================================================
--- chrome/browser/ui/views/infobars/extension_infobar.cc (revision 238220)
+++ chrome/browser/ui/views/infobars/extension_infobar.cc (working copy)
@@ -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 @@
} // 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 @@
}
-void ExtensionInfoBar::OnDelegateDeleted() {
- delegate_ = NULL;
-}
-
void ExtensionInfoBar::OnMenuButtonClicked(views::View* source,
const gfx::Point& point) {
if (!owner())
@@ -215,5 +209,5 @@
}
ExtensionInfoBarDelegate* ExtensionInfoBar::GetDelegate() {
- return delegate_ ? delegate_->AsExtensionInfoBarDelegate() : NULL;
+ return delegate()->AsExtensionInfoBarDelegate();
}
« no previous file with comments | « chrome/browser/ui/views/infobars/extension_infobar.h ('k') | chrome/browser/ui/views/infobars/infobar_container_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698