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/never_translate_infobar_controller.h" | 5 #include "ios/chrome/browser/translate/never_translate_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 "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "components/strings/grit/components_strings.h" | 10 #include "components/strings/grit/components_strings.h" |
11 #include "components/translate/core/browser/translate_infobar_delegate.h" | 11 #include "components/translate/core/browser/translate_infobar_delegate.h" |
12 #include "ios/chrome/browser/translate/translate_infobar_tags.h" | 12 #include "ios/chrome/browser/translate/translate_infobar_tags.h" |
13 #import "ios/chrome/browser/ui/infobars/infobar_view.h" | 13 #import "ios/chrome/browser/ui/infobars/infobar_view.h" |
14 #import "ios/chrome/browser/ui/infobars/infobar_view_delegate.h" | 14 #import "ios/chrome/browser/ui/infobars/infobar_view_delegate.h" |
15 #import "ios/chrome/browser/ui/infobars/infobar_view_protocol.h" | |
16 #include "ios/chrome/grit/ios_chromium_strings.h" | 15 #include "ios/chrome/grit/ios_chromium_strings.h" |
17 #include "ui/base/l10n/l10n_util.h" | 16 #include "ui/base/l10n/l10n_util.h" |
18 #include "ui/gfx/image/image.h" | 17 #include "ui/gfx/image/image.h" |
19 | 18 |
20 @interface NeverTranslateInfoBarController () | 19 @interface NeverTranslateInfoBarController () |
21 | 20 |
22 // Action for any of the user defined buttons. | 21 // Action for any of the user defined buttons. |
23 - (void)infoBarButtonDidPress:(id)sender; | 22 - (void)infoBarButtonDidPress:(id)sender; |
24 | 23 |
25 @end | 24 @end |
26 | 25 |
27 @implementation NeverTranslateInfoBarController | 26 @implementation NeverTranslateInfoBarController |
28 | 27 |
29 #pragma mark - | 28 #pragma mark - |
30 #pragma mark InfoBarControllerProtocol | 29 #pragma mark InfoBarControllerProtocol |
31 | 30 |
32 - (UIView<InfoBarViewProtocol>*)viewForDelegate: | 31 - (InfoBarView*)viewForDelegate:(infobars::InfoBarDelegate*)delegate |
33 (infobars::InfoBarDelegate*)delegate | 32 frame:(CGRect)frame { |
34 frame:(CGRect)frame { | 33 base::scoped_nsobject<InfoBarView> infoBarView; |
35 base::scoped_nsobject<UIView<InfoBarViewProtocol>> infoBarView; | |
36 translate::TranslateInfoBarDelegate* translateInfoBarDelegate = | 34 translate::TranslateInfoBarDelegate* translateInfoBarDelegate = |
37 delegate->AsTranslateInfoBarDelegate(); | 35 delegate->AsTranslateInfoBarDelegate(); |
38 infoBarView.reset( | 36 infoBarView.reset( |
39 [[InfoBarView alloc] initWithFrame:frame delegate:self.delegate]); | 37 [[InfoBarView alloc] initWithFrame:frame delegate:self.delegate]); |
40 // Icon | 38 // Icon |
41 gfx::Image icon = translateInfoBarDelegate->GetIcon(); | 39 gfx::Image icon = translateInfoBarDelegate->GetIcon(); |
42 if (!icon.IsEmpty()) | 40 if (!icon.IsEmpty()) |
43 [infoBarView addLeftIcon:icon.ToUIImage()]; | 41 [infoBarView addLeftIcon:icon.ToUIImage()]; |
44 // Main text. | 42 // Main text. |
45 base::string16 originalLanguage = | 43 base::string16 originalLanguage = |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 self.delegate->InfoBarDidCancel(); | 78 self.delegate->InfoBarDidCancel(); |
81 } else { | 79 } else { |
82 DCHECK(buttonId == TranslateInfoBarIOSTag::DENY_LANGUAGE || | 80 DCHECK(buttonId == TranslateInfoBarIOSTag::DENY_LANGUAGE || |
83 buttonId == TranslateInfoBarIOSTag::DENY_WEBSITE); | 81 buttonId == TranslateInfoBarIOSTag::DENY_WEBSITE); |
84 self.delegate->InfoBarButtonDidPress(buttonId); | 82 self.delegate->InfoBarButtonDidPress(buttonId); |
85 } | 83 } |
86 } | 84 } |
87 } | 85 } |
88 | 86 |
89 @end | 87 @end |
OLD | NEW |