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

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

Issue 2643773005: Upstream ios/web_view source code. (Closed)
Patch Set: Remove request tracker and fix pointer to CRIWVWebMainParts. Created 3 years, 11 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #import "ios/web_view/public/criwv.h"
6
7 #include <memory>
8
9 #include "base/location.h"
10 #import "base/mac/bind_objc_block.h"
11 #include "base/single_thread_task_runner.h"
12 #include "ios/web/public/app/web_main.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"
17 #import "ios/web_view/internal/criwv_web_view_impl.h"
18 #import "ios/web_view/public/criwv_delegate.h"
19
20 namespace {
21 CRIWV* g_criwv = nil;
22 }
23
24 @interface CRIWV () {
25 id<CRIWVDelegate> _delegate;
26 std::unique_ptr<ios_web_view::CRIWVWebMainDelegate> _webMainDelegate;
27 std::unique_ptr<web::WebMain> _webMain;
28 }
29
30 - (instancetype)initWithDelegate:(id<CRIWVDelegate>)delegate;
31 - (ios_web_view::CRIWVBrowserState*)browserState;
32 @end
33
34 @implementation CRIWV
35
36 + (void)configureWithDelegate:(id<CRIWVDelegate>)delegate {
37 g_criwv = [[CRIWV alloc] initWithDelegate:delegate];
38 }
39
40 + (void)shutDown {
41 [g_criwv release];
42 g_criwv = nil;
43 }
44
45 + (id<CRIWVWebView>)webView {
46 return [[[CRIWVWebViewImpl alloc] initWithBrowserState:[g_criwv browserState]]
47 autorelease];
48 }
49
50 - (instancetype)initWithDelegate:(id<CRIWVDelegate>)delegate {
51 self = [super init];
52 if (self) {
53 _delegate = delegate;
54 _webMainDelegate.reset(new ios_web_view::CRIWVWebMainDelegate(_delegate));
55 web::WebMainParams params(_webMainDelegate.get());
56 _webMain.reset(new web::WebMain(params));
57 }
58 return self;
59 }
60
61 - (void)dealloc {
62 _webMain.reset();
63 _webMainDelegate.reset();
64 [super dealloc];
65 }
66
67 - (ios_web_view::CRIWVBrowserState*)browserState {
68 ios_web_view::CRIWVWebClient* client =
69 static_cast<ios_web_view::CRIWVWebClient*>(web::GetWebClient());
70 return client->browser_state();
71 }
72
73 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698