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 #include "ios/web_view/internal/criwv_browser_state.h" | |
| 15 #import "ios/web_view/internal/criwv_web_client.h" | |
| 16 #import "ios/web_view/internal/criwv_web_main_delegate.h" | 14 #import "ios/web_view/internal/criwv_web_main_delegate.h" |
| 17 #import "ios/web_view/internal/criwv_web_view_internal.h" | 15 #import "ios/web_view/internal/criwv_web_view_internal.h" |
| 18 #import "ios/web_view/public/criwv_delegate.h" | 16 #import "ios/web_view/public/criwv_delegate.h" |
| 17 #import "ios/web_view/public/criwv_web_view_configuration.h" | |
| 18 #import "ios/web_view/public/criwv_website_data_store.h" | |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 CRIWV* g_criwv = nil; | 21 CRIWV* g_criwv = nil; |
| 22 } | 22 } |
| 23 | 23 |
| 24 @interface CRIWV () { | 24 @interface CRIWV () { |
| 25 id<CRIWVDelegate> _delegate; | 25 id<CRIWVDelegate> _delegate; |
| 26 std::unique_ptr<ios_web_view::CRIWVWebMainDelegate> _webMainDelegate; | 26 std::unique_ptr<ios_web_view::CRIWVWebMainDelegate> _webMainDelegate; |
| 27 std::unique_ptr<web::WebMain> _webMain; | 27 std::unique_ptr<web::WebMain> _webMain; |
| 28 } | 28 } |
| 29 | 29 |
| 30 - (instancetype)initWithDelegate:(id<CRIWVDelegate>)delegate; | 30 - (instancetype)initWithDelegate:(id<CRIWVDelegate>)delegate; |
| 31 - (ios_web_view::CRIWVBrowserState*)browserState; | |
| 32 @end | 31 @end |
| 33 | 32 |
| 34 @implementation CRIWV | 33 @implementation CRIWV |
| 35 | 34 |
| 36 + (void)configureWithDelegate:(id<CRIWVDelegate>)delegate { | 35 + (void)configureWithDelegate:(id<CRIWVDelegate>)delegate { |
| 37 g_criwv = [[CRIWV alloc] initWithDelegate:delegate]; | 36 g_criwv = [[CRIWV alloc] initWithDelegate:delegate]; |
| 38 } | 37 } |
| 39 | 38 |
| 40 + (void)shutDown { | 39 + (void)shutDown { |
| 41 [g_criwv release]; | 40 [g_criwv release]; |
| 42 g_criwv = nil; | 41 g_criwv = nil; |
| 43 } | 42 } |
| 44 | 43 |
| 45 + (CRIWVWebView*)webViewWithFrame:(CGRect)frame { | 44 + (CRIWVWebView*)webViewWithFrame:(CGRect)frame { |
|
Eugene But (OOO till 7-30)
2017/02/06 23:31:56
I assume we going to remove this method. Right?
michaeldo
2017/02/06 23:53:49
Yes, we will, I just didn't want this CL to get to
| |
| 46 return | 45 CRIWVWebViewConfiguration* configuration = |
| 47 [[[CRIWVWebView alloc] initWithFrame:frame | 46 [[CRIWVWebViewConfiguration alloc] init]; |
| 48 browserState:[g_criwv browserState]] autorelease]; | 47 configuration.websiteDataStore = [CRIWVWebsiteDataStore defaultDataStore]; |
| 48 | |
| 49 return [[[CRIWVWebView alloc] initWithFrame:frame configuration:configuration] | |
| 50 autorelease]; | |
| 49 } | 51 } |
| 50 | 52 |
| 51 - (instancetype)initWithDelegate:(id<CRIWVDelegate>)delegate { | 53 - (instancetype)initWithDelegate:(id<CRIWVDelegate>)delegate { |
| 52 self = [super init]; | 54 self = [super init]; |
| 53 if (self) { | 55 if (self) { |
| 54 _delegate = delegate; | 56 _delegate = delegate; |
| 55 _webMainDelegate.reset(new ios_web_view::CRIWVWebMainDelegate(_delegate)); | 57 _webMainDelegate.reset(new ios_web_view::CRIWVWebMainDelegate(_delegate)); |
| 56 web::WebMainParams params(_webMainDelegate.get()); | 58 web::WebMainParams params(_webMainDelegate.get()); |
| 57 _webMain.reset(new web::WebMain(params)); | 59 _webMain.reset(new web::WebMain(params)); |
| 58 } | 60 } |
| 59 return self; | 61 return self; |
| 60 } | 62 } |
| 61 | 63 |
| 62 - (void)dealloc { | 64 - (void)dealloc { |
| 63 _webMain.reset(); | 65 _webMain.reset(); |
| 64 _webMainDelegate.reset(); | 66 _webMainDelegate.reset(); |
| 65 [super dealloc]; | 67 [super dealloc]; |
| 66 } | 68 } |
| 67 | 69 |
| 68 - (ios_web_view::CRIWVBrowserState*)browserState { | |
| 69 ios_web_view::CRIWVWebClient* client = | |
| 70 static_cast<ios_web_view::CRIWVWebClient*>(web::GetWebClient()); | |
| 71 return client->browser_state(); | |
| 72 } | |
| 73 | |
| 74 @end | 70 @end |
| OLD | NEW |