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

Unified Diff: ios/chrome/browser/infobars/confirm_infobar_controller.mm

Issue 1161243002: Fixit: Cleanup of InfoBarController. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adding mising forward declaration. Created 5 years, 7 months 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
« no previous file with comments | « no previous file | ios/chrome/browser/infobars/infobar.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/infobars/confirm_infobar_controller.mm
diff --git a/ios/chrome/browser/infobars/confirm_infobar_controller.mm b/ios/chrome/browser/infobars/confirm_infobar_controller.mm
index 74e54a6316a6c84225e6f0ec6a80134e30ba83e9..172787636d9a6ef9008bcd19ec8544d0cf334873 100644
--- a/ios/chrome/browser/infobars/confirm_infobar_controller.mm
+++ b/ios/chrome/browser/infobars/confirm_infobar_controller.mm
@@ -48,14 +48,13 @@ ConfirmInfoBarDelegate::InfoBarButton UITagToButton(NSUInteger tag) {
#pragma mark -
#pragma mark InfoBarController
-- (void)layoutForDelegate:(infobars::InfoBarDelegate*)delegate
- frame:(CGRect)frame {
+- (base::scoped_nsobject<UIView<InfoBarViewProtocol>>)
+ viewForDelegate:(infobars::InfoBarDelegate*)delegate
+ frame:(CGRect)frame {
+ base::scoped_nsobject<UIView<InfoBarViewProtocol>> infoBarView;
ConfirmInfoBarDelegate* infoBarModel = delegate->AsConfirmInfoBarDelegate();
- DCHECK(!infoBarView_);
- infoBarView_.reset([ios::GetChromeBrowserProvider()->CreateInfoBarView()
- initWithFrame:frame
- delegate:delegate_]);
-
+ infoBarView.reset(
+ ios::GetChromeBrowserProvider()->CreateInfoBarView(frame, self.delegate));
// Model data.
NSString* modelMsg = nil;
if (infoBarModel->GetMessageText().length())
@@ -73,34 +72,35 @@ ConfirmInfoBarDelegate::InfoBarButton UITagToButton(NSUInteger tag) {
infoBarModel->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_CANCEL));
}
- [infoBarView_ addCloseButtonWithTag:ConfirmInfoBarUITags::CLOSE
- target:self
- action:@selector(infoBarButtonDidPress:)];
+ [infoBarView addCloseButtonWithTag:ConfirmInfoBarUITags::CLOSE
+ target:self
+ action:@selector(infoBarButtonDidPress:)];
// Optional left icon.
if (!modelIcon.IsEmpty())
- [infoBarView_ addLeftIcon:modelIcon.ToUIImage()];
+ [infoBarView addLeftIcon:modelIcon.ToUIImage()];
// Optional message.
if (modelMsg)
- [infoBarView_ addLabel:modelMsg];
+ [infoBarView addLabel:modelMsg];
if (buttonOK && buttonCancel) {
- [infoBarView_ addButton1:buttonOK
- tag1:ConfirmInfoBarUITags::OK
- button2:buttonCancel
- tag2:ConfirmInfoBarUITags::CANCEL
- target:self
- action:@selector(infoBarButtonDidPress:)];
- } else if (buttonOK) {
- [infoBarView_ addButton:buttonOK
- tag:ConfirmInfoBarUITags::OK
+ [infoBarView addButton1:buttonOK
+ tag1:ConfirmInfoBarUITags::OK
+ button2:buttonCancel
+ tag2:ConfirmInfoBarUITags::CANCEL
target:self
action:@selector(infoBarButtonDidPress:)];
+ } else if (buttonOK) {
+ [infoBarView addButton:buttonOK
+ tag:ConfirmInfoBarUITags::OK
+ target:self
+ action:@selector(infoBarButtonDidPress:)];
} else {
// No buttons, only message.
DCHECK(modelMsg && !buttonCancel);
}
+ return infoBarView;
}
#pragma mark - Handling of User Events
@@ -109,15 +109,15 @@ ConfirmInfoBarDelegate::InfoBarButton UITagToButton(NSUInteger tag) {
// This press might have occurred after the user has already pressed a button,
// in which case the view has been detached from the delegate and this press
// should be ignored.
- if (!delegate_) {
+ if (!self.delegate) {
return;
}
if ([sender isKindOfClass:[UIButton class]]) {
NSUInteger tag = static_cast<UIButton*>(sender).tag;
if (tag == ConfirmInfoBarUITags::CLOSE)
- delegate_->InfoBarDidCancel();
+ self.delegate->InfoBarDidCancel();
else
- delegate_->InfoBarButtonDidPress(UITagToButton(tag));
+ self.delegate->InfoBarButtonDidPress(UITagToButton(tag));
}
}
« no previous file with comments | « no previous file | ios/chrome/browser/infobars/infobar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698