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

Side by Side Diff: ios/web_view/internal/criwv.mm

Issue 2692603002: Convert //ios/web_view/internal to ARC. (Closed)
Patch Set: Respond to comments. Created 3 years, 10 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
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_view/public/criwv.h" 5 #import "ios/web_view/public/criwv.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/location.h" 9 #include "base/location.h"
10 #import "base/mac/bind_objc_block.h" 10 #import "base/mac/bind_objc_block.h"
11 #include "base/single_thread_task_runner.h" 11 #include "base/single_thread_task_runner.h"
12 #include "ios/web/public/app/web_main.h" 12 #include "ios/web/public/app/web_main.h"
13 #include "ios/web/public/web_thread.h" 13 #include "ios/web/public/web_thread.h"
14 #import "ios/web_view/internal/criwv_web_main_delegate.h" 14 #import "ios/web_view/internal/criwv_web_main_delegate.h"
15 #import "ios/web_view/public/criwv_delegate.h" 15 #import "ios/web_view/public/criwv_delegate.h"
16 #import "ios/web_view/public/criwv_web_view.h" 16 #import "ios/web_view/public/criwv_web_view.h"
17 #import "ios/web_view/public/criwv_web_view_configuration.h" 17 #import "ios/web_view/public/criwv_web_view_configuration.h"
18 #import "ios/web_view/public/criwv_website_data_store.h" 18 #import "ios/web_view/public/criwv_website_data_store.h"
19 19
20 #if !defined(__has_feature) || !__has_feature(objc_arc)
21 #error "This file requires ARC support."
22 #endif
23
20 namespace { 24 namespace {
21 CRIWV* g_criwv = nil; 25 CRIWV* g_criwv = nil;
22 } 26 }
23 27
24 @interface CRIWV () { 28 @interface CRIWV () {
25 id<CRIWVDelegate> _delegate;
26 std::unique_ptr<ios_web_view::CRIWVWebMainDelegate> _webMainDelegate; 29 std::unique_ptr<ios_web_view::CRIWVWebMainDelegate> _webMainDelegate;
27 std::unique_ptr<web::WebMain> _webMain; 30 std::unique_ptr<web::WebMain> _webMain;
28 } 31 }
29 32
33 @property(nonatomic, weak) id<CRIWVDelegate> delegate;
34
30 - (instancetype)initWithDelegate:(id<CRIWVDelegate>)delegate; 35 - (instancetype)initWithDelegate:(id<CRIWVDelegate>)delegate;
31 @end 36 @end
32 37
33 @implementation CRIWV 38 @implementation CRIWV
34 39
40 @synthesize delegate = _delegate;
41
35 + (void)configureWithDelegate:(id<CRIWVDelegate>)delegate { 42 + (void)configureWithDelegate:(id<CRIWVDelegate>)delegate {
36 g_criwv = [[CRIWV alloc] initWithDelegate:delegate]; 43 g_criwv = [[CRIWV alloc] initWithDelegate:delegate];
37 } 44 }
38 45
39 + (void)shutDown { 46 + (void)shutDown {
40 [g_criwv release];
41 g_criwv = nil; 47 g_criwv = nil;
42 } 48 }
43 49
44 + (CRIWVWebView*)webViewWithFrame:(CGRect)frame { 50 + (CRIWVWebView*)webViewWithFrame:(CGRect)frame {
45 CRIWVWebViewConfiguration* configuration = 51 CRIWVWebViewConfiguration* configuration =
46 [[CRIWVWebViewConfiguration alloc] init]; 52 [[CRIWVWebViewConfiguration alloc] init];
47 configuration.websiteDataStore = [CRIWVWebsiteDataStore defaultDataStore]; 53 configuration.websiteDataStore = [CRIWVWebsiteDataStore defaultDataStore];
48 54
49 return [[[CRIWVWebView alloc] initWithFrame:frame configuration:configuration] 55 return [[CRIWVWebView alloc] initWithFrame:frame configuration:configuration];
50 autorelease];
51 } 56 }
52 57
53 - (instancetype)initWithDelegate:(id<CRIWVDelegate>)delegate { 58 - (instancetype)initWithDelegate:(id<CRIWVDelegate>)delegate {
54 self = [super init]; 59 self = [super init];
55 if (self) { 60 if (self) {
56 _delegate = delegate; 61 _delegate = delegate;
57 _webMainDelegate.reset(new ios_web_view::CRIWVWebMainDelegate(_delegate)); 62 _webMainDelegate.reset(new ios_web_view::CRIWVWebMainDelegate(_delegate));
58 web::WebMainParams params(_webMainDelegate.get()); 63 web::WebMainParams params(_webMainDelegate.get());
59 _webMain.reset(new web::WebMain(params)); 64 _webMain.reset(new web::WebMain(params));
60 } 65 }
61 return self; 66 return self;
62 } 67 }
63 68
64 - (void)dealloc { 69 - (void)dealloc {
65 _webMain.reset(); 70 _webMain.reset();
66 _webMainDelegate.reset(); 71 _webMainDelegate.reset();
67 [super dealloc];
68 } 72 }
69 73
70 @end 74 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698