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

Unified Diff: chrome/browser/ui/cocoa/infobars/translate_infobar_base.mm

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/cocoa/infobars/translate_infobar_base.mm
===================================================================
--- chrome/browser/ui/cocoa/infobars/translate_infobar_base.mm (revision 238220)
+++ chrome/browser/ui/cocoa/infobars/translate_infobar_base.mm (working copy)
@@ -27,11 +27,13 @@
using InfoBarUtilities::CreateLabel;
using InfoBarUtilities::AddMenuItem;
-// TranslateInfoBarDelegate views specific method:
-InfoBar* TranslateInfoBarDelegate::CreateInfoBar(InfoBarService* owner) {
- scoped_ptr<InfoBarCocoa> infobar(new InfoBarCocoa(owner, this));
+// static
+scoped_ptr<InfoBar> TranslateInfoBarDelegate::CreateInfoBar(
+ scoped_ptr<TranslateInfoBarDelegate> delegate) {
+ scoped_ptr<InfoBarCocoa> infobar(
+ new InfoBarCocoa(delegate.PassAs<InfoBarDelegate>()));
base::scoped_nsobject<TranslateInfoBarControllerBase> infobar_controller;
- switch (infobar_type_) {
+ switch (infobar->delegate()->AsTranslateInfoBarDelegate()->infobar_type()) {
case BEFORE_TRANSLATE:
infobar_controller.reset([[BeforeTranslateInfobarController alloc]
initWithInfoBar:infobar.get()]);
@@ -49,7 +51,7 @@
NOTREACHED();
}
infobar->set_controller(infobar_controller);
- return infobar.release();
+ return infobar.PassAs<InfoBar>();
}
@implementation TranslateInfoBarControllerBase (FrameChangeObserver)
@@ -359,12 +361,17 @@
[self updateState];
}
+- (void)infobarWillHide {
+ [[fromLanguagePopUp_ menu] cancelTracking];
+ [[toLanguagePopUp_ menu] cancelTracking];
+ [[optionsPopUp_ menu] cancelTracking];
+ [super infobarWillHide];
+}
+
- (void)infobarWillClose {
[self disablePopUpMenu:[fromLanguagePopUp_ menu]];
[self disablePopUpMenu:[toLanguagePopUp_ menu]];
[self disablePopUpMenu:[optionsPopUp_ menu]];
- // [super infobarWillClose] clears the owner field which is relied on by the
- // notification handler, so remove the handler first.
[[NSNotificationCenter defaultCenter] removeObserver:self];
[super infobarWillClose];
}
@@ -458,9 +465,6 @@
}
- (void)dealloc {
- // Perhaps this was removed as an observer in -infobarWillClose, but there's
- // no guarantee that that was the case.
- [[NSNotificationCenter defaultCenter] removeObserver:self];
[showOriginalButton_ setTarget:nil];
[translateMessageButton_ setTarget:nil];
[super dealloc];

Powered by Google App Engine
This is Rietveld 408576698