Chromium Code Reviews| OLD | NEW |
|---|---|
| 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; | 29 __unsafe_unretained id<CRIWVDelegate> _delegate; |
|
Eugene But (OOO till 7-30)
2017/02/10 23:07:22
Should this be __weak?
michaeldo
2017/02/11 06:02:32
I was basing this off the arc migrate instructions
| |
| 26 std::unique_ptr<ios_web_view::CRIWVWebMainDelegate> _webMainDelegate; | 30 std::unique_ptr<ios_web_view::CRIWVWebMainDelegate> _webMainDelegate; |
| 27 std::unique_ptr<web::WebMain> _webMain; | 31 std::unique_ptr<web::WebMain> _webMain; |
| 28 } | 32 } |
| 29 | 33 |
| 30 - (instancetype)initWithDelegate:(id<CRIWVDelegate>)delegate; | 34 - (instancetype)initWithDelegate:(id<CRIWVDelegate>)delegate; |
| 31 @end | 35 @end |
| 32 | 36 |
| 33 @implementation CRIWV | 37 @implementation CRIWV |
| 34 | 38 |
| 35 + (void)configureWithDelegate:(id<CRIWVDelegate>)delegate { | 39 + (void)configureWithDelegate:(id<CRIWVDelegate>)delegate { |
| 36 g_criwv = [[CRIWV alloc] initWithDelegate:delegate]; | 40 g_criwv = [[CRIWV alloc] initWithDelegate:delegate]; |
| 37 } | 41 } |
| 38 | 42 |
| 39 + (void)shutDown { | 43 + (void)shutDown { |
| 40 [g_criwv release]; | |
| 41 g_criwv = nil; | 44 g_criwv = nil; |
| 42 } | 45 } |
| 43 | 46 |
| 44 + (CRIWVWebView*)webViewWithFrame:(CGRect)frame { | 47 + (CRIWVWebView*)webViewWithFrame:(CGRect)frame { |
| 45 CRIWVWebViewConfiguration* configuration = | 48 CRIWVWebViewConfiguration* configuration = |
| 46 [[CRIWVWebViewConfiguration alloc] init]; | 49 [[CRIWVWebViewConfiguration alloc] init]; |
| 47 configuration.websiteDataStore = [CRIWVWebsiteDataStore defaultDataStore]; | 50 configuration.websiteDataStore = [CRIWVWebsiteDataStore defaultDataStore]; |
| 48 | 51 |
| 49 return [[[CRIWVWebView alloc] initWithFrame:frame configuration:configuration] | 52 return [[CRIWVWebView alloc] initWithFrame:frame configuration:configuration]; |
| 50 autorelease]; | |
| 51 } | 53 } |
| 52 | 54 |
| 53 - (instancetype)initWithDelegate:(id<CRIWVDelegate>)delegate { | 55 - (instancetype)initWithDelegate:(id<CRIWVDelegate>)delegate { |
| 54 self = [super init]; | 56 self = [super init]; |
| 55 if (self) { | 57 if (self) { |
| 56 _delegate = delegate; | 58 _delegate = delegate; |
| 57 _webMainDelegate.reset(new ios_web_view::CRIWVWebMainDelegate(_delegate)); | 59 _webMainDelegate.reset(new ios_web_view::CRIWVWebMainDelegate(_delegate)); |
| 58 web::WebMainParams params(_webMainDelegate.get()); | 60 web::WebMainParams params(_webMainDelegate.get()); |
| 59 _webMain.reset(new web::WebMain(params)); | 61 _webMain.reset(new web::WebMain(params)); |
| 60 } | 62 } |
| 61 return self; | 63 return self; |
| 62 } | 64 } |
| 63 | 65 |
| 64 - (void)dealloc { | 66 - (void)dealloc { |
| 65 _webMain.reset(); | 67 _webMain.reset(); |
| 66 _webMainDelegate.reset(); | 68 _webMainDelegate.reset(); |
| 67 [super dealloc]; | |
| 68 } | 69 } |
| 69 | 70 |
| 70 @end | 71 @end |
| OLD | NEW |