| OLD | NEW |
| 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 return; | 111 return; |
| 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 __weak ConfirmInfoBarController* weakSelf = self; |
| 121 [view addLabel:base::SysUTF16ToNSString(messageText) | 122 [view addLabel:base::SysUTF16ToNSString(messageText) |
| 122 action:^(NSUInteger tag) { | 123 action:^(NSUInteger tag) { |
| 123 [self infobarLinkDidPress:tag]; | 124 [weakSelf infobarLinkDidPress:tag]; |
| 124 }]; | 125 }]; |
| 125 } else { | 126 } else { |
| 126 NSString* label = | 127 NSString* label = |
| 127 base::SysUTF16ToNSString(_confirmInfobarDelegate->GetMessageText()); | 128 base::SysUTF16ToNSString(_confirmInfobarDelegate->GetMessageText()); |
| 128 [view addLabel:label]; | 129 [view addLabel:label]; |
| 129 } | 130 } |
| 130 } | 131 } |
| 131 | 132 |
| 132 #pragma mark - Handling of User Events | 133 #pragma mark - Handling of User Events |
| 133 | 134 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 152 if (!self.delegate) { | 153 if (!self.delegate) { |
| 153 return; | 154 return; |
| 154 } | 155 } |
| 155 if (tag == ConfirmInfoBarUITags::TITLE_LINK) { | 156 if (tag == ConfirmInfoBarUITags::TITLE_LINK) { |
| 156 _confirmInfobarDelegate->LinkClicked( | 157 _confirmInfobarDelegate->LinkClicked( |
| 157 WindowOpenDisposition::NEW_FOREGROUND_TAB); | 158 WindowOpenDisposition::NEW_FOREGROUND_TAB); |
| 158 } | 159 } |
| 159 } | 160 } |
| 160 | 161 |
| 161 @end | 162 @end |
| OLD | NEW |