Chromium Code Reviews| Index: ios/web/navigation/crw_session_controller.mm |
| diff --git a/ios/web/navigation/crw_session_controller.mm b/ios/web/navigation/crw_session_controller.mm |
| index 85938fc01aff0d57368e09a92d71d18613ace9aa..a692a3f193bfc79a27e435826eeaa291b7c1c935 100644 |
| --- a/ios/web/navigation/crw_session_controller.mm |
| +++ b/ios/web/navigation/crw_session_controller.mm |
| @@ -12,7 +12,7 @@ |
| #include "base/format_macros.h" |
| #include "base/logging.h" |
| -#include "base/mac/objc_property_releaser.h" |
| +#import "base/mac/foundation_util.h" |
| #import "base/mac/scoped_nsobject.h" |
| #include "base/metrics/user_metrics.h" |
| #include "base/metrics/user_metrics_action.h" |
| @@ -102,8 +102,6 @@ NSString* const kXCallbackParametersKey = @"xCallbackParameters"; |
| // XCallback parameters used to create (or clobber) the tab. Can be nil. |
| XCallbackParameters* _xCallbackParameters; |
| - |
| - base::mac::ObjCPropertyReleaser _propertyReleaser_CRWSessionController; |
| } |
| // Redefine as readwrite. |
| @@ -111,9 +109,9 @@ NSString* const kXCallbackParametersKey = @"xCallbackParameters"; |
| // TODO(rohitrao): These properties must be redefined readwrite to work around a |
| // clang bug. crbug.com/228650 |
| -@property(nonatomic, readwrite, retain) NSString* tabId; |
| -@property(nonatomic, readwrite, retain) NSArray* entries; |
| -@property(nonatomic, readwrite, retain) |
| +@property(nonatomic, readwrite, copy) NSString* tabId; |
| +@property(nonatomic, readwrite, strong) NSArray* entries; |
| +@property(nonatomic, readwrite, strong) |
| CRWSessionCertificatePolicyManager* sessionCertificatePolicyManager; |
| - (NSString*)uniqueID; |
| @@ -153,15 +151,13 @@ NSString* const kXCallbackParametersKey = @"xCallbackParameters"; |
| browserState:(web::BrowserState*)browserState { |
| self = [super init]; |
| if (self) { |
| - _propertyReleaser_CRWSessionController.Init(self, |
| - [CRWSessionController class]); |
| self.windowName = windowName; |
| - _tabId = [[self uniqueID] retain]; |
| + _tabId = [[self uniqueID] copy]; |
| _openerId = [openerId copy]; |
| _openedByDOM = openedByDOM; |
| _openerNavigationIndex = openerIndex; |
| _browserState = browserState; |
| - _entries = [[NSMutableArray array] retain]; |
| + _entries = [NSMutableArray array]; |
| _lastVisitedTimestamp = [[NSDate date] timeIntervalSince1970]; |
| _currentNavigationIndex = -1; |
| _previousNavigationIndex = -1; |
| @@ -176,9 +172,7 @@ NSString* const kXCallbackParametersKey = @"xCallbackParameters"; |
| browserState:(web::BrowserState*)browserState { |
| self = [super init]; |
| if (self) { |
| - _propertyReleaser_CRWSessionController.Init(self, |
| - [CRWSessionController class]); |
| - _tabId = [[self uniqueID] retain]; |
| + _tabId = [[self uniqueID] copy]; |
| _openerId = nil; |
| _browserState = browserState; |
| @@ -211,14 +205,12 @@ NSString* const kXCallbackParametersKey = @"xCallbackParameters"; |
| - (id)initWithCoder:(NSCoder*)aDecoder { |
| self = [super init]; |
| if (self) { |
| - _propertyReleaser_CRWSessionController.Init(self, |
| - [CRWSessionController class]); |
| NSString* uuid = [aDecoder decodeObjectForKey:kTabIdKey]; |
| if (!uuid) |
| uuid = [self uniqueID]; |
| self.windowName = [aDecoder decodeObjectForKey:kWindowNameKey]; |
| - _tabId = [uuid retain]; |
| + _tabId = [uuid copy]; |
| _openerId = [[aDecoder decodeObjectForKey:kOpenerIdKey] copy]; |
| _openedByDOM = [aDecoder decodeBoolForKey:kOpenedByDOMKey]; |
| _openerNavigationIndex = |
| @@ -232,19 +224,19 @@ NSString* const kXCallbackParametersKey = @"xCallbackParameters"; |
| NSMutableArray* temp = |
| [NSMutableArray arrayWithArray: |
| [aDecoder decodeObjectForKey:kEntriesKey]]; |
| - _entries = [temp retain]; |
| + _entries = temp; |
| // Prior to M34, 0 was used as "no index" instead of -1; adjust for that. |
| if (![_entries count]) |
| _currentNavigationIndex = -1; |
| _sessionCertificatePolicyManager = |
| - [[aDecoder decodeObjectForKey:kCertificatePolicyManagerKey] retain]; |
| + [aDecoder decodeObjectForKey:kCertificatePolicyManagerKey]; |
| if (!_sessionCertificatePolicyManager) { |
| _sessionCertificatePolicyManager = |
| [[CRWSessionCertificatePolicyManager alloc] init]; |
| } |
| _xCallbackParameters = |
| - [[aDecoder decodeObjectForKey:kXCallbackParametersKey] retain]; |
| + [aDecoder decodeObjectForKey:kXCallbackParametersKey]; |
| } |
| return self; |
| } |
| @@ -268,8 +260,6 @@ NSString* const kXCallbackParametersKey = @"xCallbackParameters"; |
| - (id)copyWithZone:(NSZone*)zone { |
| CRWSessionController* copy = [[[self class] alloc] init]; |
| - copy->_propertyReleaser_CRWSessionController.Init( |
| - copy, [CRWSessionController class]); |
| copy->_tabId = [_tabId copy]; |
| copy->_openerId = [_openerId copy]; |
| copy->_openedByDOM = _openedByDOM; |
| @@ -282,7 +272,8 @@ NSString* const kXCallbackParametersKey = @"xCallbackParameters"; |
| [[NSMutableArray alloc] initWithArray:_entries copyItems:YES]; |
| copy->_sessionCertificatePolicyManager = |
| [_sessionCertificatePolicyManager copy]; |
| - copy->_xCallbackParameters = [_xCallbackParameters copy]; |
| + copy->_xCallbackParameters = [base::mac::ObjCCastStrict<NSObject<NSCopying>>( |
| + _xCallbackParameters) copy]; |
| return copy; |
| } |
| @@ -401,11 +392,11 @@ NSString* const kXCallbackParametersKey = @"xCallbackParameters"; |
| (self.currentEntry.navigationItem && |
| self.currentEntry.navigationItem->IsOverridingUserAgent()); |
| _useDesktopUserAgentForNextPendingEntry = NO; |
| - _pendingEntry.reset([[self sessionEntryWithURL:url |
| - referrer:ref |
| - transition:trans |
| - useDesktopUserAgent:useDesktopUserAgent |
| - rendererInitiated:rendererInitiated] retain]); |
| + _pendingEntry.reset([self sessionEntryWithURL:url |
| + referrer:ref |
| + transition:trans |
| + useDesktopUserAgent:useDesktopUserAgent |
| + rendererInitiated:rendererInitiated]); |
| if (_navigationManager && _navigationManager->GetFacadeDelegate()) { |
| _navigationManager->GetFacadeDelegate()->OnNavigationItemPending(); |
| @@ -454,7 +445,7 @@ NSString* const kXCallbackParametersKey = @"xCallbackParameters"; |
| // Store removed items in temporary NSArray so they can be deallocated after |
| // their facades. |
| base::scoped_nsobject<NSArray> removedItems( |
| - [[_entries subarrayWithRange:remove] retain]); |
| + [_entries subarrayWithRange:remove]); |
| [_entries removeObjectsInRange:remove]; |
| if (_previousNavigationIndex >= forwardEntryStartIndex) |
| _previousNavigationIndex = -1; |
| @@ -487,12 +478,12 @@ NSString* const kXCallbackParametersKey = @"xCallbackParameters"; |
| } |
| - (void)addTransientEntryWithURL:(const GURL&)URL { |
| - _transientEntry.reset( |
| - [[self sessionEntryWithURL:URL |
| - referrer:web::Referrer() |
| - transition:ui::PAGE_TRANSITION_CLIENT_REDIRECT |
| - useDesktopUserAgent:NO |
| - rendererInitiated:NO] retain]); |
| + _transientEntry.reset([self |
| + sessionEntryWithURL:URL |
| + referrer:web::Referrer() |
| + transition:ui::PAGE_TRANSITION_CLIENT_REDIRECT |
| + useDesktopUserAgent:NO |
| + rendererInitiated:NO]); |
| web::NavigationItem* navigationItem = [_transientEntry navigationItem]; |
| DCHECK(navigationItem); |
| @@ -510,12 +501,12 @@ NSString* const kXCallbackParametersKey = @"xCallbackParameters"; |
| web::Referrer referrer(item->GetURL(), web::ReferrerPolicyDefault); |
| bool overrideUserAgent = |
| self.currentEntry.navigationItem->IsOverridingUserAgent(); |
| - base::scoped_nsobject<CRWSessionEntry> pushedEntry( |
| - [[self sessionEntryWithURL:URL |
| - referrer:referrer |
| - transition:transition |
| - useDesktopUserAgent:overrideUserAgent |
| - rendererInitiated:NO] retain]); |
| + base::scoped_nsobject<CRWSessionEntry> pushedEntry([self |
| + sessionEntryWithURL:URL |
| + referrer:referrer |
| + transition:transition |
| + useDesktopUserAgent:overrideUserAgent |
| + rendererInitiated:NO]); |
| web::NavigationItemImpl* pushedItem = [pushedEntry navigationItemImpl]; |
| pushedItem->SetSerializedStateObject(stateObject); |
| pushedItem->SetIsCreatedFromPushState(true); |
| @@ -556,7 +547,6 @@ NSString* const kXCallbackParametersKey = @"xCallbackParameters"; |
| // entry; since navigations clear the transient entry, these flows might |
| // crash. (This should be removable once more session management is handled |
| // within this class and/or NavigationManager). |
| - [[_transientEntry retain] autorelease]; |
| _transientEntry.reset(); |
| } |
| @@ -572,8 +562,8 @@ NSString* const kXCallbackParametersKey = @"xCallbackParameters"; |
| self.currentNavigationIndex = -1; |
| _previousNavigationIndex = -1; |
| } |
| - self.xCallbackParameters = |
| - [[otherSession.xCallbackParameters copy] autorelease]; |
| + self.xCallbackParameters = [base::mac::ObjCCastStrict<NSObject<NSCopying>>( |
| + otherSession.xCallbackParameters) copy]; |
| self.windowName = otherSession.windowName; |
| NSInteger numInitialEntries = [_entries count]; |
| @@ -850,7 +840,8 @@ NSString* const kXCallbackParametersKey = @"xCallbackParameters"; |
| CFUUIDRef uuidRef = CFUUIDCreate(NULL); |
| CFStringRef uuidStringRef = CFUUIDCreateString(NULL, uuidRef); |
| CFRelease(uuidRef); |
| - NSString* uuid = [NSString stringWithString:(NSString*)uuidStringRef]; |
| + NSString* uuid = |
| + [NSString stringWithString:(__bridge NSString*)uuidStringRef]; |
|
Eugene But (OOO till 7-30)
2016/08/01 21:13:48
Optional NIT: since you touching this could you pl
stkhapugin
2016/08/18 17:09:36
Done.
|
| CFRelease(uuidStringRef); |
| return uuid; |
| } |
| @@ -880,8 +871,7 @@ NSString* const kXCallbackParametersKey = @"xCallbackParameters"; |
| item->SetTransitionType(transition); |
| item->SetIsOverridingUserAgent(useDesktopUserAgent); |
| item->set_is_renderer_initiated(rendererInitiated); |
| - return [[[CRWSessionEntry alloc] initWithNavigationItem:std::move(item)] |
| - autorelease]; |
| + return [[CRWSessionEntry alloc] initWithNavigationItem:std::move(item)]; |
| } |
| @end |