[ObjC ARC] Converts ios/chrome/browser/ui/side_swipe:side_swipe to ARC.

Automatically generated ARCMigrate commit
Notable issues:None
BUG=624363
TEST=None

Review-Url: https://codereview.chromium.org/2827643002
Cr-Commit-Position: refs/heads/master@{#465577}
diff --git a/ios/chrome/browser/ui/side_swipe/BUILD.gn b/ios/chrome/browser/ui/side_swipe/BUILD.gn
index ce315af..eb8e097 100644
--- a/ios/chrome/browser/ui/side_swipe/BUILD.gn
+++ b/ios/chrome/browser/ui/side_swipe/BUILD.gn
@@ -17,6 +17,7 @@
 }
 
 source_set("side_swipe") {
+  configs += [ "//build/config/compiler:enable_arc" ]
   sources = [
     "card_side_swipe_view.h",
     "card_side_swipe_view.mm",
diff --git a/ios/chrome/browser/ui/side_swipe/card_side_swipe_view.h b/ios/chrome/browser/ui/side_swipe/card_side_swipe_view.h
index 6b068749..8b9714bf 100644
--- a/ios/chrome/browser/ui/side_swipe/card_side_swipe_view.h
+++ b/ios/chrome/browser/ui/side_swipe/card_side_swipe_view.h
@@ -42,7 +42,7 @@
   base::scoped_nsobject<UIImageView> backgroundView_;
 }
 
-@property(nonatomic, assign) id<SideSwipeControllerDelegate> delegate;
+@property(nonatomic, weak) id<SideSwipeControllerDelegate> delegate;
 @property(nonatomic, assign) CGFloat topMargin;
 
 - (id)initWithFrame:(CGRect)frame
diff --git a/ios/chrome/browser/ui/side_swipe/card_side_swipe_view.mm b/ios/chrome/browser/ui/side_swipe/card_side_swipe_view.mm
index ddfdaf9..8bff8e2 100644
--- a/ios/chrome/browser/ui/side_swipe/card_side_swipe_view.mm
+++ b/ios/chrome/browser/ui/side_swipe/card_side_swipe_view.mm
@@ -25,6 +25,10 @@
 #import "ios/web/web_state/ui/crw_web_controller.h"
 #include "url/gurl.h"
 
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
 using base::UserMetricsAction;
 
 namespace {
@@ -144,8 +148,7 @@
     currentPoint_ = CGPointZero;
     topMargin_ = topMargin;
 
-    base::scoped_nsobject<UIView> background(
-        [[UIView alloc] initWithFrame:CGRectZero]);
+    UIView* background = [[UIView alloc] initWithFrame:CGRectZero];
     [self addSubview:background];
 
     [background setTranslatesAutoresizingMaskIntoConstraints:NO];
diff --git a/ios/chrome/browser/ui/side_swipe/history_side_swipe_provider.mm b/ios/chrome/browser/ui/side_swipe/history_side_swipe_provider.mm
index d23979a6..a86e19f 100644
--- a/ios/chrome/browser/ui/side_swipe/history_side_swipe_provider.mm
+++ b/ios/chrome/browser/ui/side_swipe/history_side_swipe_provider.mm
@@ -4,9 +4,15 @@
 
 #import "ios/chrome/browser/ui/side_swipe/history_side_swipe_provider.h"
 
+#include "ios/chrome/browser/tabs/tab.h"
+
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
 @interface HistorySideSwipeProvider () {
   // Keep a reference to detach before deallocing.
-  TabModel* _tabModel;  // weak
+  __weak TabModel* _tabModel;  // weak
 }
 
 @end
diff --git a/ios/chrome/browser/ui/side_swipe/side_swipe_controller.h b/ios/chrome/browser/ui/side_swipe/side_swipe_controller.h
index 81f4fdf..0a13aae 100644
--- a/ios/chrome/browser/ui/side_swipe/side_swipe_controller.h
+++ b/ios/chrome/browser/ui/side_swipe/side_swipe_controller.h
@@ -78,8 +78,8 @@
     : NSObject<CRWSwipeRecognizerProvider, UIGestureRecognizerDelegate>
 
 @property(nonatomic, assign) BOOL inSwipe;
-@property(nonatomic, assign) id<SideSwipeControllerDelegate> swipeDelegate;
-@property(nonatomic, assign) id<TabSnapshottingDelegate> snapshotDelegate;
+@property(nonatomic, weak) id<SideSwipeControllerDelegate> swipeDelegate;
+@property(nonatomic, weak) id<TabSnapshottingDelegate> snapshotDelegate;
 
 // Initializer.
 - (id)initWithTabModel:(TabModel*)model
diff --git a/ios/chrome/browser/ui/side_swipe/side_swipe_controller.mm b/ios/chrome/browser/ui/side_swipe/side_swipe_controller.mm
index b95f771..fd0ad6f 100644
--- a/ios/chrome/browser/ui/side_swipe/side_swipe_controller.mm
+++ b/ios/chrome/browser/ui/side_swipe/side_swipe_controller.mm
@@ -6,7 +6,6 @@
 
 #include <memory>
 
-#import "base/ios/weak_nsobject.h"
 #include "components/reading_list/core/reading_list_model.h"
 #import "ios/chrome/browser/browser_state/chrome_browser_state.h"
 #import "ios/chrome/browser/infobars/infobar_container_view.h"
@@ -24,6 +23,10 @@
 #import "ios/web/public/web_state/web_state_observer_bridge.h"
 #import "ios/web/web_state/ui/crw_web_controller.h"
 
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
 namespace ios_internal {
 NSString* const kSideSwipeWillStartNotification =
     @"kSideSwipeWillStartNotification";
@@ -50,21 +53,21 @@
                                   UIGestureRecognizerDelegate> {
  @private
 
-  base::WeakNSObject<TabModel> model_;
+  __weak TabModel* model_;
 
   // Side swipe view for tab navigation.
-  base::scoped_nsobject<CardSideSwipeView> tabSideSwipeView_;
+  CardSideSwipeView* tabSideSwipeView_;
 
   // Side swipe view for page navigation.
-  base::scoped_nsobject<SideSwipeNavigationView> pageSideSwipeView_;
+  SideSwipeNavigationView* pageSideSwipeView_;
 
   // YES if the user is currently swiping.
   BOOL inSwipe_;
 
   // Swipe gesture recognizer.
-  base::scoped_nsobject<SideSwipeGestureRecognizer> swipeGestureRecognizer_;
+  SideSwipeGestureRecognizer* swipeGestureRecognizer_;
 
-  base::scoped_nsobject<SideSwipeGestureRecognizer> panGestureRecognizer_;
+  SideSwipeGestureRecognizer* panGestureRecognizer_;
 
   // Used in iPad side swipe gesture, tracks the starting tab index.
   NSUInteger startingTabIndex_;
@@ -76,16 +79,15 @@
   std::unique_ptr<web::WebStateObserverBridge> webStateObserverBridge_;
 
   // Curtain over web view while waiting for it to load.
-  base::scoped_nsobject<UIView> curtain_;
+  UIView* curtain_;
 
   // Provides forward/back action for history entries.
-  base::scoped_nsobject<HistorySideSwipeProvider> historySideSwipeProvider_;
+  HistorySideSwipeProvider* historySideSwipeProvider_;
 
   // Provides forward action for reading list.
-  base::scoped_nsobject<ReadingListSideSwipeProvider>
-      readingListSideSwipeProvider_;
+  ReadingListSideSwipeProvider* readingListSideSwipeProvider_;
 
-  base::WeakNSProtocol<id<SideSwipeContentProvider>> currentContentProvider_;
+  __weak id<SideSwipeContentProvider> currentContentProvider_;
 }
 
 // Load grey snapshots for the next |kIpadGreySwipeTabCount| tabs in
@@ -117,27 +119,26 @@
   DCHECK(model);
   self = [super init];
   if (self) {
-    model_.reset(model);
+    model_ = model;
     [model_ addObserver:self];
-    historySideSwipeProvider_.reset(
-        [[HistorySideSwipeProvider alloc] initWithTabModel:model_]);
+    historySideSwipeProvider_ =
+        [[HistorySideSwipeProvider alloc] initWithTabModel:model_];
 
-    readingListSideSwipeProvider_.reset([[ReadingListSideSwipeProvider alloc]
+    readingListSideSwipeProvider_ = [[ReadingListSideSwipeProvider alloc]
         initWithReadingList:ReadingListModelFactory::GetForBrowserState(
-                                browserState)]);
+                                browserState)];
   }
   return self;
 }
 
 - (void)dealloc {
   [model_ removeObserver:self];
-  [super dealloc];
 }
 
 - (void)addHorizontalGesturesToView:(UIView*)view {
-  swipeGestureRecognizer_.reset([[SideSwipeGestureRecognizer alloc]
+  swipeGestureRecognizer_ = [[SideSwipeGestureRecognizer alloc]
       initWithTarget:self
-              action:@selector(handleSwipe:)]);
+              action:@selector(handleSwipe:)];
   [swipeGestureRecognizer_ setMaximumNumberOfTouches:1];
   [swipeGestureRecognizer_ setDelegate:self];
   [swipeGestureRecognizer_ setSwipeEdge:kSwipeEdge];
@@ -145,9 +146,9 @@
 
   // Add a second gesture recognizer to handle swiping on the toolbar to change
   // tabs.
-  panGestureRecognizer_.reset([[SideSwipeGestureRecognizer alloc]
-      initWithTarget:self
-              action:@selector(handlePan:)]);
+  panGestureRecognizer_ =
+      [[SideSwipeGestureRecognizer alloc] initWithTarget:self
+                                                  action:@selector(handlePan:)];
   [panGestureRecognizer_ setMaximumNumberOfTouches:1];
   [panGestureRecognizer_ setSwipeThreshold:48];
   [panGestureRecognizer_ setDelegate:self];
@@ -155,7 +156,7 @@
 }
 
 - (NSSet*)swipeRecognizers {
-  return [NSSet setWithObjects:swipeGestureRecognizer_.get(), nil];
+  return [NSSet setWithObjects:swipeGestureRecognizer_, nil];
 }
 
 - (void)setEnabled:(BOOL)enabled {
@@ -252,14 +253,14 @@
     index = index + dx;
   }
   [[SnapshotCache sharedInstance] createGreyCache:sessionIDs];
-  for (Tab* tab in model_.get()) {
+  for (Tab* tab in model_) {
     tab.useGreyImageCache = YES;
   }
 }
 
 - (void)deleteGreyCache {
   [[SnapshotCache sharedInstance] removeGreyCache];
-  for (Tab* tab in model_.get()) {
+  for (Tab* tab in model_) {
     tab.useGreyImageCache = NO;
   }
 }
@@ -385,7 +386,7 @@
     [swipeDelegate_ updateAccessoryViewsForSideSwipeWithVisibility:NO];
     BOOL goBack = IsSwipingBack(gesture.direction);
 
-    currentContentProvider_.reset([self contentProviderForGesture:goBack]);
+    currentContentProvider_ = [self contentProviderForGesture:goBack];
     BOOL canNavigate = currentContentProvider_ != nil;
 
     CGRect gestureBounds = gesture.view.bounds;
@@ -396,19 +397,19 @@
                    CGRectGetWidth(gestureBounds),
                    CGRectGetHeight(gestureBounds) - headerHeight);
 
-    pageSideSwipeView_.reset([[SideSwipeNavigationView alloc]
+    pageSideSwipeView_ = [[SideSwipeNavigationView alloc]
         initWithFrame:navigationFrame
         withDirection:gesture.direction
           canNavigate:canNavigate
                 image:[currentContentProvider_ paneIcon]
-        rotateForward:[currentContentProvider_ rotateForwardIcon]]);
+        rotateForward:[currentContentProvider_ rotateForwardIcon]];
     [pageSideSwipeView_ setTargetView:[swipeDelegate_ contentView]];
 
     [gesture.view insertSubview:pageSideSwipeView_
                    belowSubview:[[swipeDelegate_ toolbarController] view]];
   }
 
