Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(556)

Side by Side Diff: ios/chrome/browser/translate/never_translate_infobar_controller.mm

Issue 2574463002: [ObjC ARC] Converts ios/chrome/browser/infobars:infobars to ARC.\n\nAutomatically generated ARCMigr… (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/strings/sys_string_conversions.h" 8 #include "base/strings/sys_string_conversions.h"
8 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
9 #include "components/strings/grit/components_strings.h" 10 #include "components/strings/grit/components_strings.h"
10 #include "components/translate/core/browser/translate_infobar_delegate.h" 11 #include "components/translate/core/browser/translate_infobar_delegate.h"
11 #include "ios/chrome/browser/translate/translate_infobar_tags.h" 12 #include "ios/chrome/browser/translate/translate_infobar_tags.h"
12 #include "ios/chrome/grit/ios_chromium_strings.h" 13 #include "ios/chrome/grit/ios_chromium_strings.h"
13 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" 14 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h"
14 #import "ios/public/provider/chrome/browser/ui/infobar_view_delegate.h" 15 #import "ios/public/provider/chrome/browser/ui/infobar_view_delegate.h"
15 #import "ios/public/provider/chrome/browser/ui/infobar_view_protocol.h" 16 #import "ios/public/provider/chrome/browser/ui/infobar_view_protocol.h"
16 #include "ui/base/l10n/l10n_util.h" 17 #include "ui/base/l10n/l10n_util.h"
17 #include "ui/gfx/image/image.h" 18 #include "ui/gfx/image/image.h"
18 19
19 @interface NeverTranslateInfoBarController () 20 @interface NeverTranslateInfoBarController ()
20 21
21 // Action for any of the user defined buttons. 22 // Action for any of the user defined buttons.
22 - (void)infoBarButtonDidPress:(id)sender; 23 - (void)infoBarButtonDidPress:(id)sender;
23 24
24 @end 25 @end
25 26
26 @implementation NeverTranslateInfoBarController 27 @implementation NeverTranslateInfoBarController
27 28
28 #pragma mark - 29 #pragma mark -
29 #pragma mark InfoBarControllerProtocol 30 #pragma mark InfoBarControllerProtocol
30 31
31 - (base::scoped_nsobject<UIView<InfoBarViewProtocol>>) 32 - (UIView<InfoBarViewProtocol>*)viewForDelegate:
32 viewForDelegate:(infobars::InfoBarDelegate*)delegate 33 (infobars::InfoBarDelegate*)delegate
33 frame:(CGRect)frame { 34 frame:(CGRect)frame {
34 base::scoped_nsobject<UIView<InfoBarViewProtocol>> infoBarView; 35 base::scoped_nsobject<UIView<InfoBarViewProtocol>> infoBarView;
35 translate::TranslateInfoBarDelegate* translateInfoBarDelegate = 36 translate::TranslateInfoBarDelegate* translateInfoBarDelegate =
36 delegate->AsTranslateInfoBarDelegate(); 37 delegate->AsTranslateInfoBarDelegate();
37 ios::ChromeBrowserProvider* provider = ios::GetChromeBrowserProvider(); 38 ios::ChromeBrowserProvider* provider = ios::GetChromeBrowserProvider();
38 infoBarView.reset(provider->CreateInfoBarView(frame, self.delegate)); 39 infoBarView.reset(provider->CreateInfoBarView(frame, self.delegate));
39 // Icon 40 // Icon
40 gfx::Image icon = translateInfoBarDelegate->GetIcon(); 41 gfx::Image icon = translateInfoBarDelegate->GetIcon();
41 if (!icon.IsEmpty()) 42 if (!icon.IsEmpty())
42 [infoBarView addLeftIcon:icon.ToUIImage()]; 43 [infoBarView addLeftIcon:icon.ToUIImage()];
43 // Main text. 44 // Main text.
(...skipping 10 matching lines...) Expand all
54 NSString* buttonLanguage = l10n_util::GetNSStringF( 55 NSString* buttonLanguage = l10n_util::GetNSStringF(
55 IDS_TRANSLATE_INFOBAR_NEVER_TRANSLATE, originalLanguage); 56 IDS_TRANSLATE_INFOBAR_NEVER_TRANSLATE, originalLanguage);
56 NSString* buttonSite = l10n_util::GetNSString( 57 NSString* buttonSite = l10n_util::GetNSString(
57 IDS_TRANSLATE_INFOBAR_OPTIONS_NEVER_TRANSLATE_SITE); 58 IDS_TRANSLATE_INFOBAR_OPTIONS_NEVER_TRANSLATE_SITE);
58 [infoBarView addButton1:buttonLanguage 59 [infoBarView addButton1:buttonLanguage
59 tag1:TranslateInfoBarIOSTag::DENY_LANGUAGE 60 tag1:TranslateInfoBarIOSTag::DENY_LANGUAGE
60 button2:buttonSite 61 button2:buttonSite
61 tag2:TranslateInfoBarIOSTag::DENY_WEBSITE 62 tag2:TranslateInfoBarIOSTag::DENY_WEBSITE
62 target:self 63 target:self
63 action:@selector(infoBarButtonDidPress:)]; 64 action:@selector(infoBarButtonDidPress:)];
64 return infoBarView; 65 return infoBarView;
noyau (Ping after 24h) 2016/12/13 12:13:12 And here as well.
stkhapugin 2016/12/13 13:53:20 Done.
65 } 66 }
66 67
67 #pragma mark - Handling of User Events 68 #pragma mark - Handling of User Events
68 69
69 - (void)infoBarButtonDidPress:(id)sender { 70 - (void)infoBarButtonDidPress:(id)sender {
70 // This press might have occurred after the user has already pressed a button, 71 // This press might have occurred after the user has already pressed a button,
71 // in which case the view has been detached from the delegate and this press 72 // in which case the view has been detached from the delegate and this press
72 // should be ignored. 73 // should be ignored.
73 if (!self.delegate) { 74 if (!self.delegate) {
74 return; 75 return;
75 } 76 }
76 if ([sender isKindOfClass:[UIButton class]]) { 77 if ([sender isKindOfClass:[UIButton class]]) {
77 NSUInteger buttonId = static_cast<UIButton*>(sender).tag; 78 NSUInteger buttonId = static_cast<UIButton*>(sender).tag;
78 if (buttonId == TranslateInfoBarIOSTag::CLOSE) { 79 if (buttonId == TranslateInfoBarIOSTag::CLOSE) {
79 self.delegate->InfoBarDidCancel(); 80 self.delegate->InfoBarDidCancel();
80 } else { 81 } else {
81 DCHECK(buttonId == TranslateInfoBarIOSTag::DENY_LANGUAGE || 82 DCHECK(buttonId == TranslateInfoBarIOSTag::DENY_LANGUAGE ||
82 buttonId == TranslateInfoBarIOSTag::DENY_WEBSITE); 83 buttonId == TranslateInfoBarIOSTag::DENY_WEBSITE);
83 self.delegate->InfoBarButtonDidPress(buttonId); 84 self.delegate->InfoBarButtonDidPress(buttonId);
84 } 85 }
85 } 86 }
86 } 87 }
87 88
88 @end 89 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698