Chromium Code Reviews| 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 f887d843d30b5e30f88c312de54524dba6f502d6..e81f59bd40b430d1ef2b384ede92b52aba6220ee 100644 |
| --- a/ios/chrome/browser/infobars/confirm_infobar_controller.mm |
| +++ b/ios/chrome/browser/infobars/confirm_infobar_controller.mm |
| @@ -2,7 +2,7 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#include "ios/chrome/browser/infobars/confirm_infobar_controller.h" |
| +#import "ios/chrome/browser/infobars/confirm_infobar_controller.h" |
| #include "base/mac/foundation_util.h" |
| #include "base/strings/string_util.h" |
| @@ -18,7 +18,12 @@ |
| namespace { |
| // UI Tags for the infobar elements. |
| -enum ConfirmInfoBarUITags { OK = 1, CANCEL, CLOSE, TITLE_LINK }; |
| +typedef NS_ENUM(NSInteger, ConfirmInfoBarUITags) { |
| + OK = 1, |
| + CANCEL, |
| + CLOSE, |
| + TITLE_LINK |
| +}; |
| // Converts a UI button tag to the corresponding InfoBarButton. |
| ConfirmInfoBarDelegate::InfoBarButton UITagToButton(NSUInteger tag) { |
| @@ -38,18 +43,12 @@ ConfirmInfoBarDelegate::InfoBarButton UITagToButton(NSUInteger tag) { |
| #pragma mark - ConfirmInfoBarController |
| -@interface ConfirmInfoBarController () |
| - |
| -// Action for any of the user defined buttons. |
| -- (void)infoBarButtonDidPress:(id)sender; |
| -// Action for any of the user defined links. |
| -- (void)infobarLinkDidPress:(NSNumber*)tag; |
| -- (void)updateInfobarLabel:(UIView<InfoBarViewProtocol>*)view; |
| +@interface ConfirmInfoBarController () { |
| + ConfirmInfoBarDelegate* _confirmInfobarDelegate; // weak |
|
jif-google
2016/07/05 14:18:15
like sylvain said, you can remove the "// weak" he
Jackie Quinn
2016/07/06 07:18:13
Done.
|
| +} |
| @end |
| -@implementation ConfirmInfoBarController { |
| - ConfirmInfoBarDelegate* confirmInfobarDelegate_; // weak |
| -} |
| +@implementation ConfirmInfoBarController |
| #pragma mark - |
| #pragma mark InfoBarController |
| @@ -58,21 +57,21 @@ ConfirmInfoBarDelegate::InfoBarButton UITagToButton(NSUInteger tag) { |
| viewForDelegate:(infobars::InfoBarDelegate*)delegate |
| frame:(CGRect)frame { |
| base::scoped_nsobject<UIView<InfoBarViewProtocol>> infoBarView; |
| - confirmInfobarDelegate_ = delegate->AsConfirmInfoBarDelegate(); |
| + _confirmInfobarDelegate = delegate->AsConfirmInfoBarDelegate(); |
| infoBarView.reset( |
| ios::GetChromeBrowserProvider()->CreateInfoBarView(frame, self.delegate)); |
| // Model data. |
| - gfx::Image modelIcon = confirmInfobarDelegate_->GetIcon(); |
| - int buttons = confirmInfobarDelegate_->GetButtons(); |
| + gfx::Image modelIcon = _confirmInfobarDelegate->GetIcon(); |
| + int buttons = _confirmInfobarDelegate->GetButtons(); |
| NSString* buttonOK = nil; |
| if (buttons & ConfirmInfoBarDelegate::BUTTON_OK) { |
| - buttonOK = base::SysUTF16ToNSString(confirmInfobarDelegate_->GetButtonLabel( |
| + buttonOK = base::SysUTF16ToNSString(_confirmInfobarDelegate->GetButtonLabel( |
| ConfirmInfoBarDelegate::BUTTON_OK)); |
| } |
| NSString* buttonCancel = nil; |
| if (buttons & ConfirmInfoBarDelegate::BUTTON_CANCEL) { |
| buttonCancel = |
| - base::SysUTF16ToNSString(confirmInfobarDelegate_->GetButtonLabel( |
| + base::SysUTF16ToNSString(_confirmInfobarDelegate->GetButtonLabel( |
| ConfirmInfoBarDelegate::BUTTON_CANCEL)); |
| } |
| @@ -101,29 +100,29 @@ ConfirmInfoBarDelegate::InfoBarButton UITagToButton(NSUInteger tag) { |
| action:@selector(infoBarButtonDidPress:)]; |
| } else { |
| // No buttons, only message. |
| - DCHECK(!confirmInfobarDelegate_->GetMessageText().empty() && !buttonCancel); |
| + DCHECK(!_confirmInfobarDelegate->GetMessageText().empty() && !buttonCancel); |
| } |
| return infoBarView; |
| } |
| - (void)updateInfobarLabel:(UIView<InfoBarViewProtocol>*)view { |
| - if (!confirmInfobarDelegate_->GetMessageText().length()) |
| + if (!_confirmInfobarDelegate->GetMessageText().length()) |
| return; |
| - if (confirmInfobarDelegate_->GetLinkText().length()) { |
| - base::string16 msgLink = base::SysNSStringToUTF16( |
| - [[view class] stringAsLink:base::SysUTF16ToNSString( |
| - confirmInfobarDelegate_->GetLinkText()) |
| - tag:ConfirmInfoBarUITags::TITLE_LINK]); |
| - base::string16 messageText = confirmInfobarDelegate_->GetMessageText(); |
| + if (_confirmInfobarDelegate->GetLinkText().length()) { |
| + base::string16 msgLink = base::SysNSStringToUTF16([[view class] |
| + stringAsLink:base::SysUTF16ToNSString( |
| + _confirmInfobarDelegate->GetLinkText()) |
| + tag:ConfirmInfoBarUITags::TITLE_LINK]); |
| + base::string16 messageText = _confirmInfobarDelegate->GetMessageText(); |
| base::ReplaceFirstSubstringAfterOffset( |
| - &messageText, 0, confirmInfobarDelegate_->GetLinkText(), msgLink); |
| + &messageText, 0, _confirmInfobarDelegate->GetLinkText(), msgLink); |
| [view addLabel:base::SysUTF16ToNSString(messageText) |
| target:self |
| action:@selector(infobarLinkDidPress:)]; |
| } else { |
| NSString* label = |
| - base::SysUTF16ToNSString(confirmInfobarDelegate_->GetMessageText()); |
| + base::SysUTF16ToNSString(_confirmInfobarDelegate->GetMessageText()); |
| [view addLabel:label]; |
| } |
| } |
| @@ -153,7 +152,7 @@ ConfirmInfoBarDelegate::InfoBarButton UITagToButton(NSUInteger tag) { |
| return; |
| } |
| if ([tag unsignedIntegerValue] == ConfirmInfoBarUITags::TITLE_LINK) { |
| - confirmInfobarDelegate_->LinkClicked(NEW_FOREGROUND_TAB); |
| + _confirmInfobarDelegate->LinkClicked(NEW_FOREGROUND_TAB); |
| } |
| } |