Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(126)

Unified Diff: ios/web/web_state/ui/wk_web_view_configuration_provider.mm

Issue 2432363003: [ObjC ARC] Converts parts of ios/web/webstate to ARC. (Closed)
Patch Set: rebase Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 2ef20332c7c0c9235a66901cc161996478c6a610..4b1ad99a649a03712598848445aa4e16976fffa5 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,6 +14,10 @@
#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 +27,10 @@ const char kWKWebViewConfigProviderKeyName[] = "wk_web_view_config_provider";
// Returns an autoreleased instance of WKUserScript to be added to
// configuration's userContentController.
WKUserScript* InternalGetEarlyPageScript() {
- return [[[WKUserScript alloc]
+ return [[WKUserScript alloc]
initWithSource:GetEarlyPageScript()
injectionTime:WKUserScriptInjectionTimeAtDocumentStart
- forMainFrameOnly:YES] autorelease];
+ forMainFrameOnly:YES];
}
} // namespace
@@ -57,7 +61,7 @@ WKWebViewConfiguration*
WKWebViewConfigurationProvider::GetWebViewConfiguration() {
DCHECK([NSThread isMainThread]);
if (!configuration_) {
- configuration_.reset([[WKWebViewConfiguration alloc] init]);
+ configuration_ = [[WKWebViewConfiguration alloc] init];
if (is_off_the_record_) {
[configuration_
setWebsiteDataStore:[WKWebsiteDataStore nonPersistentDataStore]];
@@ -78,7 +82,7 @@ WKWebViewConfigurationProvider::GetWebViewConfiguration() {
addUserScript:InternalGetEarlyPageScript()];
}
// Prevent callers from changing the internals of configuration.
- return [[configuration_ copy] autorelease];
+ return [configuration_ copy];
}
CRWWKScriptMessageRouter*
@@ -87,8 +91,8 @@ WKWebViewConfigurationProvider::GetScriptMessageRouter() {
if (!router_) {
WKUserContentController* userContentController =
[GetWebViewConfiguration() userContentController];
- router_.reset([[CRWWKScriptMessageRouter alloc]
- initWithUserContentController:userContentController]);
+ router_ = [[CRWWKScriptMessageRouter alloc]
+ initWithUserContentController:userContentController];
}
return router_;
}
@@ -96,12 +100,14 @@ WKWebViewConfigurationProvider::GetScriptMessageRouter() {
void WKWebViewConfigurationProvider::Purge() {
DCHECK([NSThread isMainThread]);
#if !defined(NDEBUG) || !defined(DCHECK_ALWAYS_ON) // Matches 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_;
+ __weak id weak_process_pool = [configuration_ processPool];
+// TODO(crbug.com/522672): Remove this pragma.
+#pragma unused(weak_process_pool)
#endif // !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
- configuration_.reset();
- router_.reset();
+ configuration_ = nil;
+ router_ = nil;
// Make sure that no one retains configuration, router, processPool.
DCHECK(!weak_configuration);
DCHECK(!weak_router);
« no previous file with comments | « ios/web/web_state/ui/wk_web_view_configuration_provider.h ('k') | ios/web/web_state/web_controller_observer_bridge.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698