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

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

Issue 2916473002: [ObjC ARC] Converts ios/web:web to ARC. (Closed)
Patch Set: Fixing silly mistake Created 3 years, 6 months 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
« no previous file with comments | « ios/web/web_state/ui/crw_wk_script_message_router.h ('k') | ios/web/web_state/ui/web_view_js_utils.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/web/web_state/ui/crw_wk_script_message_router.mm
diff --git a/ios/web/web_state/ui/crw_wk_script_message_router.mm b/ios/web/web_state/ui/crw_wk_script_message_router.mm
index ed13ddb0b878def502fbd03555fc35f32ee2a154..295ab0bd891506a364eb49a2f71d2c97311648d7 100644
--- a/ios/web/web_state/ui/crw_wk_script_message_router.mm
+++ b/ios/web/web_state/ui/crw_wk_script_message_router.mm
@@ -5,7 +5,10 @@
#import "ios/web/web_state/ui/crw_wk_script_message_router.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 CRWWKScriptMessageRouter ()<WKScriptMessageHandler>
@@ -13,23 +16,23 @@
- (void)tryRemoveScriptMessageHandlerForName:(NSString*)messageName
webView:(WKWebView*)webView;
+@property(nonatomic, weak, readwrite)
+ WKUserContentController* userContentController;
+
@end
@implementation CRWWKScriptMessageRouter {
// Two level map of registed message handlers. Keys are message names and
// values are more maps (where keys are web views and values are handlers).
- base::scoped_nsobject<NSMutableDictionary> _handlers;
- // Wrapped WKUserContentController.
- base::scoped_nsobject<WKUserContentController> _userContentController;
+ NSMutableDictionary* _handlers;
}
+// Wrapped WKUserContentController.
+@synthesize userContentController = _userContentController;
+
#pragma mark -
#pragma mark Interface
-- (WKUserContentController*)userContentController {
- return _userContentController.get();
-}
-
- (instancetype)init {
NOTREACHED();
return nil;
@@ -39,8 +42,8 @@
(WKUserContentController*)userContentController {
DCHECK(userContentController);
if ((self = [super init])) {
- _handlers.reset([[NSMutableDictionary alloc] init]);
- _userContentController.reset([userContentController retain]);
+ _handlers = [[NSMutableDictionary alloc] init];
+ _userContentController = userContentController;
}
return self;
}
@@ -100,12 +103,11 @@
- (void)tryRemoveScriptMessageHandlerForName:(NSString*)messageName
webView:(WKWebView*)webView {
NSMapTable* webViewToHandlerMap = [_handlers objectForKey:messageName];
- id handler = [webViewToHandlerMap objectForKey:webView];
+ NS_VALID_UNTIL_END_OF_SCOPE id handler =
+ [webViewToHandlerMap objectForKey:webView];
if (!handler)
return;
- // Extend the lifetime of |handler| so removeScriptMessageHandlerForName: can
- // be called from inside of |handler|.
- [[handler retain] autorelease];
+
if (webViewToHandlerMap.count == 1) {
[_handlers removeObjectForKey:messageName];
[_userContentController removeScriptMessageHandlerForName:messageName];
« no previous file with comments | « ios/web/web_state/ui/crw_wk_script_message_router.h ('k') | ios/web/web_state/ui/web_view_js_utils.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698