| Index: ios/web/web_state/ui/wk_web_view_configuration_provider.mm
|
| diff --git a/ios/web/web_state/ui/wk_web_view_configuration_provider.mm b/ios/web/web_state/ui/wk_web_view_configuration_provider.mm
|
| index 7527133963eaf71a5d883e8b9da24a8d72e6df5a..fbb2c8ca23ec893972a9a5484bbcedfe0538b659 100644
|
| --- a/ios/web/web_state/ui/wk_web_view_configuration_provider.mm
|
| +++ b/ios/web/web_state/ui/wk_web_view_configuration_provider.mm
|
| @@ -7,13 +7,16 @@
|
| #import <Foundation/Foundation.h>
|
| #import <WebKit/WebKit.h>
|
|
|
| -#import "base/ios/weak_nsobject.h"
|
| #include "base/logging.h"
|
| #include "base/memory/ptr_util.h"
|
| #include "ios/web/public/browser_state.h"
|
| #import "ios/web/web_state/js/page_script_util.h"
|
| #import "ios/web/web_state/ui/crw_wk_script_message_router.h"
|
|
|
| +#if !defined(__has_feature) || !__has_feature(objc_arc)
|
| +#error "This file requires ARC support."
|
| +#endif
|
| +
|
| namespace web {
|
|
|
| namespace {
|
| @@ -23,10 +26,10 @@ const char kWKWebViewConfigProviderKeyName[] = "wk_web_view_config_provider";
|
| // Returns an autoreleased instance of WKUserScript to be added to
|
| // configuration's userContentController.
|
| WKUserScript* InternalGetEarlyPageScript(BrowserState* browser_state) {
|
| - return [[[WKUserScript alloc]
|
| + return [[WKUserScript alloc]
|
| initWithSource:GetEarlyPageScript(browser_state)
|
| injectionTime:WKUserScriptInjectionTimeAtDocumentStart
|
| - forMainFrameOnly:YES] autorelease];
|
| + forMainFrameOnly:YES];
|
| }
|
|
|
| } // namespace
|
| @@ -56,7 +59,7 @@ WKWebViewConfiguration*
|
| WKWebViewConfigurationProvider::GetWebViewConfiguration() {
|
| DCHECK([NSThread isMainThread]);
|
| if (!configuration_) {
|
| - configuration_.reset([[WKWebViewConfiguration alloc] init]);
|
| + configuration_ = [[WKWebViewConfiguration alloc] init];
|
| if (browser_state_->IsOffTheRecord()) {
|
| [configuration_
|
| setWebsiteDataStore:[WKWebsiteDataStore nonPersistentDataStore]];
|
| @@ -70,7 +73,7 @@ WKWebViewConfigurationProvider::GetWebViewConfiguration() {
|
| addUserScript:InternalGetEarlyPageScript(browser_state_)];
|
| }
|
| // Prevent callers from changing the internals of configuration.
|
| - return [[configuration_ copy] autorelease];
|
| + return [configuration_ copy];
|
| }
|
|
|
| CRWWKScriptMessageRouter*
|
| @@ -79,8 +82,8 @@ WKWebViewConfigurationProvider::GetScriptMessageRouter() {
|
| if (!router_) {
|
| WKUserContentController* userContentController =
|
| [GetWebViewConfiguration() userContentController];
|
| - router_.reset([[CRWWKScriptMessageRouter alloc]
|
| - initWithUserContentController:userContentController]);
|
| + router_ = [[CRWWKScriptMessageRouter alloc]
|
| + initWithUserContentController:userContentController];
|
| }
|
| return router_;
|
| }
|
| @@ -88,12 +91,13 @@ WKWebViewConfigurationProvider::GetScriptMessageRouter() {
|
| void WKWebViewConfigurationProvider::Purge() {
|
| DCHECK([NSThread isMainThread]);
|
| #if DCHECK_IS_ON()
|
| - base::WeakNSObject<id> weak_configuration(configuration_);
|
| - base::WeakNSObject<id> weak_router(router_);
|
| - base::WeakNSObject<id> weak_process_pool([configuration_ processPool]);
|
| + __weak id weak_configuration = configuration_;
|
| + __weak id weak_router = router_;
|
| +// TODO(crbug.com/522672): See commented out DCHECK below.
|
| +// __weak id weak_process_pool = [configuration_ processPool];
|
| #endif // DCHECK_IS_ON()
|
| - configuration_.reset();
|
| - router_.reset();
|
| + configuration_ = nil;
|
| + router_ = nil;
|
| // Make sure that no one retains configuration, router, processPool.
|
| #if DCHECK_IS_ON()
|
| DCHECK(!weak_configuration);
|
|
|