Chromium Code Reviews| Index: ios/chrome/browser/ui/ntp/google_landing_mediator.mm |
| diff --git a/ios/chrome/browser/ui/ntp/google_landing_mediator.mm b/ios/chrome/browser/ui/ntp/google_landing_mediator.mm |
| index ef06b35d8ba9ad36fdb36734646a180dd9197e99..dc0b176a6d85626600328417b74edfc7b1ff7ef3 100644 |
| --- a/ios/chrome/browser/ui/ntp/google_landing_mediator.mm |
| +++ b/ios/chrome/browser/ui/ntp/google_landing_mediator.mm |
| @@ -4,9 +4,7 @@ |
| #import "ios/chrome/browser/ui/ntp/google_landing_mediator.h" |
| -#import "base/ios/weak_nsobject.h" |
| #include "base/mac/bind_objc_block.h" |
| -#include "base/mac/scoped_nsobject.h" |
| #include "base/metrics/user_metrics.h" |
| #include "base/metrics/user_metrics_action.h" |
| #include "base/strings/sys_string_conversions.h" |
| @@ -44,6 +42,10 @@ |
| #include "ios/web/public/web_state/web_state.h" |
| #include "skia/ext/skia_utils_ios.h" |
| +#if !defined(__has_feature) || !__has_feature(objc_arc) |
| +#error "This file requires ARC support." |
| +#endif |
| + |
| using base::UserMetricsAction; |
| namespace { |
| @@ -70,7 +72,7 @@ class SearchEngineObserver : public TemplateURLServiceObserver { |
| void OnTemplateURLServiceChanged() override; |
| private: |
| - base::WeakNSObject<GoogleLandingMediator> _owner; |
| + __weak GoogleLandingMediator* _owner; |
| TemplateURLService* _templateURLService; // weak |
| }; |
| @@ -100,7 +102,7 @@ void SearchEngineObserver::OnTemplateURLServiceChanged() { |
| BOOL _recordedPageImpression; |
| // Controller to fetch and show doodles or a default Google logo. |
| - base::scoped_nsprotocol<id<LogoVendor>> _doodleController; |
| + id<LogoVendor> _doodleController; |
| // Listen for default search engine changes. |
| std::unique_ptr<google_landing::SearchEngineObserver> _observer; |
| @@ -128,13 +130,13 @@ void SearchEngineObserver::OnTemplateURLServiceChanged() { |
| } |
| // Consumer to handle google landing update notifications. |
| -@property(nonatomic) id<GoogleLandingConsumer> consumer; |
| +@property(weak, nonatomic) id<GoogleLandingConsumer> consumer; |
|
marq (ping after 24h)
2017/06/29 11:57:15
nit: nonatomic, weak
stkhapugin
2017/06/29 15:04:49
Done.
|
| // The WebStateList that is being observed by this mediator. |
| @property(nonatomic, assign) WebStateList* webStateList; |
| // The dispatcher for this mediator. |
| -@property(nonatomic, assign) id<ChromeExecuteCommand, UrlLoader> dispatcher; |
| +@property(nonatomic, weak) id<ChromeExecuteCommand, UrlLoader> dispatcher; |
| // Most visited data from the MostVisitedSites service (copied upon receiving |
| // the callback), not yet used. |
| @@ -200,8 +202,8 @@ void SearchEngineObserver::OnTemplateURLServiceChanged() { |
| _observer.reset( |
| new google_landing::SearchEngineObserver(self, _templateURLService)); |
| _templateURLService->Load(); |
| - _doodleController.reset(ios::GetChromeBrowserProvider()->CreateLogoVendor( |
| - _browserState, self.dispatcher)); |
| + _doodleController = ios::GetChromeBrowserProvider()->CreateLogoVendor( |
| + _browserState, self.dispatcher); |
| [_consumer setLogoVendor:_doodleController]; |
| [self updateShowLogo]; |
| @@ -296,7 +298,7 @@ void SearchEngineObserver::OnTemplateURLServiceChanged() { |
| fallbackCallback:(void (^)(UIColor* textColor, |
| UIColor* backgroundColor, |
| BOOL isDefaultColor))fallbackCallback { |
| - base::WeakNSObject<GoogleLandingMediator> weakSelf(self); |
| + __weak GoogleLandingMediator* weakSelf = self; |
| void (^faviconBlock)(const favicon_base::LargeIconResult&) = ^( |
| const favicon_base::LargeIconResult& result) { |
| @@ -317,7 +319,7 @@ void SearchEngineObserver::OnTemplateURLServiceChanged() { |
| fallbackCallback(textColor, backgroundColor, isDefaultColor); |
| } |
| - base::scoped_nsobject<GoogleLandingMediator> strongSelf([weakSelf retain]); |
| + GoogleLandingMediator* strongSelf = weakSelf; |
| if (strongSelf && |
| (result.bitmap.is_valid() || result.fallback_icon_style)) { |
| [strongSelf largeIconCache]->SetCachedResult(URL, result); |
| @@ -335,7 +337,7 @@ void SearchEngineObserver::OnTemplateURLServiceChanged() { |
| CGFloat faviconSize = [UIScreen mainScreen].scale * size; |
| CGFloat faviconMinSize = [UIScreen mainScreen].scale * kFaviconMinSize; |
| [self largeIconService]->GetLargeIconOrFallbackStyle( |
| - URL, faviconMinSize, faviconSize, base::BindBlock(faviconBlock), |
| + URL, faviconMinSize, faviconSize, base::BindBlockArc(faviconBlock), |
| &_cancelable_task_tracker); |
| } |
| @@ -430,9 +432,8 @@ void SearchEngineObserver::OnTemplateURLServiceChanged() { |
| } |
| if (_notification_promo->IsChromeCommand()) { |
| - base::scoped_nsobject<GenericChromeCommand> command( |
| - [[GenericChromeCommand alloc] |
| - initWithTag:_notification_promo->command_id()]); |
| + GenericChromeCommand* command = [[GenericChromeCommand alloc] |
| + initWithTag:_notification_promo->command_id()]; |
| [self.dispatcher chromeExecuteCommand:command]; |
| return; |
| } |