-  base::WeakNSObject<Tab> weakCurrentTab([model_ currentTab]);
+  __weak Tab* weakCurrentTab = [model_ currentTab];
   [pageSideSwipeView_ handleHorizontalPan:gesture
       onOverThresholdCompletion:^{
         BOOL wantsBack = IsSwipingBack(gesture.direction);
@@ -454,10 +455,9 @@
       [tabSideSwipeView_ setFrame:frame];
       [tabSideSwipeView_ setTopMargin:headerHeight];
     } else {
-      tabSideSwipeView_.reset([[CardSideSwipeView alloc]
-          initWithFrame:frame
-              topMargin:headerHeight
-                  model:model_]);
+      tabSideSwipeView_ = [[CardSideSwipeView alloc] initWithFrame:frame
+                                                         topMargin:headerHeight
+                                                             model:model_];
       [tabSideSwipeView_ setAutoresizingMask:UIViewAutoresizingFlexibleWidth |
                                              UIViewAutoresizingFlexibleHeight];
       [tabSideSwipeView_ setDelegate:swipeDelegate_];
@@ -490,8 +490,8 @@
 
 - (void)addCurtainWithCompletionHandler:(ProceduralBlock)completionHandler {
   if (!curtain_) {
-    curtain_.reset(
-        [[UIView alloc] initWithFrame:[swipeDelegate_ contentView].bounds]);
+    curtain_ =
+        [[UIView alloc] initWithFrame:[swipeDelegate_ contentView].bounds];
     [curtain_ setBackgroundColor:[UIColor whiteColor]];
   }
   [[swipeDelegate_ contentView] addSubview:curtain_];
@@ -500,7 +500,7 @@
   // long it can take a web view to clear the previous page image, and what
   // feels like to 'too long' to see the curtain.
   [self performSelector:@selector(dismissCurtainWithCompletionHandler:)
-             withObject:[[completionHandler copy] autorelease]
+             withObject:[completionHandler copy]
              afterDelay:3];
 }
 
@@ -514,7 +514,7 @@
   [NSObject cancelPreviousPerformRequestsWithTarget:self];
   webStateObserverBridge_.reset();
   [curtain_ removeFromSuperview];
-  curtain_.reset();
+  curtain_ = nil;
   completionHandler();
 }
 
diff --git a/ios/chrome/browser/ui/side_swipe/side_swipe_navigation_view.h b/ios/chrome/browser/ui/side_swipe/side_swipe_navigation_view.h
index b18f2a3..c8a4e2b 100644
--- a/ios/chrome/browser/ui/side_swipe/side_swipe_navigation_view.h
+++ b/ios/chrome/browser/ui/side_swipe/side_swipe_navigation_view.h
@@ -13,7 +13,7 @@
 // is dragged from side to side.
 @interface SideSwipeNavigationView : UIView
 
-@property(nonatomic, assign) UIView* targetView;
+@property(nonatomic, weak) UIView* targetView;
 
 // Initialize with direction.
 - (instancetype)initWithFrame:(CGRect)frame
diff --git a/ios/chrome/browser/ui/side_swipe/side_swipe_navigation_view.mm b/ios/chrome/browser/ui/side_swipe/side_swipe_navigation_view.mm
index ca4fa6d2..83beea7e 100644
--- a/ios/chrome/browser/ui/side_swipe/side_swipe_navigation_view.mm
+++ b/ios/chrome/browser/ui/side_swipe/side_swipe_navigation_view.mm
@@ -7,8 +7,7 @@
 #include <cmath>
 
 #include "base/logging.h"
-#include "base/mac/objc_property_releaser.h"
-#include "base/mac/scoped_nsobject.h"
+
 #include "base/metrics/user_metrics.h"
 #include "base/metrics/user_metrics_action.h"
 #import "ios/chrome/browser/ui/side_swipe/side_swipe_util.h"
@@ -17,6 +16,10 @@
 #import "ios/chrome/browser/ui/uikit_ui_util.h"
 #import "ios/chrome/common/material_timing.h"
 
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
 namespace {
 
 enum class SwipeType { CHANGE_TABS, NAVIGATION };
@@ -71,7 +74,7 @@
   BOOL thresholdTriggered_;
 
   // The back or forward sprite image.
-  base::scoped_nsobject<UIImageView> arrowView_;
+  UIImageView* arrowView_;
 
   // The selection bubble.
   CAShapeLayer* selectionCircleLayer_;
@@ -83,8 +86,6 @@
   // If |YES| arrowView_ is directionnal and must be rotated 180 degreed for the
   // forward panes.
   BOOL rotateForward_;
-
-  base::mac::ObjCPropertyReleaser _propertyReleaser_SideSwipeNavigationView;
 }
 // Returns a newly allocated and configured selection circle shape.
 - (CAShapeLayer*)newSelectionCircleLayer;
@@ -104,8 +105,6 @@
                 rotateForward:(BOOL)rotateForward {
   self = [super initWithFrame:frame];
   if (self) {
-    _propertyReleaser_SideSwipeNavigationView.Init(
-        self, [SideSwipeNavigationView class]);
     self.backgroundColor = [UIColor colorWithWhite:90.0 / 256 alpha:1.0];
 
     canNavigate_ = canNavigate;
@@ -113,7 +112,7 @@
     if (canNavigate) {
       image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
       const CGRect imageSize = CGRectMake(0, 0, 24, 24);
-      arrowView_.reset([[UIImageView alloc] initWithImage:image]);
+      arrowView_ = [[UIImageView alloc] initWithImage:image];
       [arrowView_ setTintColor:[UIColor whiteColor]];
       selectionCircleLayer_ = [self newSelectionCircleLayer];
       [arrowView_ setFrame:imageSize];
@@ -123,8 +122,7 @@
         [UIImage imageNamed:@"side_swipe_navigation_content_shadow"];
     CGRect borderFrame =
         CGRectMake(0, 0, shadowImage.size.width, self.frame.size.height);
-    base::scoped_nsobject<UIImageView> border(
-        [[UIImageView alloc] initWithFrame:borderFrame]);
+    UIImageView* border = [[UIImageView alloc] initWithFrame:borderFrame];
     [border setImage:shadowImage];
     [self addSubview:border];
     if (direction == UISwipeGestureRecognizerDirectionRight) {
diff --git a/ios/chrome/browser/ui/side_swipe/side_swipe_util.mm b/ios/chrome/browser/ui/side_swipe/side_swipe_util.mm
index f8a2a0d..7a8455e3 100644
--- a/ios/chrome/browser/ui/side_swipe/side_swipe_util.mm
+++ b/ios/chrome/browser/ui/side_swipe/side_swipe_util.mm
@@ -8,6 +8,10 @@
 
 #include "ios/chrome/browser/ui/rtl_geometry.h"
 
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
 BOOL IsSwipingBack(UISwipeGestureRecognizerDirection direction) {
   if (UseRTLLayout())
     return direction == UISwipeGestureRecognizerDirectionLeft;