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/after_translate_infobar_controller.h" | 5 #include "ios/chrome/browser/translate/after_translate_infobar_controller.h" |
6 | 6 |
7 #include "base/strings/sys_string_conversions.h" | 7 #include "base/strings/sys_string_conversions.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_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 "grit/components_strings.h" | 10 #include "grit/components_strings.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 | 27 |
28 @implementation AfterTranslateInfoBarController | 28 @implementation AfterTranslateInfoBarController |
29 | 29 |
30 #pragma mark - | 30 #pragma mark - |
31 #pragma mark InfoBarControllerProtocol | 31 #pragma mark InfoBarControllerProtocol |
32 | 32 |
33 - (void)layoutForDelegate:(infobars::InfoBarDelegate*)delegate | 33 - (void)layoutForDelegate:(infobars::InfoBarDelegate*)delegate |
34 frame:(CGRect)frame { | 34 frame:(CGRect)frame { |
35 _translateInfoBarDelegate = delegate->AsTranslateInfoBarDelegate(); | 35 _translateInfoBarDelegate = delegate->AsTranslateInfoBarDelegate(); |
36 DCHECK(_translateInfoBarDelegate); | 36 DCHECK(_translateInfoBarDelegate); |
37 infobars::InfoBarDelegate* infoBarDelegate = | |
38 static_cast<infobars::InfoBarDelegate*>(_translateInfoBarDelegate); | |
39 DCHECK(!infoBarView_); | 37 DCHECK(!infoBarView_); |
40 infoBarView_.reset([ios::GetChromeBrowserProvider()->CreateInfoBarView() | 38 infoBarView_.reset([ios::GetChromeBrowserProvider()->CreateInfoBarView() |
41 initWithFrame:frame | 39 initWithFrame:frame |
42 delegate:delegate_ | 40 delegate:delegate_]); |
43 isWarning:infoBarDelegate->GetInfoBarType() == | |
44 infobars::InfoBarDelegate::WARNING_TYPE]); | |
45 // Icon | 41 // Icon |
46 gfx::Image icon = _translateInfoBarDelegate->GetIcon(); | 42 gfx::Image icon = _translateInfoBarDelegate->GetIcon(); |
47 if (!icon.IsEmpty()) | 43 if (!icon.IsEmpty()) |
48 [infoBarView_ addLeftIcon:icon.ToUIImage()]; | 44 [infoBarView_ addLeftIcon:icon.ToUIImage()]; |
49 // Main text. | 45 // Main text. |
50 const bool autodeterminedSourceLanguage = | 46 const bool autodeterminedSourceLanguage = |
51 _translateInfoBarDelegate->original_language_index() == | 47 _translateInfoBarDelegate->original_language_index() == |
52 translate::TranslateInfoBarDelegate::kNoIndex; | 48 translate::TranslateInfoBarDelegate::kNoIndex; |
53 bool swappedLanguageButtons; | 49 bool swappedLanguageButtons; |
54 std::vector<base::string16> strings; | 50 std::vector<base::string16> strings; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 } | 116 } |
121 | 117 |
122 - (void)infoBarSwitchDidPress:(id)sender { | 118 - (void)infoBarSwitchDidPress:(id)sender { |
123 DCHECK_EQ(TranslateInfoBarIOSTag::ALWAYS_TRANSLATE_SWITCH, [sender tag]); | 119 DCHECK_EQ(TranslateInfoBarIOSTag::ALWAYS_TRANSLATE_SWITCH, [sender tag]); |
124 DCHECK([sender respondsToSelector:@selector(isOn)]); | 120 DCHECK([sender respondsToSelector:@selector(isOn)]); |
125 if (_translateInfoBarDelegate->ShouldAlwaysTranslate() != [sender isOn]) | 121 if (_translateInfoBarDelegate->ShouldAlwaysTranslate() != [sender isOn]) |
126 _translateInfoBarDelegate->ToggleAlwaysTranslate(); | 122 _translateInfoBarDelegate->ToggleAlwaysTranslate(); |
127 } | 123 } |
128 | 124 |
129 @end | 125 @end |
OLD | NEW |