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

Side by Side Diff: ios/chrome/browser/native_app_launcher/native_app_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 #import "ios/chrome/browser/native_app_launcher/native_app_infobar_controller.h" 5 #import "ios/chrome/browser/native_app_launcher/native_app_infobar_controller.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/mac/scoped_nsobject.h"
8 #include "base/strings/sys_string_conversions.h" 9 #include "base/strings/sys_string_conversions.h"
9 #include "ios/chrome/browser/native_app_launcher/native_app_infobar_delegate.h" 10 #include "ios/chrome/browser/native_app_launcher/native_app_infobar_delegate.h"
10 #include "ios/chrome/grit/ios_strings.h" 11 #include "ios/chrome/grit/ios_strings.h"
11 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" 12 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h"
12 #import "ios/public/provider/chrome/browser/native_app_launcher/native_app_types .h" 13 #import "ios/public/provider/chrome/browser/native_app_launcher/native_app_types .h"
13 #include "ios/public/provider/chrome/browser/ui/infobar_view_protocol.h" 14 #include "ios/public/provider/chrome/browser/ui/infobar_view_protocol.h"
14 #include "ui/base/l10n/l10n_util.h" 15 #include "ui/base/l10n/l10n_util.h"
15 16
16 @interface NativeAppInfoBarController () 17 @interface NativeAppInfoBarController ()
17 18
18 // Action for any of the user defined buttons. 19 // Action for any of the user defined buttons.
19 - (void)infoBarButtonDidPress:(UIButton*)button; 20 - (void)infoBarButtonDidPress:(UIButton*)button;
20 21
21 // Notifies the delegate of which action the user took. 22 // Notifies the delegate of which action the user took.
22 - (void)userPerformedAction:(NativeAppActionType)userAction; 23 - (void)userPerformedAction:(NativeAppActionType)userAction;
23 24
24 // For testing. 25 // For testing.
25 // Sets the infobar delegate. 26 // Sets the infobar delegate.
26 - (void)setInfoBarDelegate:(NativeAppInfoBarDelegate*)delegate; 27 - (void)setInfoBarDelegate:(NativeAppInfoBarDelegate*)delegate;
27 28
28 @end 29 @end
29 30
30 @implementation NativeAppInfoBarController { 31 @implementation NativeAppInfoBarController {
31 NativeAppInfoBarDelegate* nativeAppInfoBarDelegate_; // weak 32 NativeAppInfoBarDelegate* nativeAppInfoBarDelegate_; // weak
32 } 33 }
33 34
34 #pragma mark - InfoBarController 35 #pragma mark - InfoBarController
35 36
36 - (base::scoped_nsobject<UIView<InfoBarViewProtocol>>) 37 - (UIView<InfoBarViewProtocol>*)viewForDelegate:
37 viewForDelegate:(infobars::InfoBarDelegate*)delegate 38 (infobars::InfoBarDelegate*)delegate
38 frame:(CGRect)frame { 39 frame:(CGRect)frame {
39 base::scoped_nsobject<UIView<InfoBarViewProtocol>> infoBarView; 40 base::scoped_nsobject<UIView<InfoBarViewProtocol>> infoBarView;
40 nativeAppInfoBarDelegate_ = static_cast<NativeAppInfoBarDelegate*>(delegate); 41 nativeAppInfoBarDelegate_ = static_cast<NativeAppInfoBarDelegate*>(delegate);
41 DCHECK(nativeAppInfoBarDelegate_); 42 DCHECK(nativeAppInfoBarDelegate_);
42 infoBarView.reset( 43 infoBarView.reset(
43 ios::GetChromeBrowserProvider()->CreateInfoBarView(frame, self.delegate)); 44 ios::GetChromeBrowserProvider()->CreateInfoBarView(frame, self.delegate));
44 45
45 // Lays out widgets common to all NativeAppInfobars. 46 // Lays out widgets common to all NativeAppInfobars.
46 [infoBarView 47 [infoBarView
47 addPlaceholderTransparentIcon:native_app_infobar::kSmallIconSize]; 48 addPlaceholderTransparentIcon:native_app_infobar::kSmallIconSize];
48 nativeAppInfoBarDelegate_->FetchSmallAppIcon(^(UIImage* image) { 49 nativeAppInfoBarDelegate_->FetchSmallAppIcon(^(UIImage* image) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 [infoBarView addLabel:labelMsg]; 90 [infoBarView addLabel:labelMsg];
90 [infoBarView addButton1:buttonOnceString 91 [infoBarView addButton1:buttonOnceString
91 tag1:NATIVE_APP_ACTION_CLICK_ONCE 92 tag1:NATIVE_APP_ACTION_CLICK_ONCE
92 button2:buttonAlwaysString 93 button2:buttonAlwaysString
93 tag2:NATIVE_APP_ACTION_CLICK_ALWAYS 94 tag2:NATIVE_APP_ACTION_CLICK_ALWAYS
94 target:self 95 target:self
95 action:@selector(infoBarButtonDidPress:)]; 96 action:@selector(infoBarButtonDidPress:)];
96 break; 97 break;
97 } 98 }
98 } 99 }
99 return infoBarView; 100 return [[infoBarView retain] autorelease];
100 } 101 }
101 102
102 - (void)infoBarButtonDidPress:(UIButton*)button { 103 - (void)infoBarButtonDidPress:(UIButton*)button {
103 DCHECK(nativeAppInfoBarDelegate_); 104 DCHECK(nativeAppInfoBarDelegate_);
104 DCHECK([button isKindOfClass:[UIButton class]]); 105 DCHECK([button isKindOfClass:[UIButton class]]);
105 // This press might have occurred after the user has already pressed a button, 106 // This press might have occurred after the user has already pressed a button,
106 // in which case the view has been detached from the delegate and this press 107 // in which case the view has been detached from the delegate and this press
107 // should be ignored. 108 // should be ignored.
108 if (!self.delegate) { 109 if (!self.delegate) {
109 return; 110 return;
110 } 111 }
111 self.delegate->InfoBarDidCancel(); 112 self.delegate->InfoBarDidCancel();
112 NativeAppActionType action = static_cast<NativeAppActionType>([button tag]); 113 NativeAppActionType action = static_cast<NativeAppActionType>([button tag]);
113 [self userPerformedAction:action]; 114 [self userPerformedAction:action];
114 } 115 }
115 116
116 - (void)userPerformedAction:(NativeAppActionType)userAction { 117 - (void)userPerformedAction:(NativeAppActionType)userAction {
117 nativeAppInfoBarDelegate_->UserPerformedAction(userAction); 118 nativeAppInfoBarDelegate_->UserPerformedAction(userAction);
118 } 119 }
119 120
120 #pragma mark - Testing 121 #pragma mark - Testing
121 122
122 - (void)setInfoBarDelegate:(NativeAppInfoBarDelegate*)delegate { 123 - (void)setInfoBarDelegate:(NativeAppInfoBarDelegate*)delegate {
123 nativeAppInfoBarDelegate_ = delegate; 124 nativeAppInfoBarDelegate_ = delegate;
124 } 125 }
125 126
126 @end 127 @end
OLDNEW
« no previous file with comments | « ios/chrome/browser/infobars/infobar_utils.mm ('k') | ios/chrome/browser/native_app_launcher/native_app_infobar_delegate.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698