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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: ios/web_view/internal/criwv.mm
diff --git a/ios/web_view/internal/criwv.mm b/ios/web_view/internal/criwv.mm
new file mode 100644
index 0000000000000000000000000000000000000000..f4a4093349eaffea38ee265eb964db4bf6ce1d9d
--- /dev/null
+++ b/ios/web_view/internal/criwv.mm
@@ -0,0 +1,73 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import "ios/web_view/public/criwv.h"
+
+#include <memory>
+
+#include "base/location.h"
+#import "base/mac/bind_objc_block.h"
+#include "base/single_thread_task_runner.h"
+#include "ios/web/public/app/web_main.h"
+#include "ios/web/public/web_thread.h"
+#include "ios/web_view/internal/criwv_browser_state.h"
+#import "ios/web_view/internal/criwv_web_client.h"
+#import "ios/web_view/internal/criwv_web_main_delegate.h"
+#import "ios/web_view/internal/criwv_web_view_impl.h"
+#import "ios/web_view/public/criwv_delegate.h"
+
+namespace {
+CRIWV* g_criwv = nil;
+}
+
+@interface CRIWV () {
+ id<CRIWVDelegate> _delegate;
+ std::unique_ptr<ios_web_view::CRIWVWebMainDelegate> _webMainDelegate;
+ std::unique_ptr<web::WebMain> _webMain;
+}
+
+- (instancetype)initWithDelegate:(id<CRIWVDelegate>)delegate;
+- (ios_web_view::CRIWVBrowserState*)browserState;
+@end
+
+@implementation CRIWV
+
++ (void)configureWithDelegate:(id<CRIWVDelegate>)delegate {
+ g_criwv = [[CRIWV alloc] initWithDelegate:delegate];
+}
+
++ (void)shutDown {
+ [g_criwv release];
+ g_criwv = nil;
+}
+
++ (id<CRIWVWebView>)webView {
+ return [[[CRIWVWebViewImpl alloc] initWithBrowserState:[g_criwv browserState]]
+ autorelease];
+}
+
+- (instancetype)initWithDelegate:(id<CRIWVDelegate>)delegate {
+ self = [super init];
+ if (self) {
+ _delegate = delegate;
+ _webMainDelegate.reset(new ios_web_view::CRIWVWebMainDelegate(_delegate));
+ web::WebMainParams params(_webMainDelegate.get());
+ _webMain.reset(new web::WebMain(params));
+ }
+ return self;
+}
+
+- (void)dealloc {
+ _webMain.reset();
+ _webMainDelegate.reset();
+ [super dealloc];
+}
+
+- (ios_web_view::CRIWVBrowserState*)browserState {
+ ios_web_view::CRIWVWebClient* client =
+ static_cast<ios_web_view::CRIWVWebClient*>(web::GetWebClient());
+ return client->browser_state();
+}
+
+@end

Powered by Google App Engine
This is Rietveld 408576698