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..fa61964559ca6fdfdfee9cbc636340cfb776711a 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 |
@@ -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* |
@@ -88,9 +91,10 @@ 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(); |