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

Side by Side Diff: ios/web/web_state/web_view_internal_creation_util.mm

Issue 2948673002: Revert of [ObjC ARC] Converts ios/web:web to ARC. (Closed)
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « ios/web/web_state/web_state_impl.mm ('k') | ios/web/web_state/wk_web_view_security_util.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "ios/web/web_state/web_view_internal_creation_util.h" 5 #import "ios/web/web_state/web_view_internal_creation_util.h"
6 6
7 #import <objc/runtime.h> 7 #import <objc/runtime.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #import "base/mac/scoped_nsobject.h"
10 #include "base/strings/sys_string_conversions.h" 11 #include "base/strings/sys_string_conversions.h"
11 #import "ios/web/public/web_client.h" 12 #import "ios/web/public/web_client.h"
12 #import "ios/web/web_state/ui/crw_context_menu_controller.h" 13 #import "ios/web/web_state/ui/crw_context_menu_controller.h"
13 #import "ios/web/web_state/ui/wk_web_view_configuration_provider.h" 14 #import "ios/web/web_state/ui/wk_web_view_configuration_provider.h"
14 15
15 #if !defined(__has_feature) || !__has_feature(objc_arc)
16 #error "This file requires ARC support."
17 #endif
18
19 namespace web { 16 namespace web {
20 17
21 namespace { 18 namespace {
22 19
23 // Verifies the preconditions for creating a WKWebView. Must be called before 20 // Verifies the preconditions for creating a WKWebView. Must be called before
24 // a WKWebView is allocated. Not verifying the preconditions before creating 21 // a WKWebView is allocated. Not verifying the preconditions before creating
25 // a WKWebView will lead to undefined behavior. 22 // a WKWebView will lead to undefined behavior.
26 void VerifyWKWebViewCreationPreConditions( 23 void VerifyWKWebViewCreationPreConditions(
27 BrowserState* browser_state, 24 BrowserState* browser_state,
28 WKWebViewConfiguration* configuration) { 25 WKWebViewConfiguration* configuration) {
(...skipping 27 matching lines...) Expand all
56 // reasonable value. 53 // reasonable value.
57 web_view.scrollView.decelerationRate = UIScrollViewDecelerationRateNormal; 54 web_view.scrollView.decelerationRate = UIScrollViewDecelerationRateNormal;
58 55
59 // Starting in iOS10, |allowsLinkPreview| defaults to YES. This should be 56 // Starting in iOS10, |allowsLinkPreview| defaults to YES. This should be
60 // disabled since the default implementation will open the link in Safari. 57 // disabled since the default implementation will open the link in Safari.
61 // TODO(crbug.com/622746): Remove once web// link preview implementation is 58 // TODO(crbug.com/622746): Remove once web// link preview implementation is
62 // created. 59 // created.
63 web_view.allowsLinkPreview = NO; 60 web_view.allowsLinkPreview = NO;
64 61
65 if (context_menu_delegate) { 62 if (context_menu_delegate) {
66 CRWContextMenuController* context_menu_controller = [ 63 base::scoped_nsobject<CRWContextMenuController> context_menu_controller(
67 [CRWContextMenuController alloc] initWithWebView:web_view 64 [[CRWContextMenuController alloc]
68 injectionEvaluator:nil 65 initWithWebView:web_view
69 delegate:context_menu_delegate]; 66 injectionEvaluator:nil
70 void* associated_object_key = (__bridge void*)context_menu_controller; 67 delegate:context_menu_delegate]);
71 objc_setAssociatedObject(web_view, associated_object_key, 68 objc_setAssociatedObject(web_view, context_menu_controller.get(),
72 context_menu_controller, 69 context_menu_controller.get(),
73 OBJC_ASSOCIATION_RETAIN_NONATOMIC); 70 OBJC_ASSOCIATION_RETAIN_NONATOMIC);
74 } 71 }
75 72
76 return web_view; 73 return [web_view autorelease];
77 } 74 }
78 75
79 WKWebView* BuildWKWebView(CGRect frame, 76 WKWebView* BuildWKWebView(CGRect frame,
80 WKWebViewConfiguration* configuration, 77 WKWebViewConfiguration* configuration,
81 BrowserState* browser_state, 78 BrowserState* browser_state,
82 UserAgentType user_agent_type) { 79 UserAgentType user_agent_type) {
83 return BuildWKWebView(frame, configuration, browser_state, user_agent_type, 80 return BuildWKWebView(frame, configuration, browser_state, user_agent_type,
84 nil); 81 nil);
85 } 82 }
86 83
87 WKWebView* BuildWKWebView(CGRect frame, 84 WKWebView* BuildWKWebView(CGRect frame,
88 WKWebViewConfiguration* configuration, 85 WKWebViewConfiguration* configuration,
89 BrowserState* browser_state) { 86 BrowserState* browser_state) {
90 return BuildWKWebView(frame, configuration, browser_state, 87 return BuildWKWebView(frame, configuration, browser_state,
91 UserAgentType::MOBILE); 88 UserAgentType::MOBILE);
92 } 89 }
93 90
94 } // namespace web 91 } // namespace web
OLDNEW
« no previous file with comments | « ios/web/web_state/web_state_impl.mm ('k') | ios/web/web_state/wk_web_view_security_util.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698