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 #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/mac/scoped_nsobject.h" |
9 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
10 #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" |
11 #import "ios/chrome/browser/ui/infobars/infobar_view.h" | 11 #import "ios/chrome/browser/ui/infobars/infobar_view.h" |
12 #include "ios/chrome/browser/ui/infobars/infobar_view_protocol.h" | 12 #include "ios/chrome/browser/ui/infobars/infobar_view.h" |
13 #include "ios/chrome/grit/ios_strings.h" | 13 #include "ios/chrome/grit/ios_strings.h" |
14 #import "ios/public/provider/chrome/browser/native_app_launcher/native_app_types
.h" | 14 #import "ios/public/provider/chrome/browser/native_app_launcher/native_app_types
.h" |
15 #include "ui/base/l10n/l10n_util.h" | 15 #include "ui/base/l10n/l10n_util.h" |
16 | 16 |
17 @interface NativeAppInfoBarController () | 17 @interface NativeAppInfoBarController () |
18 | 18 |
19 // Action for any of the user defined buttons. | 19 // Action for any of the user defined buttons. |
20 - (void)infoBarButtonDidPress:(UIButton*)button; | 20 - (void)infoBarButtonDidPress:(UIButton*)button; |
21 | 21 |
22 // Notifies the delegate of which action the user took. | 22 // Notifies the delegate of which action the user took. |
23 - (void)userPerformedAction:(NativeAppActionType)userAction; | 23 - (void)userPerformedAction:(NativeAppActionType)userAction; |
24 | 24 |
25 // For testing. | 25 // For testing. |
26 // Sets the infobar delegate. | 26 // Sets the infobar delegate. |
27 - (void)setInfoBarDelegate:(NativeAppInfoBarDelegate*)delegate; | 27 - (void)setInfoBarDelegate:(NativeAppInfoBarDelegate*)delegate; |
28 | 28 |
29 @end | 29 @end |
30 | 30 |
31 @implementation NativeAppInfoBarController { | 31 @implementation NativeAppInfoBarController { |
32 NativeAppInfoBarDelegate* nativeAppInfoBarDelegate_; // weak | 32 NativeAppInfoBarDelegate* nativeAppInfoBarDelegate_; // weak |
33 } | 33 } |
34 | 34 |
35 #pragma mark - InfoBarController | 35 #pragma mark - InfoBarController |
36 | 36 |
37 - (UIView<InfoBarViewProtocol>*)viewForDelegate: | 37 - (InfoBarView*)viewForDelegate:(infobars::InfoBarDelegate*)delegate |
38 (infobars::InfoBarDelegate*)delegate | 38 frame:(CGRect)frame { |
39 frame:(CGRect)frame { | 39 base::scoped_nsobject<InfoBarView> infoBarView; |
40 base::scoped_nsobject<UIView<InfoBarViewProtocol>> infoBarView; | |
41 nativeAppInfoBarDelegate_ = static_cast<NativeAppInfoBarDelegate*>(delegate); | 40 nativeAppInfoBarDelegate_ = static_cast<NativeAppInfoBarDelegate*>(delegate); |
42 DCHECK(nativeAppInfoBarDelegate_); | 41 DCHECK(nativeAppInfoBarDelegate_); |
43 infoBarView.reset( | 42 infoBarView.reset( |
44 [[InfoBarView alloc] initWithFrame:frame delegate:self.delegate]); | 43 [[InfoBarView alloc] initWithFrame:frame delegate:self.delegate]); |
45 | 44 |
46 // Lays out widgets common to all NativeAppInfobars. | 45 // Lays out widgets common to all NativeAppInfobars. |
47 [infoBarView | 46 [infoBarView |
48 addPlaceholderTransparentIcon:native_app_infobar::kSmallIconSize]; | 47 addPlaceholderTransparentIcon:native_app_infobar::kSmallIconSize]; |
49 nativeAppInfoBarDelegate_->FetchSmallAppIcon(^(UIImage* image) { | 48 nativeAppInfoBarDelegate_->FetchSmallAppIcon(^(UIImage* image) { |
50 [infoBarView addLeftIconWithRoundedCornersAndShadow:image]; | 49 [infoBarView addLeftIconWithRoundedCornersAndShadow:image]; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 nativeAppInfoBarDelegate_->UserPerformedAction(userAction); | 117 nativeAppInfoBarDelegate_->UserPerformedAction(userAction); |
119 } | 118 } |
120 | 119 |
121 #pragma mark - Testing | 120 #pragma mark - Testing |
122 | 121 |
123 - (void)setInfoBarDelegate:(NativeAppInfoBarDelegate*)delegate { | 122 - (void)setInfoBarDelegate:(NativeAppInfoBarDelegate*)delegate { |
124 nativeAppInfoBarDelegate_ = delegate; | 123 nativeAppInfoBarDelegate_ = delegate; |
125 } | 124 } |
126 | 125 |
127 @end | 126 @end |
OLD | NEW |