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 #import "ios/chrome/browser/ui/infobars/infobar_view.h" | 11 #import "ios/chrome/browser/ui/infobars/infobar_view.h" |
12 #import "ios/chrome/browser/ui/infobars/infobar_view_delegate.h" | 12 #import "ios/chrome/browser/ui/infobars/infobar_view_delegate.h" |
13 #import "ios/chrome/browser/ui/infobars/infobar_view_protocol.h" | |
14 #include "ui/gfx/image/image.h" | 13 #include "ui/gfx/image/image.h" |
15 | 14 |
16 @interface TranslateMessageInfoBarController () | 15 @interface TranslateMessageInfoBarController () |
17 | 16 |
18 // Action for any of the user defined buttons. | 17 // Action for any of the user defined buttons. |
19 - (void)infoBarButtonDidPress:(id)sender; | 18 - (void)infoBarButtonDidPress:(id)sender; |
20 | 19 |
21 @end | 20 @end |
22 | 21 |
23 @implementation TranslateMessageInfoBarController | 22 @implementation TranslateMessageInfoBarController |
24 | 23 |
25 - (UIView<InfoBarViewProtocol>*)viewForDelegate: | 24 - (InfoBarView*)viewForDelegate:(infobars::InfoBarDelegate*)delegate |
26 (infobars::InfoBarDelegate*)delegate | 25 frame:(CGRect)frame { |
27 frame:(CGRect)frame { | 26 base::scoped_nsobject<InfoBarView> infoBarView; |
28 base::scoped_nsobject<UIView<InfoBarViewProtocol>> infoBarView; | |
29 translate::TranslateInfoBarDelegate* translateInfoBarDelegate = | 27 translate::TranslateInfoBarDelegate* translateInfoBarDelegate = |
30 delegate->AsTranslateInfoBarDelegate(); | 28 delegate->AsTranslateInfoBarDelegate(); |
31 infoBarView.reset( | 29 infoBarView.reset( |
32 [[InfoBarView alloc] initWithFrame:frame delegate:self.delegate]); | 30 [[InfoBarView alloc] initWithFrame:frame delegate:self.delegate]); |
33 // Icon | 31 // Icon |
34 gfx::Image icon = translateInfoBarDelegate->GetIcon(); | 32 gfx::Image icon = translateInfoBarDelegate->GetIcon(); |
35 if (!icon.IsEmpty()) | 33 if (!icon.IsEmpty()) |
36 [infoBarView addLeftIcon:icon.ToUIImage()]; | 34 [infoBarView addLeftIcon:icon.ToUIImage()]; |
37 // Text. | 35 // Text. |
38 [infoBarView addLabel:base::SysUTF16ToNSString( | 36 [infoBarView addLabel:base::SysUTF16ToNSString( |
(...skipping 28 matching lines...) Expand all Loading... |
67 if (buttonId == TranslateInfoBarIOSTag::CLOSE) { | 65 if (buttonId == TranslateInfoBarIOSTag::CLOSE) { |
68 self.delegate->InfoBarDidCancel(); | 66 self.delegate->InfoBarDidCancel(); |
69 } else { | 67 } else { |
70 DCHECK(buttonId == TranslateInfoBarIOSTag::MESSAGE); | 68 DCHECK(buttonId == TranslateInfoBarIOSTag::MESSAGE); |
71 self.delegate->InfoBarButtonDidPress(buttonId); | 69 self.delegate->InfoBarButtonDidPress(buttonId); |
72 } | 70 } |
73 } | 71 } |
74 } | 72 } |
75 | 73 |
76 @end | 74 @end |
OLD | NEW |