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

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

Issue 102163002: Revert 238283 "Infobar system refactor." (Closed) Base URL: svn://svn.chromium.org/chrome/
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: trunk/src/chrome/browser/ui/cocoa/infobars/translate_infobar_base.mm
===================================================================
--- trunk/src/chrome/browser/ui/cocoa/infobars/translate_infobar_base.mm (revision 238401)
+++ trunk/src/chrome/browser/ui/cocoa/infobars/translate_infobar_base.mm (working copy)
@@ -27,13 +27,11 @@
using InfoBarUtilities::CreateLabel;
using InfoBarUtilities::AddMenuItem;
-// static
-scoped_ptr<InfoBar> TranslateInfoBarDelegate::CreateInfoBar(
- scoped_ptr<TranslateInfoBarDelegate> delegate) {
- scoped_ptr<InfoBarCocoa> infobar(
- new InfoBarCocoa(delegate.PassAs<InfoBarDelegate>()));
+// TranslateInfoBarDelegate views specific method:
+InfoBar* TranslateInfoBarDelegate::CreateInfoBar(InfoBarService* owner) {
+ scoped_ptr<InfoBarCocoa> infobar(new InfoBarCocoa(owner, this));
base::scoped_nsobject<TranslateInfoBarControllerBase> infobar_controller;
- switch (infobar->delegate()->AsTranslateInfoBarDelegate()->infobar_type()) {
+ switch (infobar_type_) {
case BEFORE_TRANSLATE:
infobar_controller.reset([[BeforeTranslateInfobarController alloc]
initWithInfoBar:infobar.get()]);
@@ -51,7 +49,7 @@
NOTREACHED();
}
infobar->set_controller(infobar_controller);
- return infobar.PassAs<InfoBar>();
+ return infobar.release();
}
@implementation TranslateInfoBarControllerBase (FrameChangeObserver)
@@ -361,17 +359,12 @@
[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];
}
@@ -465,6 +458,9 @@
}
- (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