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/strings/sys_string_conversions.h" | 7 #include "base/strings/sys_string_conversions.h" |
8 #include "components/translate/core/browser/translate_infobar_delegate.h" | 8 #include "components/translate/core/browser/translate_infobar_delegate.h" |
9 #include "ios/chrome/browser/translate/translate_infobar_tags.h" | 9 #include "ios/chrome/browser/translate/translate_infobar_tags.h" |
10 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" | 10 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 @implementation TranslateMessageInfoBarController | 22 @implementation TranslateMessageInfoBarController |
23 | 23 |
24 #pragma mark - | 24 #pragma mark - |
25 #pragma mark InfoBarControllerProtocol | 25 #pragma mark InfoBarControllerProtocol |
26 | 26 |
27 - (void)layoutForDelegate:(infobars::InfoBarDelegate*)delegate | 27 - (void)layoutForDelegate:(infobars::InfoBarDelegate*)delegate |
28 frame:(CGRect)frame { | 28 frame:(CGRect)frame { |
29 translate::TranslateInfoBarDelegate* translateInfoBarDelegate = | 29 translate::TranslateInfoBarDelegate* translateInfoBarDelegate = |
30 delegate->AsTranslateInfoBarDelegate(); | 30 delegate->AsTranslateInfoBarDelegate(); |
31 infobars::InfoBarDelegate* infoBarDelegate = | |
32 static_cast<infobars::InfoBarDelegate*>(translateInfoBarDelegate); | |
33 DCHECK(!infoBarView_); | 31 DCHECK(!infoBarView_); |
34 infoBarView_.reset([ios::GetChromeBrowserProvider()->CreateInfoBarView() | 32 infoBarView_.reset([ios::GetChromeBrowserProvider()->CreateInfoBarView() |
35 initWithFrame:frame | 33 initWithFrame:frame |
36 delegate:delegate_ | 34 delegate:delegate_]); |
37 isWarning:infoBarDelegate->GetInfoBarType() == | |
38 infobars::InfoBarDelegate::WARNING_TYPE]); | |
39 // Icon | 35 // Icon |
40 gfx::Image icon = translateInfoBarDelegate->GetIcon(); | 36 gfx::Image icon = translateInfoBarDelegate->GetIcon(); |
41 if (!icon.IsEmpty()) | 37 if (!icon.IsEmpty()) |
42 [infoBarView_ addLeftIcon:icon.ToUIImage()]; | 38 [infoBarView_ addLeftIcon:icon.ToUIImage()]; |
43 // Text. | 39 // Text. |
44 [infoBarView_ | 40 [infoBarView_ |
45 addLabel:base::SysUTF16ToNSString( | 41 addLabel:base::SysUTF16ToNSString( |
46 translateInfoBarDelegate->GetMessageInfoBarText())]; | 42 translateInfoBarDelegate->GetMessageInfoBarText())]; |
47 // Close button. | 43 // Close button. |
48 [infoBarView_ addCloseButtonWithTag:TranslateInfoBarIOSTag::CLOSE | 44 [infoBarView_ addCloseButtonWithTag:TranslateInfoBarIOSTag::CLOSE |
(...skipping 24 matching lines...) Expand all Loading... |
73 if (buttonId == TranslateInfoBarIOSTag::CLOSE) { | 69 if (buttonId == TranslateInfoBarIOSTag::CLOSE) { |
74 delegate_->InfoBarDidCancel(); | 70 delegate_->InfoBarDidCancel(); |
75 } else { | 71 } else { |
76 DCHECK(buttonId == TranslateInfoBarIOSTag::MESSAGE); | 72 DCHECK(buttonId == TranslateInfoBarIOSTag::MESSAGE); |
77 delegate_->InfoBarButtonDidPress(buttonId); | 73 delegate_->InfoBarButtonDidPress(buttonId); |
78 } | 74 } |
79 } | 75 } |
80 } | 76 } |
81 | 77 |
82 @end | 78 @end |
OLD | NEW |