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

Side by Side Diff: ios/chrome/browser/native_app_launcher/native_app_infobar_controller.mm

Issue 2949103008: [ObjC ARC] Converts ios/chrome/browser/native_app_launcher:native_app_launcher to ARC. (Closed)
Patch Set: missing weak Created 3 years, 5 months 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"
9 #include "base/strings/sys_string_conversions.h" 8 #include "base/strings/sys_string_conversions.h"
10 #include "ios/chrome/browser/native_app_launcher/native_app_infobar_delegate.h" 9 #include "ios/chrome/browser/native_app_launcher/native_app_infobar_delegate.h"
11 #import "ios/chrome/browser/ui/infobars/infobar_view.h" 10 #import "ios/chrome/browser/ui/infobars/infobar_view.h"
12 #include "ios/chrome/browser/ui/infobars/infobar_view.h" 11 #include "ios/chrome/browser/ui/infobars/infobar_view.h"
13 #include "ios/chrome/grit/ios_strings.h" 12 #include "ios/chrome/grit/ios_strings.h"
14 #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"
15 #include "ui/base/l10n/l10n_util.h" 14 #include "ui/base/l10n/l10n_util.h"
16 15
16 #if !defined(__has_feature) || !__has_feature(objc_arc)
17 #error "This file requires ARC support."
18 #endif
19
17 @interface NativeAppInfoBarController () 20 @interface NativeAppInfoBarController ()
18 21
19 // Action for any of the user defined buttons. 22 // Action for any of the user defined buttons.
20 - (void)infoBarButtonDidPress:(UIButton*)button; 23 - (void)infoBarButtonDidPress:(UIButton*)button;
21 24
22 // Notifies the delegate of which action the user took. 25 // Notifies the delegate of which action the user took.
23 - (void)userPerformedAction:(NativeAppActionType)userAction; 26 - (void)userPerformedAction:(NativeAppActionType)userAction;
24 27
25 // For testing. 28 // For testing.
26 // Sets the infobar delegate. 29 // Sets the infobar delegate.
27 - (void)setInfoBarDelegate:(NativeAppInfoBarDelegate*)delegate; 30 - (void)setInfoBarDelegate:(NativeAppInfoBarDelegate*)delegate;
28 31
29 @end 32 @end
30 33
31 @implementation NativeAppInfoBarController { 34 @implementation NativeAppInfoBarController {
32 NativeAppInfoBarDelegate* nativeAppInfoBarDelegate_; // weak 35 NativeAppInfoBarDelegate* nativeAppInfoBarDelegate_; // weak
33 } 36 }
34 37
35 #pragma mark - InfoBarController 38 #pragma mark - InfoBarController
36 39
37 - (InfoBarView*)viewForDelegate:(infobars::InfoBarDelegate*)delegate 40 - (InfoBarView*)viewForDelegate:(infobars::InfoBarDelegate*)delegate
38 frame:(CGRect)frame { 41 frame:(CGRect)frame {
39 base::scoped_nsobject<InfoBarView> infoBarView; 42 InfoBarView* infoBarView;
40 nativeAppInfoBarDelegate_ = static_cast<NativeAppInfoBarDelegate*>(delegate); 43 nativeAppInfoBarDelegate_ = static_cast<NativeAppInfoBarDelegate*>(delegate);
41 DCHECK(nativeAppInfoBarDelegate_); 44 DCHECK(nativeAppInfoBarDelegate_);
42 infoBarView.reset( 45 infoBarView =
43 [[InfoBarView alloc] initWithFrame:frame delegate:self.delegate]); 46 [[InfoBarView alloc] initWithFrame:frame delegate:self.delegate];
44 47
45 // Lays out widgets common to all NativeAppInfobars. 48 // Lays out widgets common to all NativeAppInfobars.
46 [infoBarView 49 [infoBarView
47 addPlaceholderTransparentIcon:native_app_infobar::kSmallIconSize]; 50 addPlaceholderTransparentIcon:native_app_infobar::kSmallIconSize];
48 nativeAppInfoBarDelegate_->FetchSmallAppIcon(^(UIImage* image) { 51 nativeAppInfoBarDelegate_->FetchSmallAppIcon(^(UIImage* image) {
49 [infoBarView addLeftIconWithRoundedCornersAndShadow:image]; 52 [infoBarView addLeftIconWithRoundedCornersAndShadow:image];
50 }); 53 });
51 [infoBarView addCloseButtonWithTag:NATIVE_APP_ACTION_DISMISS 54 [infoBarView addCloseButtonWithTag:NATIVE_APP_ACTION_DISMISS
52 target:self 55 target:self
53 action:@selector(infoBarButtonDidPress:)]; 56 action:@selector(infoBarButtonDidPress:)];
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 [infoBarView addLabel:labelMsg]; 92 [infoBarView addLabel:labelMsg];
90 [infoBarView addButton1:buttonOnceString 93 [infoBarView addButton1:buttonOnceString
91 tag1:NATIVE_APP_ACTION_CLICK_ONCE 94 tag1:NATIVE_APP_ACTION_CLICK_ONCE
92 button2:buttonAlwaysString 95 button2:buttonAlwaysString
93 tag2:NATIVE_APP_ACTION_CLICK_ALWAYS 96 tag2:NATIVE_APP_ACTION_CLICK_ALWAYS
94 target:self 97 target:self
95 action:@selector(infoBarButtonDidPress:)]; 98 action:@selector(infoBarButtonDidPress:)];
96 break; 99 break;
97 } 100 }
98 } 101 }
99 return [[infoBarView retain] autorelease]; 102 return infoBarView;
100 } 103 }
101 104
102 - (void)infoBarButtonDidPress:(UIButton*)button { 105 - (void)infoBarButtonDidPress:(UIButton*)button {
103 DCHECK(nativeAppInfoBarDelegate_); 106 DCHECK(nativeAppInfoBarDelegate_);
104 DCHECK([button isKindOfClass:[UIButton class]]); 107 DCHECK([button isKindOfClass:[UIButton class]]);
105 // This press might have occurred after the user has already pressed a button, 108 // 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 109 // in which case the view has been detached from the delegate and this press
107 // should be ignored. 110 // should be ignored.
108 if (!self.delegate) { 111 if (!self.delegate) {
109 return; 112 return;
110 } 113 }
111 self.delegate->InfoBarDidCancel(); 114 self.delegate->InfoBarDidCancel();
112 NativeAppActionType action = static_cast<NativeAppActionType>([button tag]); 115 NativeAppActionType action = static_cast<NativeAppActionType>([button tag]);
113 [self userPerformedAction:action]; 116 [self userPerformedAction:action];
114 } 117 }
115 118
116 - (void)userPerformedAction:(NativeAppActionType)userAction { 119 - (void)userPerformedAction:(NativeAppActionType)userAction {
117 nativeAppInfoBarDelegate_->UserPerformedAction(userAction); 120 nativeAppInfoBarDelegate_->UserPerformedAction(userAction);
118 } 121 }
119 122
120 #pragma mark - Testing 123 #pragma mark - Testing
121 124
122 - (void)setInfoBarDelegate:(NativeAppInfoBarDelegate*)delegate { 125 - (void)setInfoBarDelegate:(NativeAppInfoBarDelegate*)delegate {
123 nativeAppInfoBarDelegate_ = delegate; 126 nativeAppInfoBarDelegate_ = delegate;
124 } 127 }
125 128
126 @end 129 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698