| 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/cwv.h" | 5 #import "ios/web_view/public/cwv.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/memory/ptr_util.h" |
| 11 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
| 12 #include "ios/web/public/app/web_main.h" | 13 #include "ios/web/public/app/web_main.h" |
| 13 #include "ios/web/public/web_thread.h" | 14 #include "ios/web/public/web_thread.h" |
| 14 #import "ios/web_view/internal/criwv_web_main_delegate.h" | 15 #import "ios/web_view/internal/web_view_web_main_delegate.h" |
| 15 #import "ios/web_view/public/cwv_delegate.h" | 16 #import "ios/web_view/public/cwv_delegate.h" |
| 16 #import "ios/web_view/public/cwv_web_view.h" | 17 #import "ios/web_view/public/cwv_web_view.h" |
| 17 #import "ios/web_view/public/cwv_web_view_configuration.h" | 18 #import "ios/web_view/public/cwv_web_view_configuration.h" |
| 18 #import "ios/web_view/public/cwv_website_data_store.h" | 19 #import "ios/web_view/public/cwv_website_data_store.h" |
| 19 | 20 |
| 20 #if !defined(__has_feature) || !__has_feature(objc_arc) | 21 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 21 #error "This file requires ARC support." | 22 #error "This file requires ARC support." |
| 22 #endif | 23 #endif |
| 23 | 24 |
| 24 namespace { | 25 namespace { |
| 25 CWV* g_criwv = nil; | 26 CWV* g_criwv = nil; |
| 26 } | 27 } |
| 27 | 28 |
| 28 @interface CWV () { | 29 @interface CWV () { |
| 29 std::unique_ptr<ios_web_view::CRIWVWebMainDelegate> _webMainDelegate; | 30 std::unique_ptr<ios_web_view::WebViewWebMainDelegate> _webMainDelegate; |
| 30 std::unique_ptr<web::WebMain> _webMain; | 31 std::unique_ptr<web::WebMain> _webMain; |
| 31 } | 32 } |
| 32 | 33 |
| 33 @property(nonatomic, weak) id<CWVDelegate> delegate; | 34 @property(nonatomic, weak) id<CWVDelegate> delegate; |
| 34 | 35 |
| 35 - (instancetype)initWithDelegate:(id<CWVDelegate>)delegate; | 36 - (instancetype)initWithDelegate:(id<CWVDelegate>)delegate; |
| 36 @end | 37 @end |
| 37 | 38 |
| 38 @implementation CWV | 39 @implementation CWV |
| 39 | 40 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 52 [[CWVWebViewConfiguration alloc] init]; | 53 [[CWVWebViewConfiguration alloc] init]; |
| 53 configuration.websiteDataStore = [CWVWebsiteDataStore defaultDataStore]; | 54 configuration.websiteDataStore = [CWVWebsiteDataStore defaultDataStore]; |
| 54 | 55 |
| 55 return [[CWVWebView alloc] initWithFrame:frame configuration:configuration]; | 56 return [[CWVWebView alloc] initWithFrame:frame configuration:configuration]; |
| 56 } | 57 } |
| 57 | 58 |
| 58 - (instancetype)initWithDelegate:(id<CWVDelegate>)delegate { | 59 - (instancetype)initWithDelegate:(id<CWVDelegate>)delegate { |
| 59 self = [super init]; | 60 self = [super init]; |
| 60 if (self) { | 61 if (self) { |
| 61 _delegate = delegate; | 62 _delegate = delegate; |
| 62 _webMainDelegate.reset(new ios_web_view::CRIWVWebMainDelegate(_delegate)); | 63 _webMainDelegate = |
| 64 base::MakeUnique<ios_web_view::WebViewWebMainDelegate>(_delegate); |
| 63 web::WebMainParams params(_webMainDelegate.get()); | 65 web::WebMainParams params(_webMainDelegate.get()); |
| 64 _webMain.reset(new web::WebMain(params)); | 66 _webMain = base::MakeUnique<web::WebMain>(params); |
| 65 } | 67 } |
| 66 return self; | 68 return self; |
| 67 } | 69 } |
| 68 | 70 |
| 69 - (void)dealloc { | 71 - (void)dealloc { |
| 70 _webMain.reset(); | 72 _webMain.reset(); |
| 71 _webMainDelegate.reset(); | 73 _webMainDelegate.reset(); |
| 72 } | 74 } |
| 73 | 75 |
| 74 @end | 76 @end |
| OLD | NEW |