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 209746341d51ce18344f1a7e7b68b8e944b77421..7527133963eaf71a5d883e8b9da24a8d72e6df5a 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 |
@@ -14,10 +14,6 @@ |
#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 { |
@@ -27,10 +23,10 @@ |
// 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]; |
+ forMainFrameOnly:YES] autorelease]; |
} |
} // namespace |
@@ -74,7 +70,7 @@ |
addUserScript:InternalGetEarlyPageScript(browser_state_)]; |
} |
// Prevent callers from changing the internals of configuration. |
- return [configuration_ copy]; |
+ return [[configuration_ copy] autorelease]; |
} |
CRWWKScriptMessageRouter* |
@@ -92,16 +88,9 @@ |
void WKWebViewConfigurationProvider::Purge() { |
DCHECK([NSThread isMainThread]); |
#if DCHECK_IS_ON() |
- base::WeakNSObject<id> weak_configuration; |
- base::WeakNSObject<id> weak_router; |
- // It's expected that the weak objects auto-nil by the end of this method. |
- // They should not be in any autoreleasepool that might keep them alive. |
- @autoreleasepool { |
- weak_configuration.reset(configuration_); |
- weak_router.reset(router_); |
- } |
-// TODO(crbug.com/522672): See commented out DCHECK below. |
-// __weak id weak_process_pool = [configuration_ processPool]; |
+ base::WeakNSObject<id> weak_configuration(configuration_); |
+ base::WeakNSObject<id> weak_router(router_); |
+ base::WeakNSObject<id> weak_process_pool([configuration_ processPool]); |
#endif // DCHECK_IS_ON() |
configuration_.reset(); |
router_.reset(); |