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

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

Issue 2574463002: [ObjC ARC] Converts ios/chrome/browser/infobars:infobars to ARC.\n\nAutomatically generated ARCMigr… (Closed)
Patch Set: retain-autorelease 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/before_translate_infobar_controller.h" 5 #include "ios/chrome/browser/translate/before_translate_infobar_controller.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #import <UIKit/UIKit.h> 8 #import <UIKit/UIKit.h>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/mac/scoped_nsobject.h"
11 #include "base/strings/sys_string_conversions.h" 12 #include "base/strings/sys_string_conversions.h"
12 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
13 #include "components/strings/grit/components_strings.h" 14 #include "components/strings/grit/components_strings.h"
14 #include "components/translate/core/browser/translate_infobar_delegate.h" 15 #include "components/translate/core/browser/translate_infobar_delegate.h"
15 #include "ios/chrome/browser/translate/translate_infobar_tags.h" 16 #include "ios/chrome/browser/translate/translate_infobar_tags.h"
16 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" 17 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h"
17 #import "ios/public/provider/chrome/browser/ui/infobar_view_delegate.h" 18 #import "ios/public/provider/chrome/browser/ui/infobar_view_delegate.h"
18 #import "ios/public/provider/chrome/browser/ui/infobar_view_protocol.h" 19 #import "ios/public/provider/chrome/browser/ui/infobar_view_protocol.h"
19 #include "ui/base/l10n/l10n_util.h" 20 #include "ui/base/l10n/l10n_util.h"
20 #include "ui/gfx/image/image.h" 21 #include "ui/gfx/image/image.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 // Navigation bar associated with the picker with "Done" and "Cancel" buttons. 121 // Navigation bar associated with the picker with "Done" and "Cancel" buttons.
121 base::scoped_nsobject<UINavigationBar> _navigationBar; 122 base::scoped_nsobject<UINavigationBar> _navigationBar;
122 // The controller of the languagePicker. Needs to be an ivar because 123 // The controller of the languagePicker. Needs to be an ivar because
123 // |_languagePicker| does not retain it. 124 // |_languagePicker| does not retain it.
124 base::scoped_nsobject<LanguagePickerController> _languagePickerController; 125 base::scoped_nsobject<LanguagePickerController> _languagePickerController;
125 } 126 }
126 127
127 #pragma mark - 128 #pragma mark -
128 #pragma mark InfoBarControllerProtocol 129 #pragma mark InfoBarControllerProtocol
129 130
130 - (base::scoped_nsobject<UIView<InfoBarViewProtocol>>) 131 - (UIView<InfoBarViewProtocol>*)viewForDelegate:
131 viewForDelegate:(infobars::InfoBarDelegate*)delegate 132 (infobars::InfoBarDelegate*)delegate
132 frame:(CGRect)frame { 133 frame:(CGRect)frame {
133 base::scoped_nsobject<UIView<InfoBarViewProtocol>> infoBarView; 134 base::scoped_nsobject<UIView<InfoBarViewProtocol>> infoBarView;
134 _translateInfoBarDelegate = delegate->AsTranslateInfoBarDelegate(); 135 _translateInfoBarDelegate = delegate->AsTranslateInfoBarDelegate();
135 infoBarView.reset( 136 infoBarView.reset(
136 ios::GetChromeBrowserProvider()->CreateInfoBarView(frame, self.delegate)); 137 ios::GetChromeBrowserProvider()->CreateInfoBarView(frame, self.delegate));
137 // Icon 138 // Icon
138 gfx::Image icon = _translateInfoBarDelegate->GetIcon(); 139 gfx::Image icon = _translateInfoBarDelegate->GetIcon();
139 if (!icon.IsEmpty()) 140 if (!icon.IsEmpty())
140 [infoBarView addLeftIcon:icon.ToUIImage()]; 141 [infoBarView addLeftIcon:icon.ToUIImage()];
141 142
142 // Main text. 143 // Main text.
143 [self updateInfobarLabelOnView:infoBarView]; 144 [self updateInfobarLabelOnView:infoBarView];
144 145
145 // Close button. 146 // Close button.
146 [infoBarView addCloseButtonWithTag:TranslateInfoBarIOSTag::BEFORE_DENY 147 [infoBarView addCloseButtonWithTag:TranslateInfoBarIOSTag::BEFORE_DENY
147 target:self 148 target:self
148 action:@selector(infoBarButtonDidPress:)]; 149 action:@selector(infoBarButtonDidPress:)];
149 // Other buttons. 150 // Other buttons.
150 NSString* buttonAccept = l10n_util::GetNSString(IDS_TRANSLATE_INFOBAR_ACCEPT); 151 NSString* buttonAccept = l10n_util::GetNSString(IDS_TRANSLATE_INFOBAR_ACCEPT);
151 NSString* buttonDeny = l10n_util::GetNSString(IDS_TRANSLATE_INFOBAR_DENY); 152 NSString* buttonDeny = l10n_util::GetNSString(IDS_TRANSLATE_INFOBAR_DENY);
152 [infoBarView addButton1:buttonAccept 153 [infoBarView addButton1:buttonAccept
153 tag1:TranslateInfoBarIOSTag::BEFORE_ACCEPT 154 tag1:TranslateInfoBarIOSTag::BEFORE_ACCEPT
154 button2:buttonDeny 155 button2:buttonDeny
155 tag2:TranslateInfoBarIOSTag::BEFORE_DENY 156 tag2:TranslateInfoBarIOSTag::BEFORE_DENY
156 target:self 157 target:self
157 action:@selector(infoBarButtonDidPress:)]; 158 action:@selector(infoBarButtonDidPress:)];
158 return infoBarView; 159 return [[infoBarView retain] autorelease];
159 } 160 }
160 161
161 - (void)updateInfobarLabelOnView:(UIView<InfoBarViewProtocol>*)view { 162 - (void)updateInfobarLabelOnView:(UIView<InfoBarViewProtocol>*)view {
162 NSString* originalLanguage = base::SysUTF16ToNSString( 163 NSString* originalLanguage = base::SysUTF16ToNSString(
163 _translateInfoBarDelegate->original_language_name()); 164 _translateInfoBarDelegate->original_language_name());
164 NSString* targetLanguage = base::SysUTF16ToNSString( 165 NSString* targetLanguage = base::SysUTF16ToNSString(
165 _translateInfoBarDelegate->target_language_name()); 166 _translateInfoBarDelegate->target_language_name());
166 base::string16 originalLanguageWithLink = 167 base::string16 originalLanguageWithLink =
167 base::SysNSStringToUTF16([[view class] 168 base::SysNSStringToUTF16([[view class]
168 stringAsLink:originalLanguage 169 stringAsLink:originalLanguage
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 [super removeView]; 366 [super removeView];
366 [self dismissLanguageSelectionView]; 367 [self dismissLanguageSelectionView];
367 } 368 }
368 369
369 - (void)detachView { 370 - (void)detachView {
370 [super detachView]; 371 [super detachView];
371 [self dismissLanguageSelectionView]; 372 [self dismissLanguageSelectionView];
372 } 373 }
373 374
374 @end 375 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698