Commit c1be1791 authored by stkhapugin's avatar stkhapugin Committed by Commit bot

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

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

Review-Url: https://codereview.chromium.org/2566993002
Cr-Commit-Position: refs/heads/master@{#438164}
parent fe3ca5de
...@@ -22,6 +22,7 @@ declare_args() { ...@@ -22,6 +22,7 @@ declare_args() {
} }
source_set("browser") { source_set("browser") {
configs += [ "//build/config/compiler:enable_arc" ]
sources = [ sources = [
"about_flags.h", "about_flags.h",
"about_flags.mm", "about_flags.mm",
......
...@@ -38,6 +38,10 @@ ...@@ -38,6 +38,10 @@
#if !defined(OFFICIAL_BUILD) #if !defined(OFFICIAL_BUILD)
#include "components/variations/variations_switches.h" #include "components/variations/variations_switches.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
#endif #endif
namespace { namespace {
......
...@@ -19,7 +19,7 @@ class GURL; ...@@ -19,7 +19,7 @@ class GURL;
// Parameters representing an x-callback-url request from another app. // Parameters representing an x-callback-url request from another app.
// Can be nil. // Can be nil.
@property(nonatomic, readonly, retain) XCallbackParameters* xCallbackParameters; @property(nonatomic, readonly, strong) XCallbackParameters* xCallbackParameters;
// Boolean to track if a voice search is requested at startup. // Boolean to track if a voice search is requested at startup.
@property(nonatomic, readwrite, assign) BOOL launchVoiceSearch; @property(nonatomic, readwrite, assign) BOOL launchVoiceSearch;
......
...@@ -5,14 +5,16 @@ ...@@ -5,14 +5,16 @@
#import "ios/chrome/browser/app_startup_parameters.h" #import "ios/chrome/browser/app_startup_parameters.h"
#include "base/logging.h" #include "base/logging.h"
#import "base/mac/scoped_nsobject.h"
#include "ios/chrome/browser/experimental_flags.h" #include "ios/chrome/browser/experimental_flags.h"
#import "ios/chrome/browser/xcallback_parameters.h" #import "ios/chrome/browser/xcallback_parameters.h"
#include "url/gurl.h" #include "url/gurl.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@implementation AppStartupParameters { @implementation AppStartupParameters {
GURL _externalURL; GURL _externalURL;
base::scoped_nsobject<XCallbackParameters> _xCallbackParameters;
BOOL _launchVoiceSearch; BOOL _launchVoiceSearch;
BOOL _launchInIncognito; BOOL _launchInIncognito;
BOOL _launchQRScanner; BOOL _launchQRScanner;
...@@ -20,14 +22,12 @@ ...@@ -20,14 +22,12 @@
@synthesize launchVoiceSearch = _launchVoiceSearch; @synthesize launchVoiceSearch = _launchVoiceSearch;
@synthesize launchInIncognito = _launchInIncognito; @synthesize launchInIncognito = _launchInIncognito;
@synthesize xCallbackParameters = _xCallbackParameters;
- (const GURL&)externalURL { - (const GURL&)externalURL {
return _externalURL; return _externalURL;
} }
- (XCallbackParameters*)xCallbackParameters {
return _xCallbackParameters.get();
}
- (instancetype)init { - (instancetype)init {
NOTREACHED(); NOTREACHED();
...@@ -42,8 +42,8 @@ ...@@ -42,8 +42,8 @@
xCallbackParameters:(XCallbackParameters*)xCallbackParameters { xCallbackParameters:(XCallbackParameters*)xCallbackParameters {
self = [super init]; self = [super init];
if (self) { if (self) {
_externalURL = GURL(externalURL); _externalURL = externalURL;
_xCallbackParameters.reset([xCallbackParameters retain]); _xCallbackParameters = xCallbackParameters;
} }
return self; return self;
} }
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
- (NSString*)description { - (NSString*)description {
return [NSString stringWithFormat:@"ExternalURL: %s \nXCallbackParams: %@", return [NSString stringWithFormat:@"ExternalURL: %s \nXCallbackParams: %@",
_externalURL.spec().c_str(), _externalURL.spec().c_str(),
_xCallbackParameters.get()]; _xCallbackParameters];
} }
#pragma mark Property implementation. #pragma mark Property implementation.
......
...@@ -21,16 +21,17 @@ typedef NSMutableArray<ChromeCoordinator*> MutableCoordinatorArray; ...@@ -21,16 +21,17 @@ typedef NSMutableArray<ChromeCoordinator*> MutableCoordinatorArray;
- (nullable instancetype)init NS_UNAVAILABLE; - (nullable instancetype)init NS_UNAVAILABLE;
// Child coordinators created by this object. // Child coordinators created by this object.
@property(nonatomic, nonnull, readonly) @property(strong, nonatomic, nonnull, readonly)
MutableCoordinatorArray* childCoordinators; MutableCoordinatorArray* childCoordinators;
// The currently 'active' child coordinator, if any. By default this is the last // The currently 'active' child coordinator, if any. By default this is the last
// coordinator in |childCoordinators|, but subclasses need not adhere to that. // coordinator in |childCoordinators|, but subclasses need not adhere to that.
@property(nonatomic, nullable, readonly) @property(strong, nonatomic, nullable, readonly)
ChromeCoordinator* activeChildCoordinator; ChromeCoordinator* activeChildCoordinator;
// The view controller this coordinator was initialized with. // The view controller this coordinator was initialized with.
@property(nonatomic, nullable, readonly) UIViewController* baseViewController; @property(weak, nonatomic, nullable, readonly)
UIViewController* baseViewController;
// The basic lifecycle methods for coordinators are -start and -stop. These // The basic lifecycle methods for coordinators are -start and -stop. These
// are blank template methods; child classes are expected to implement them and // are blank template methods; child classes are expected to implement them and
......
...@@ -4,13 +4,15 @@ ...@@ -4,13 +4,15 @@
#import "ios/chrome/browser/chrome_coordinator.h" #import "ios/chrome/browser/chrome_coordinator.h"
#include "base/ios/weak_nsobject.h"
#include "base/logging.h" #include "base/logging.h"
#import "base/mac/scoped_nsobject.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@interface ChromeCoordinator () { @interface ChromeCoordinator () {
base::WeakNSObject<UIViewController> _baseViewController; __weak UIViewController* _baseViewController;
base::scoped_nsobject<MutableCoordinatorArray> _childCoordinators; MutableCoordinatorArray* _childCoordinators;
} }
@end @end
...@@ -19,8 +21,8 @@ ...@@ -19,8 +21,8 @@
- (nullable instancetype)initWithBaseViewController: - (nullable instancetype)initWithBaseViewController:
(UIViewController*)viewController { (UIViewController*)viewController {
if (self = [super init]) { if (self = [super init]) {
_baseViewController.reset(viewController); _baseViewController = viewController;
_childCoordinators.reset([[MutableCoordinatorArray array] retain]); _childCoordinators = [MutableCoordinatorArray array];
} }
return self; return self;
} }
...@@ -32,7 +34,6 @@ ...@@ -32,7 +34,6 @@
- (void)dealloc { - (void)dealloc {
[self stop]; [self stop];
[super dealloc];
} }
- (MutableCoordinatorArray*)childCoordinators { - (MutableCoordinatorArray*)childCoordinators {
......
...@@ -13,6 +13,10 @@ ...@@ -13,6 +13,10 @@
#include "components/gcm_driver/gcm_driver_constants.h" #include "components/gcm_driver/gcm_driver_constants.h"
#include "ios/chrome/browser/chrome_paths_internal.h" #include "ios/chrome/browser/chrome_paths_internal.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace ios { namespace ios {
namespace { namespace {
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#include "base/logging.h" #include "base/logging.h"
#include "base/mac/foundation_util.h" #include "base/mac/foundation_util.h"
#include "base/mac/scoped_block.h" #include "base/mac/scoped_block.h"
#include "base/mac/scoped_nsobject.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#include "ios/chrome/browser/chrome_url_constants.h" #include "ios/chrome/browser/chrome_url_constants.h"
...@@ -18,6 +17,10 @@ ...@@ -18,6 +17,10 @@
#include "url/gurl.h" #include "url/gurl.h"
#include "url/url_constants.h" #include "url/url_constants.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
bool UrlIsExternalFileReference(const GURL& url) { bool UrlIsExternalFileReference(const GURL& url) {
return url.SchemeIs(kChromeUIScheme) && return url.SchemeIs(kChromeUIScheme) &&
base::LowerCaseEqualsASCII(url.host(), kChromeUIExternalFileHost); base::LowerCaseEqualsASCII(url.host(), kChromeUIExternalFileHost);
...@@ -43,7 +46,7 @@ bool IsHandledProtocol(const std::string& scheme) { ...@@ -43,7 +46,7 @@ bool IsHandledProtocol(const std::string& scheme) {
} }
@implementation ChromeAppConstants { @implementation ChromeAppConstants {
base::scoped_nsobject<NSString> _callbackScheme; NSString* _callbackScheme;
} }
+ (ChromeAppConstants*)sharedInstance { + (ChromeAppConstants*)sharedInstance {
...@@ -64,7 +67,7 @@ bool IsHandledProtocol(const std::string& scheme) { ...@@ -64,7 +67,7 @@ bool IsHandledProtocol(const std::string& scheme) {
base::mac::ObjCCastStrict<NSArray>(urlType[@"CFBundleURLSchemes"]); base::mac::ObjCCastStrict<NSArray>(urlType[@"CFBundleURLSchemes"]);
for (NSString* scheme in schemes) { for (NSString* scheme in schemes) {
if ([allowableSchemes containsObject:scheme]) if ([allowableSchemes containsObject:scheme])
_callbackScheme.reset([scheme copy]); _callbackScheme = [scheme copy];
} }
} }
} }
...@@ -73,7 +76,7 @@ bool IsHandledProtocol(const std::string& scheme) { ...@@ -73,7 +76,7 @@ bool IsHandledProtocol(const std::string& scheme) {
} }
- (void)setCallbackSchemeForTesting:(NSString*)scheme { - (void)setCallbackSchemeForTesting:(NSString*)scheme {
_callbackScheme.reset([scheme copy]); _callbackScheme = [scheme copy];
} }
@end @end
...@@ -6,6 +6,10 @@ ...@@ -6,6 +6,10 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace { namespace {
NSString* const kAppStartupFailureCountKey = @"AppStartupFailureCount"; NSString* const kAppStartupFailureCountKey = @"AppStartupFailureCount";
} }
......
...@@ -22,6 +22,10 @@ ...@@ -22,6 +22,10 @@
#include "ios/chrome/browser/chrome_switches.h" #include "ios/chrome/browser/chrome_switches.h"
#include "ios/web/public/web_view_creation_util.h" #include "ios/web/public/web_view_creation_util.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace { namespace {
NSString* const kEnableAlertOnBackgroundUpload = NSString* const kEnableAlertOnBackgroundUpload =
......
...@@ -10,6 +10,10 @@ ...@@ -10,6 +10,10 @@
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#include "base/threading/thread_restrictions.h" #include "base/threading/thread_restrictions.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
void SetSkipSystemBackupAttributeToItem(const base::FilePath& path, void SetSkipSystemBackupAttributeToItem(const base::FilePath& path,
bool skip_system_backup) { bool skip_system_backup) {
base::ThreadRestrictions::AssertIOAllowed(); base::ThreadRestrictions::AssertIOAllowed();
......
...@@ -9,6 +9,10 @@ ...@@ -9,6 +9,10 @@
#include "base/mac/foundation_util.h" #include "base/mac/foundation_util.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace { namespace {
NSString* const kInstallationTimeKey = @"omaha.InstallationTime"; NSString* const kInstallationTimeKey = @"omaha.InstallationTime";
......
...@@ -9,14 +9,16 @@ ...@@ -9,14 +9,16 @@
#include <memory> #include <memory>
#include "base/ios/weak_nsobject.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/mac/scoped_nsobject.h"
#include "base/metrics/histogram.h" #include "base/metrics/histogram.h"
#include "ios/web/public/web_thread.h" #include "ios/web/public/web_thread.h"
#include "net/base/backoff_entry.h" #include "net/base/backoff_entry.h"
#include "url/gurl.h" #include "url/gurl.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace { namespace {
const net::BackoffEntry::Policy kPollingBackoffPolicy = { const net::BackoffEntry::Policy kPollingBackoffPolicy = {
0, // Number of errors to ignore. 0, // Number of errors to ignore.
...@@ -64,13 +66,13 @@ const net::BackoffEntry::Policy kPollingBackoffPolicy = { ...@@ -64,13 +66,13 @@ const net::BackoffEntry::Policy kPollingBackoffPolicy = {
@implementation InstallationNotifier { @implementation InstallationNotifier {
std::unique_ptr<net::BackoffEntry> _backoffEntry; std::unique_ptr<net::BackoffEntry> _backoffEntry;
base::scoped_nsprotocol<id<DispatcherProtocol>> _dispatcher; id<DispatcherProtocol> _dispatcher;
// Dictionary mapping URL schemes to mutable sets of observers. // Dictionary mapping URL schemes to mutable sets of observers.
base::scoped_nsobject<NSMutableDictionary> _installedAppObservers; NSMutableDictionary* _installedAppObservers;
NSNotificationCenter* _notificationCenter; // Weak. __weak NSNotificationCenter* _notificationCenter;
// This object can be a fake application in unittests. // This object can be a fake application in unittests.
UIApplication* sharedApplication_; // Weak. __weak UIApplication* sharedApplication_;
} }
@synthesize lastCreatedBlockId = lastCreatedBlockId_; @synthesize lastCreatedBlockId = lastCreatedBlockId_;
...@@ -84,8 +86,8 @@ const net::BackoffEntry::Policy kPollingBackoffPolicy = { ...@@ -84,8 +86,8 @@ const net::BackoffEntry::Policy kPollingBackoffPolicy = {
self = [super init]; self = [super init];
if (self) { if (self) {
lastCreatedBlockId_ = 0; lastCreatedBlockId_ = 0;
_dispatcher.reset([[DefaultDispatcher alloc] init]); _dispatcher = [[DefaultDispatcher alloc] init];
_installedAppObservers.reset([[NSMutableDictionary alloc] init]); _installedAppObservers = [[NSMutableDictionary alloc] init];
_notificationCenter = [NSNotificationCenter defaultCenter]; _notificationCenter = [NSNotificationCenter defaultCenter];
sharedApplication_ = [UIApplication sharedApplication]; sharedApplication_ = [UIApplication sharedApplication];
_backoffEntry.reset(new net::BackoffEntry([self backOffPolicy])); _backoffEntry.reset(new net::BackoffEntry([self backOffPolicy]));
...@@ -117,7 +119,7 @@ const net::BackoffEntry::Policy kPollingBackoffPolicy = { ...@@ -117,7 +119,7 @@ const net::BackoffEntry::Policy kPollingBackoffPolicy = {
[NSValue valueWithNonretainedObject:observer]; [NSValue valueWithNonretainedObject:observer];
NSMutableSet* observers = [_installedAppObservers objectForKey:scheme]; NSMutableSet* observers = [_installedAppObservers objectForKey:scheme];
if (!observers) if (!observers)
observers = [[[NSMutableSet alloc] init] autorelease]; observers = [[NSMutableSet alloc] init];
if ([observers containsObject:weakReferenceToObserver]) if ([observers containsObject:weakReferenceToObserver])
return; return;
[observers addObject:weakReferenceToObserver]; [observers addObject:weakReferenceToObserver];
...@@ -161,12 +163,11 @@ const net::BackoffEntry::Policy kPollingBackoffPolicy = { ...@@ -161,12 +163,11 @@ const net::BackoffEntry::Policy kPollingBackoffPolicy = {
_backoffEntry->InformOfRequest(false); _backoffEntry->InformOfRequest(false);
int64_t delayInNSec = int64_t delayInNSec =
_backoffEntry->GetTimeUntilRelease().InMicroseconds() * NSEC_PER_USEC; _backoffEntry->GetTimeUntilRelease().InMicroseconds() * NSEC_PER_USEC;
base::WeakNSObject<InstallationNotifier> weakSelf(self); __weak InstallationNotifier* weakSelf = self;
[_dispatcher dispatchAfter:delayInNSec [_dispatcher dispatchAfter:delayInNSec
withBlock:^{ withBlock:^{
DCHECK_CURRENTLY_ON(web::WebThread::UI); DCHECK_CURRENTLY_ON(web::WebThread::UI);
base::scoped_nsobject<InstallationNotifier> strongSelf( InstallationNotifier* strongSelf = weakSelf;
[weakSelf retain]);
if (blockId == [strongSelf lastCreatedBlockId]) { if (blockId == [strongSelf lastCreatedBlockId]) {
[strongSelf pollForTheInstallationOfApps]; [strongSelf pollForTheInstallationOfApps];
} }
...@@ -212,7 +213,7 @@ const net::BackoffEntry::Policy kPollingBackoffPolicy = { ...@@ -212,7 +213,7 @@ const net::BackoffEntry::Policy kPollingBackoffPolicy = {
#pragma mark Testing setters #pragma mark Testing setters
- (void)setDispatcher:(id<DispatcherProtocol>)dispatcher { - (void)setDispatcher:(id<DispatcherProtocol>)dispatcher {
_dispatcher.reset(dispatcher); _dispatcher = dispatcher;
} }
- (void)setSharedApplication:(id)sharedApplication { - (void)setSharedApplication:(id)sharedApplication {
......
...@@ -79,6 +79,10 @@ ...@@ -79,6 +79,10 @@
#include "net/url_request/url_request_job_factory_impl.h" #include "net/url_request/url_request_job_factory_impl.h"
#include "url/url_constants.h" #include "url/url_constants.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
// The IOSChromeIOThread object must outlive any tasks posted to the IO thread // The IOSChromeIOThread object must outlive any tasks posted to the IO thread
// before the Quit task, so base::Bind() calls are not refcounted. // before the Quit task, so base::Bind() calls are not refcounted.
......
...@@ -8,6 +8,10 @@ ...@@ -8,6 +8,10 @@
#include "base/ios/ios_util.h" #include "base/ios/ios_util.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
void OpenUrlWithCompletionHandler(NSURL* url, void OpenUrlWithCompletionHandler(NSURL* url,
void (^completion_handler)(BOOL success)) { void (^completion_handler)(BOOL success)) {
if (base::ios::IsRunningOnIOS10OrLater()) { if (base::ios::IsRunningOnIOS10OrLater()) {
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
- (nullable instancetype)initWithBaseViewController: - (nullable instancetype)initWithBaseViewController:
(nullable UIViewController*)viewController NS_UNAVAILABLE; (nullable UIViewController*)viewController NS_UNAVAILABLE;
@property(nonatomic, readonly, nullable) UIWindow* window; @property(weak, nonatomic, readonly, nullable) UIWindow* window;
@end @end
......
...@@ -4,19 +4,18 @@ ...@@ -4,19 +4,18 @@
#import "ios/chrome/browser/root_coordinator.h" #import "ios/chrome/browser/root_coordinator.h"
#include "base/ios/weak_nsobject.h"
#include "base/logging.h" #include "base/logging.h"
@interface RootCoordinator () { #if !defined(__has_feature) || !__has_feature(objc_arc)
base::WeakNSObject<UIWindow> _window; #error "This file requires ARC support."
} #endif
@end
@implementation RootCoordinator @implementation RootCoordinator
@synthesize window = _window;
- (instancetype)initWithWindow:(UIWindow*)window { - (instancetype)initWithWindow:(UIWindow*)window {
if ((self = [super initWithBaseViewController:nil])) { if ((self = [super initWithBaseViewController:nil])) {
_window.reset(window); _window = window;
} }
return self; return self;
} }
...@@ -26,10 +25,4 @@ ...@@ -26,10 +25,4 @@
return nil; return nil;
} }
#pragma mark - property implementation
- (nullable UIWindow*)window {
return _window;
}
@end @end
...@@ -4,33 +4,27 @@ ...@@ -4,33 +4,27 @@
#import "ios/chrome/browser/xcallback_parameters.h" #import "ios/chrome/browser/xcallback_parameters.h"
#include "base/mac/scoped_nsobject.h" #if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace { namespace {
NSString* const kSourceAppIdKey = @"sourceAppId"; NSString* const kSourceAppIdKey = @"sourceAppId";
} }
@interface XCallbackParameters () {
base::scoped_nsobject<NSString> _sourceAppId;
}
@end
@implementation XCallbackParameters @implementation XCallbackParameters
@synthesize sourceAppId = _sourceAppId;
- (instancetype)initWithSourceAppId:(NSString*)sourceAppId { - (instancetype)initWithSourceAppId:(NSString*)sourceAppId {
self = [super init]; self = [super init];
if (self) { if (self) {
_sourceAppId.reset([sourceAppId copy]); _sourceAppId = [sourceAppId copy];
} }
return self; return self;
} }
- (NSString*)description { - (NSString*)description {
return [NSString stringWithFormat:@"SourceApp: %@\n", _sourceAppId.get()]; return [NSString stringWithFormat:@"SourceApp: %@\n", _sourceAppId];
}
- (NSString*)sourceAppId {
return _sourceAppId.get();
} }
#pragma mark - NSCoding Methods #pragma mark - NSCoding Methods
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment