| 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/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" |
| 11 #include "ios/chrome/browser/translate/translate_infobar_tags.h" | 11 #include "ios/chrome/browser/translate/translate_infobar_tags.h" |
| 12 #include "ios/chrome/grit/ios_chromium_strings.h" |
| 13 #include "ios/chrome/grit/ios_google_chrome_strings.h" |
| 12 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" | 14 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" |
| 13 #import "ios/public/provider/chrome/browser/ui/infobar_view_delegate.h" | 15 #import "ios/public/provider/chrome/browser/ui/infobar_view_delegate.h" |
| 14 #import "ios/public/provider/chrome/browser/ui/infobar_view_protocol.h" | 16 #import "ios/public/provider/chrome/browser/ui/infobar_view_protocol.h" |
| 15 #include "ui/base/l10n/l10n_util.h" | 17 #include "ui/base/l10n/l10n_util.h" |
| 16 #include "ui/gfx/image/image.h" | 18 #include "ui/gfx/image/image.h" |
| 17 | 19 |
| 18 @interface NeverTranslateInfoBarController () | 20 @interface NeverTranslateInfoBarController () |
| 19 | 21 |
| 20 // Action for any of the user defined buttons. | 22 // Action for any of the user defined buttons. |
| 21 - (void)infoBarButtonDidPress:(id)sender; | 23 - (void)infoBarButtonDidPress:(id)sender; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 35 delegate->AsTranslateInfoBarDelegate(); | 37 delegate->AsTranslateInfoBarDelegate(); |
| 36 ios::ChromeBrowserProvider* provider = ios::GetChromeBrowserProvider(); | 38 ios::ChromeBrowserProvider* provider = ios::GetChromeBrowserProvider(); |
| 37 infoBarView.reset(provider->CreateInfoBarView(frame, self.delegate)); | 39 infoBarView.reset(provider->CreateInfoBarView(frame, self.delegate)); |
| 38 // Icon | 40 // Icon |
| 39 gfx::Image icon = translateInfoBarDelegate->GetIcon(); | 41 gfx::Image icon = translateInfoBarDelegate->GetIcon(); |
| 40 if (!icon.IsEmpty()) | 42 if (!icon.IsEmpty()) |
| 41 [infoBarView addLeftIcon:icon.ToUIImage()]; | 43 [infoBarView addLeftIcon:icon.ToUIImage()]; |
| 42 // Main text. | 44 // Main text. |
| 43 base::string16 originalLanguage = | 45 base::string16 originalLanguage = |
| 44 translateInfoBarDelegate->original_language_name(); | 46 translateInfoBarDelegate->original_language_name(); |
| 45 [infoBarView addLabel:l10n_util::GetNSStringF( | 47 [infoBarView |
| 46 IDS_TRANSLATE_INFOBAR_NEVER_MESSAGE_IOS, | 48 addLabel:l10n_util::GetNSStringF(IDS_IOS_TRANSLATE_INFOBAR_NEVER_MESSAGE, |
| 47 originalLanguage)]; | 49 originalLanguage)]; |
| 48 // Close button. | 50 // Close button. |
| 49 [infoBarView addCloseButtonWithTag:TranslateInfoBarIOSTag::CLOSE | 51 [infoBarView addCloseButtonWithTag:TranslateInfoBarIOSTag::CLOSE |
| 50 target:self | 52 target:self |
| 51 action:@selector(infoBarButtonDidPress:)]; | 53 action:@selector(infoBarButtonDidPress:)]; |
| 52 // Other buttons. | 54 // Other buttons. |
| 53 NSString* buttonLanguage = l10n_util::GetNSStringF( | 55 NSString* buttonLanguage = l10n_util::GetNSStringF( |
| 54 IDS_TRANSLATE_INFOBAR_NEVER_TRANSLATE, originalLanguage); | 56 IDS_TRANSLATE_INFOBAR_NEVER_TRANSLATE, originalLanguage); |
| 55 NSString* buttonSite = l10n_util::GetNSString( | 57 NSString* buttonSite = l10n_util::GetNSString( |
| 56 IDS_TRANSLATE_INFOBAR_OPTIONS_NEVER_TRANSLATE_SITE); | 58 IDS_TRANSLATE_INFOBAR_OPTIONS_NEVER_TRANSLATE_SITE); |
| 57 [infoBarView addButton1:buttonLanguage | 59 [infoBarView addButton1:buttonLanguage |
| (...skipping 20 matching lines...) Expand all Loading... |
| 78 self.delegate->InfoBarDidCancel(); | 80 self.delegate->InfoBarDidCancel(); |
| 79 } else { | 81 } else { |
| 80 DCHECK(buttonId == TranslateInfoBarIOSTag::DENY_LANGUAGE || | 82 DCHECK(buttonId == TranslateInfoBarIOSTag::DENY_LANGUAGE || |
| 81 buttonId == TranslateInfoBarIOSTag::DENY_WEBSITE); | 83 buttonId == TranslateInfoBarIOSTag::DENY_WEBSITE); |
| 82 self.delegate->InfoBarButtonDidPress(buttonId); | 84 self.delegate->InfoBarButtonDidPress(buttonId); |
| 83 } | 85 } |
| 84 } | 86 } |
| 85 } | 87 } |
| 86 | 88 |
| 87 @end | 89 @end |
| OLD | NEW |