Index: ios/web/web_state/ui/crw_web_controller_container_view.mm |
diff --git a/ios/web/web_state/ui/crw_web_controller_container_view.mm b/ios/web/web_state/ui/crw_web_controller_container_view.mm |
index 754d9e8b814f4d013b8d1d24e9f24cf48d3314e0..57e797918c247e774e03d2a81fd2a3ac04d0392a 100644 |
--- a/ios/web/web_state/ui/crw_web_controller_container_view.mm |
+++ b/ios/web/web_state/ui/crw_web_controller_container_view.mm |
@@ -4,7 +4,6 @@ |
#import "ios/web/web_state/ui/crw_web_controller_container_view.h" |
-#include "base/ios/weak_nsobject.h" |
#include "base/logging.h" |
#include "base/mac/scoped_nsobject.h" |
#import "ios/web/public/web_state/ui/crw_content_view.h" |
@@ -12,6 +11,10 @@ |
#import "ios/web/public/web_state/ui/crw_web_view_content_view.h" |
#import "ios/web/web_state/crw_web_view_proxy_impl.h" |
+#if !defined(__has_feature) || !__has_feature(objc_arc) |
+#error "This file requires ARC support." |
+#endif |
+ |
#pragma mark - CRWToolbarContainerView |
// Class that manages the display of toolbars. |
@@ -21,7 +24,7 @@ |
} |
// The toolbars currently managed by this view. |
-@property(nonatomic, retain, readonly) NSMutableArray* toolbars; |
+@property(nonatomic, strong, readonly) NSMutableArray* toolbars; |
// Adds |toolbar| as a subview and bottom aligns to any previously added |
// toolbars. |
@@ -90,7 +93,7 @@ |
@interface CRWWebControllerContainerView () { |
// The delegate passed on initialization. |
- base::WeakNSProtocol<id<CRWWebControllerContainerViewDelegate>> _delegate; |
+ __weak id<CRWWebControllerContainerViewDelegate> _delegate; |
// Backing objects for corresponding properties. |
base::scoped_nsobject<CRWWebViewContentView> _webViewContentView; |
base::scoped_nsprotocol<id<CRWNativeContent>> _nativeController; |
@@ -99,18 +102,18 @@ |
} |
// Redefine properties as readwrite. |
-@property(nonatomic, retain, readwrite) |
+@property(nonatomic, strong, readwrite) |
CRWWebViewContentView* webViewContentView; |
-@property(nonatomic, retain, readwrite) id<CRWNativeContent> nativeController; |
-@property(nonatomic, retain, readwrite) CRWContentView* transientContentView; |
+@property(nonatomic, strong, readwrite) id<CRWNativeContent> nativeController; |
+@property(nonatomic, strong, readwrite) CRWContentView* transientContentView; |
// Container view that displays any added toolbars. It is always the top-most |
// subview, and is bottom aligned with the CRWWebControllerContainerView. |
-@property(nonatomic, retain, readonly) |
+@property(nonatomic, strong, readonly) |
CRWToolbarContainerView* toolbarContainerView; |
// Convenience getter for the proxy object. |
-@property(nonatomic, readonly) CRWWebViewProxyImpl* contentViewProxy; |
+@property(weak, nonatomic, readonly) CRWWebViewProxyImpl* contentViewProxy; |
// Returns |self.bounds| after being inset at the top by the header height |
// returned by the delegate. This is only used to lay out native controllers, |
@@ -147,7 +150,6 @@ |
- (void)dealloc { |
self.contentViewProxy.contentView = nil; |
- [super dealloc]; |
} |
#pragma mark Accessors |
@@ -159,7 +161,7 @@ |
- (void)setWebViewContentView:(CRWWebViewContentView*)webViewContentView { |
if (![_webViewContentView isEqual:webViewContentView]) { |
[_webViewContentView removeFromSuperview]; |
- _webViewContentView.reset([webViewContentView retain]); |
+ _webViewContentView.reset(webViewContentView); |
[_webViewContentView setFrame:self.bounds]; |
[self addSubview:_webViewContentView]; |
} |
@@ -171,9 +173,9 @@ |
- (void)setNativeController:(id<CRWNativeContent>)nativeController { |
if (![_nativeController isEqual:nativeController]) { |
- base::WeakNSProtocol<id> oldController(_nativeController); |
+ __weak id oldController = _nativeController; |
[[oldController view] removeFromSuperview]; |
- _nativeController.reset([nativeController retain]); |
+ _nativeController.reset(nativeController); |
// TODO(crbug.com/503297): Re-enable this DCHECK once native controller |
// leaks are fixed. |
// DCHECK(!oldController); |
@@ -187,14 +189,14 @@ |
- (void)setTransientContentView:(CRWContentView*)transientContentView { |
if (![_transientContentView isEqual:transientContentView]) { |
[_transientContentView removeFromSuperview]; |
- _transientContentView.reset([transientContentView retain]); |
+ _transientContentView.reset(transientContentView); |
} |
} |
- (void)setToolbarContainerView:(CRWToolbarContainerView*)toolbarContainerView { |
if (![_toolbarContainerView isEqual:toolbarContainerView]) { |
[_toolbarContainerView removeFromSuperview]; |
- _toolbarContainerView.reset([toolbarContainerView retain]); |
+ _toolbarContainerView.reset(toolbarContainerView); |
} |
} |
@@ -299,13 +301,17 @@ |
self.contentViewProxy.contentView = self.webViewContentView; |
} |
+- (void)setDelegate:(id<CRWWebControllerContainerViewDelegate>)delegate { |
+ _delegate.reset(delegate); |
+} |
+ |
#pragma mark Toolbars |
- (void)addToolbar:(UIView*)toolbar { |
// Create toolbar container if necessary. |
if (!self.toolbarContainerView) { |
- self.toolbarContainerView = [ |
- [[CRWToolbarContainerView alloc] initWithFrame:CGRectZero] autorelease]; |
+ self.toolbarContainerView = |
+ [[CRWToolbarContainerView alloc] initWithFrame:CGRectZero]; |
} |
// Add the toolbar to the container. |
[self.toolbarContainerView addToolbar:toolbar]; |