| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "ios/chrome/browser/translate/translate_message_infobar_controller.h" | 5 #include "ios/chrome/browser/translate/translate_message_infobar_controller.h" |
| 6 | 6 |
| 7 #include "base/mac/scoped_nsobject.h" | 7 #include "base/mac/scoped_nsobject.h" |
| 8 #include "base/strings/sys_string_conversions.h" | 8 #include "base/strings/sys_string_conversions.h" |
| 9 #include "components/translate/core/browser/translate_infobar_delegate.h" | 9 #include "components/translate/core/browser/translate_infobar_delegate.h" |
| 10 #include "ios/chrome/browser/translate/translate_infobar_tags.h" | 10 #include "ios/chrome/browser/translate/translate_infobar_tags.h" |
| 11 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" | 11 #import "ios/chrome/browser/ui/infobars/infobar_view.h" |
| 12 #import "ios/public/provider/chrome/browser/ui/infobar_view_delegate.h" | 12 #import "ios/chrome/browser/ui/infobars/infobar_view_delegate.h" |
| 13 #import "ios/public/provider/chrome/browser/ui/infobar_view_protocol.h" | 13 #import "ios/chrome/browser/ui/infobars/infobar_view_protocol.h" |
| 14 #include "ui/gfx/image/image.h" | 14 #include "ui/gfx/image/image.h" |
| 15 | 15 |
| 16 @interface TranslateMessageInfoBarController () | 16 @interface TranslateMessageInfoBarController () |
| 17 | 17 |
| 18 // Action for any of the user defined buttons. | 18 // Action for any of the user defined buttons. |
| 19 - (void)infoBarButtonDidPress:(id)sender; | 19 - (void)infoBarButtonDidPress:(id)sender; |
| 20 | 20 |
| 21 @end | 21 @end |
| 22 | 22 |
| 23 @implementation TranslateMessageInfoBarController | 23 @implementation TranslateMessageInfoBarController |
| 24 | 24 |
| 25 - (UIView<InfoBarViewProtocol>*)viewForDelegate: | 25 - (UIView<InfoBarViewProtocol>*)viewForDelegate: |
| 26 (infobars::InfoBarDelegate*)delegate | 26 (infobars::InfoBarDelegate*)delegate |
| 27 frame:(CGRect)frame { | 27 frame:(CGRect)frame { |
| 28 base::scoped_nsobject<UIView<InfoBarViewProtocol>> infoBarView; | 28 base::scoped_nsobject<UIView<InfoBarViewProtocol>> infoBarView; |
| 29 translate::TranslateInfoBarDelegate* translateInfoBarDelegate = | 29 translate::TranslateInfoBarDelegate* translateInfoBarDelegate = |
| 30 delegate->AsTranslateInfoBarDelegate(); | 30 delegate->AsTranslateInfoBarDelegate(); |
| 31 infoBarView.reset( | 31 infoBarView.reset( |
| 32 ios::GetChromeBrowserProvider()->CreateInfoBarView(frame, self.delegate)); | 32 [[InfoBarView alloc] initWithFrame:frame delegate:self.delegate]); |
| 33 // Icon | 33 // Icon |
| 34 gfx::Image icon = translateInfoBarDelegate->GetIcon(); | 34 gfx::Image icon = translateInfoBarDelegate->GetIcon(); |
| 35 if (!icon.IsEmpty()) | 35 if (!icon.IsEmpty()) |
| 36 [infoBarView addLeftIcon:icon.ToUIImage()]; | 36 [infoBarView addLeftIcon:icon.ToUIImage()]; |
| 37 // Text. | 37 // Text. |
| 38 [infoBarView addLabel:base::SysUTF16ToNSString( | 38 [infoBarView addLabel:base::SysUTF16ToNSString( |
| 39 translateInfoBarDelegate->GetMessageInfoBarText())]; | 39 translateInfoBarDelegate->GetMessageInfoBarText())]; |
| 40 // Close button. | 40 // Close button. |
| 41 [infoBarView addCloseButtonWithTag:TranslateInfoBarIOSTag::CLOSE | 41 [infoBarView addCloseButtonWithTag:TranslateInfoBarIOSTag::CLOSE |
| 42 target:self | 42 target:self |
| (...skipping 24 matching lines...) Expand all Loading... |
| 67 if (buttonId == TranslateInfoBarIOSTag::CLOSE) { | 67 if (buttonId == TranslateInfoBarIOSTag::CLOSE) { |
| 68 self.delegate->InfoBarDidCancel(); | 68 self.delegate->InfoBarDidCancel(); |
| 69 } else { | 69 } else { |
| 70 DCHECK(buttonId == TranslateInfoBarIOSTag::MESSAGE); | 70 DCHECK(buttonId == TranslateInfoBarIOSTag::MESSAGE); |
| 71 self.delegate->InfoBarButtonDidPress(buttonId); | 71 self.delegate->InfoBarButtonDidPress(buttonId); |
| 72 } | 72 } |
| 73 } | 73 } |
| 74 } | 74 } |
| 75 | 75 |
| 76 @end | 76 @end |
| OLD | NEW |