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