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

Side by Side Diff: ios/chrome/browser/infobars/confirm_infobar_controller.mm

Issue 2831293002: Change target+selector for block in InfoBarView (Closed)
Patch Set: Address comment Created 3 years, 8 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 unified diff | Download patch
« no previous file with comments | « no previous file | ios/chrome/browser/infobars/confirm_infobar_controller+protected.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "ios/chrome/browser/infobars/confirm_infobar_controller.h" 5 #import "ios/chrome/browser/infobars/confirm_infobar_controller.h"
6 6
7 #include "base/mac/foundation_util.h" 7 #include "base/mac/foundation_util.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/strings/sys_string_conversions.h" 9 #include "base/strings/sys_string_conversions.h"
10 #include "components/infobars/core/confirm_infobar_delegate.h" 10 #include "components/infobars/core/confirm_infobar_delegate.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 if (_confirmInfobarDelegate->GetLinkText().length()) { 112 if (_confirmInfobarDelegate->GetLinkText().length()) {
113 base::string16 msgLink = base::SysNSStringToUTF16([[view class] 113 base::string16 msgLink = base::SysNSStringToUTF16([[view class]
114 stringAsLink:base::SysUTF16ToNSString( 114 stringAsLink:base::SysUTF16ToNSString(
115 _confirmInfobarDelegate->GetLinkText()) 115 _confirmInfobarDelegate->GetLinkText())
116 tag:ConfirmInfoBarUITags::TITLE_LINK]); 116 tag:ConfirmInfoBarUITags::TITLE_LINK]);
117 base::string16 messageText = _confirmInfobarDelegate->GetMessageText(); 117 base::string16 messageText = _confirmInfobarDelegate->GetMessageText();
118 base::ReplaceFirstSubstringAfterOffset( 118 base::ReplaceFirstSubstringAfterOffset(
119 &messageText, 0, _confirmInfobarDelegate->GetLinkText(), msgLink); 119 &messageText, 0, _confirmInfobarDelegate->GetLinkText(), msgLink);
120 120
121 [view addLabel:base::SysUTF16ToNSString(messageText) 121 [view addLabel:base::SysUTF16ToNSString(messageText)
122 target:self 122 action:^(NSUInteger tag) {
123 action:@selector(infobarLinkDidPress:)]; 123 [self infobarLinkDidPress:tag];
sdefresne 2017/04/21 14:19:24 This block has a strong reference to "self". Thus
gambard 2017/04/21 14:54:48 Yes, I tried to keep the current behavior.
124 }];
124 } else { 125 } else {
125 NSString* label = 126 NSString* label =
126 base::SysUTF16ToNSString(_confirmInfobarDelegate->GetMessageText()); 127 base::SysUTF16ToNSString(_confirmInfobarDelegate->GetMessageText());
127 [view addLabel:label]; 128 [view addLabel:label];
128 } 129 }
129 } 130 }
130 131
131 #pragma mark - Handling of User Events 132 #pragma mark - Handling of User Events
132 133
133 - (void)infoBarButtonDidPress:(id)sender { 134 - (void)infoBarButtonDidPress:(id)sender {
134 // This press might have occurred after the user has already pressed a button, 135 // This press might have occurred after the user has already pressed a button,
135 // in which case the view has been detached from the delegate and this press 136 // in which case the view has been detached from the delegate and this press
136 // should be ignored. 137 // should be ignored.
137 if (!self.delegate) { 138 if (!self.delegate) {
138 return; 139 return;
139 } 140 }
140 if ([sender isKindOfClass:[UIButton class]]) { 141 if ([sender isKindOfClass:[UIButton class]]) {
141 NSUInteger tag = static_cast<UIButton*>(sender).tag; 142 NSUInteger tag = static_cast<UIButton*>(sender).tag;
142 if (tag == ConfirmInfoBarUITags::CLOSE) 143 if (tag == ConfirmInfoBarUITags::CLOSE)
143 self.delegate->InfoBarDidCancel(); 144 self.delegate->InfoBarDidCancel();
144 else 145 else
145 self.delegate->InfoBarButtonDidPress(UITagToButton(tag)); 146 self.delegate->InfoBarButtonDidPress(UITagToButton(tag));
146 } 147 }
147 } 148 }
148 149
149 // Title link was clicked. 150 // Title link was clicked.
150 - (void)infobarLinkDidPress:(NSNumber*)tag { 151 - (void)infobarLinkDidPress:(NSUInteger)tag {
151 DCHECK([tag isKindOfClass:[NSNumber class]]);
152 if (!self.delegate) { 152 if (!self.delegate) {
153 return; 153 return;
154 } 154 }
155 if ([tag unsignedIntegerValue] == ConfirmInfoBarUITags::TITLE_LINK) { 155 if (tag == ConfirmInfoBarUITags::TITLE_LINK) {
156 _confirmInfobarDelegate->LinkClicked( 156 _confirmInfobarDelegate->LinkClicked(
157 WindowOpenDisposition::NEW_FOREGROUND_TAB); 157 WindowOpenDisposition::NEW_FOREGROUND_TAB);
158 } 158 }
159 } 159 }
160 160
161 @end 161 @end
OLDNEW
« no previous file with comments | « no previous file | ios/chrome/browser/infobars/confirm_infobar_controller+protected.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698