Index: ios/chrome/browser/ui/settings/native_apps_collection_view_controller.mm |
diff --git a/ios/chrome/browser/ui/settings/native_apps_collection_view_controller.mm b/ios/chrome/browser/ui/settings/native_apps_collection_view_controller.mm |
index 2ec5fb3b81f8d997a2f67a08c783563ff86c2f18..68602f5d12ed963218e85afbbdeed9b2cd38bc6d 100644 |
--- a/ios/chrome/browser/ui/settings/native_apps_collection_view_controller.mm |
+++ b/ios/chrome/browser/ui/settings/native_apps_collection_view_controller.mm |
@@ -7,10 +7,8 @@ |
#import <StoreKit/StoreKit.h> |
-#import "base/ios/weak_nsobject.h" |
#include "base/logging.h" |
#import "base/mac/foundation_util.h" |
-#import "base/mac/scoped_nsobject.h" |
#include "base/memory/ptr_util.h" |
#include "base/metrics/histogram_macros.h" |
#include "base/metrics/user_metrics.h" |
@@ -35,6 +33,10 @@ |
#include "ui/base/l10n/l10n_util.h" |
#include "url/gurl.h" |
+#if !defined(__has_feature) || !__has_feature(objc_arc) |
+#error "This file requires ARC support." |
+#endif |
+ |
const NSInteger kTagShift = 1000; |
namespace { |
@@ -54,7 +56,7 @@ typedef NS_ENUM(NSInteger, ItemType) { |
@interface NativeAppsCollectionViewController ()< |
SKStoreProductViewControllerDelegate> { |
std::unique_ptr<image_fetcher::IOSImageDataFetcherWrapper> _imageFetcher; |
- base::scoped_nsobject<NSArray> _nativeAppsInSettings; |
+ NSArray* _nativeAppsInSettings; |
BOOL _userDidSomething; |
} |
@@ -62,7 +64,7 @@ typedef NS_ENUM(NSInteger, ItemType) { |
@property(nonatomic, copy) NSArray* appsInSettings; |
// Delegate for App-Store-related operations. |
-@property(nonatomic, assign) id<StoreKitLauncher> storeKitLauncher; |
+@property(nonatomic, weak) id<StoreKitLauncher> storeKitLauncher; |
// Sets up the list of visible apps based on |nativeAppWhitelistManager|, which |
// serves as datasource for this controller. Apps from |
@@ -117,7 +119,6 @@ typedef NS_ENUM(NSInteger, ItemType) { |
[[InstallationNotifier sharedInstance] unregisterForNotifications:self]; |
if (!_userDidSomething) |
[self recordUserAction:settings::kNativeAppsActionDidNothing]; |
- [super dealloc]; |
} |
#pragma mark - View lifecycle |
@@ -213,17 +214,17 @@ typedef NS_ENUM(NSInteger, ItemType) { |
NativeAppItem* appItem = base::mac::ObjCCastStrict<NativeAppItem>(item); |
if (!appItem.icon) { |
// Fetch the real icon. |
- base::WeakNSObject<NativeAppsCollectionViewController> weakSelf(self); |
+ __weak NativeAppsCollectionViewController* weakSelf = self; |
id<NativeAppMetadata> metadata = [self nativeAppAtIndex:indexPath.item]; |
[metadata fetchSmallIconWithImageFetcher:_imageFetcher.get() |
completionBlock:^(UIImage* image) { |
- base::scoped_nsobject< |
- NativeAppsCollectionViewController> |
- strongSelf([weakSelf retain]); |
+ |
+ NativeAppsCollectionViewController* strongSelf = |
+ weakSelf; |
if (!image || !strongSelf) |
return; |
appItem.icon = image; |
- [strongSelf.get().collectionView |
+ [strongSelf.collectionView |
reloadItemsAtIndexPaths:@[ indexPath ]]; |
}]; |
} |
@@ -232,8 +233,8 @@ typedef NS_ENUM(NSInteger, ItemType) { |
- (CollectionViewItem*)learnMoreItem { |
NSString* learnMoreText = |
l10n_util::GetNSString(IDS_IOS_GOOGLE_APPS_SM_SECTION_HEADER); |
- CollectionViewFooterItem* learnMoreItem = [[[CollectionViewFooterItem alloc] |
- initWithType:ItemTypeLearnMore] autorelease]; |
+ CollectionViewFooterItem* learnMoreItem = |
+ [[CollectionViewFooterItem alloc] initWithType:ItemTypeLearnMore]; |
learnMoreItem.text = learnMoreText; |
return learnMoreItem; |
} |
@@ -255,8 +256,8 @@ typedef NS_ENUM(NSInteger, ItemType) { |
return; |
NSDictionary* product = |
@{SKStoreProductParameterITunesItemIdentifier : appId}; |
- base::scoped_nsobject<SKStoreProductViewController> storeViewController( |
- [[SKStoreProductViewController alloc] init]); |
+ SKStoreProductViewController* storeViewController = |
+ [[SKStoreProductViewController alloc] init]; |
[storeViewController setDelegate:self]; |
[storeViewController loadProductWithParameters:product completionBlock:nil]; |
[self presentViewController:storeViewController animated:YES completion:nil]; |
@@ -372,19 +373,18 @@ typedef NS_ENUM(NSInteger, ItemType) { |
} else { |
state = NativeAppItemInstall; |
} |
- NativeAppItem* appItem = |
- [[[NativeAppItem alloc] initWithType:ItemTypeApp] autorelease]; |
+ NativeAppItem* appItem = [[NativeAppItem alloc] initWithType:ItemTypeApp]; |
appItem.name = [metadata appName]; |
appItem.state = state; |
return appItem; |
} |
- (NSArray*)appsInSettings { |
- return _nativeAppsInSettings.get(); |
+ return _nativeAppsInSettings; |
} |
- (void)setAppsInSettings:(NSArray*)apps { |
- _nativeAppsInSettings.reset([apps copy]); |
+ _nativeAppsInSettings = [apps copy]; |
} |
- (NSInteger)tagForIndexPath:(NSIndexPath*)indexPath { |