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

Unified Diff: ios/web_view/internal/cwv_web_view_configuration.mm

Issue 2791403005: Remove CWV class and move setting User Agent to CWVWebViewConfiguration. (Closed)
Patch Set: Remove cwv.h import from Framework header. Created 3 years, 8 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/cwv_web_view_configuration.mm
diff --git a/ios/web_view/internal/cwv_web_view_configuration.mm b/ios/web_view/internal/cwv_web_view_configuration.mm
index d8916d719da520424576cd898b40c9e11e064559..c70240c32586a804763e1bcb21bf551de9c3f2c1 100644
--- a/ios/web_view/internal/cwv_web_view_configuration.mm
+++ b/ios/web_view/internal/cwv_web_view_configuration.mm
@@ -5,9 +5,12 @@
#import "ios/web_view/public/cwv_web_view_configuration.h"
#import "ios/web_view/internal/cwv_web_view_configuration_internal.h"
+#include "base/memory/ptr_util.h"
+#include "ios/web/public/app/web_main.h"
#import "ios/web_view/internal/cwv_user_content_controller_internal.h"
#import "ios/web_view/internal/web_view_browser_state.h"
#import "ios/web_view/internal/web_view_web_client.h"
+#import "ios/web_view/internal/web_view_web_main_delegate.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
@@ -30,9 +33,8 @@
static dispatch_once_t once;
static CWVWebViewConfiguration* configuration;
dispatch_once(&once, ^{
- ios_web_view::WebViewWebClient* client =
- static_cast<ios_web_view::WebViewWebClient*>(web::GetWebClient());
- configuration = [[self alloc] initWithBrowserState:client->browser_state()];
+ configuration =
+ [[self alloc] initWithBrowserState:[self webClient]->browser_state()];
});
return configuration;
}
@@ -41,14 +43,26 @@
static dispatch_once_t once;
static CWVWebViewConfiguration* configuration;
dispatch_once(&once, ^{
- ios_web_view::WebViewWebClient* client =
- static_cast<ios_web_view::WebViewWebClient*>(web::GetWebClient());
configuration = [[self alloc]
- initWithBrowserState:client->off_the_record_browser_state()];
+ initWithBrowserState:[self webClient]->off_the_record_browser_state()];
});
return configuration;
}
++ (ios_web_view::WebViewWebClient*)webClient {
Eugene But (OOO till 7-30) 2017/04/08 00:34:36 This whole method looks awkward, and I think that'
michaeldo 2017/04/11 17:07:48 I was able to fix ownership of BrowserState. WebCl
+ static std::unique_ptr<ios_web_view::WebViewWebMainDelegate> webMainDelegate;
+ static std::unique_ptr<web::WebMain> webMain;
+
+ static dispatch_once_t onceToken;
+ dispatch_once(&onceToken, ^{
+ webMainDelegate = base::MakeUnique<ios_web_view::WebViewWebMainDelegate>();
+ web::WebMainParams params(webMainDelegate.get());
+ webMain = base::MakeUnique<web::WebMain>(params);
+ });
+
+ return static_cast<ios_web_view::WebViewWebClient*>(web::GetWebClient());
Eugene But (OOO till 7-30) 2017/04/08 00:49:57 After giving some thoughts, I this we can avoid ca
michaeldo 2017/04/11 17:07:48 I was able to get rid of the cast by moving webCli
+}
+
- (instancetype)initWithBrowserState:
(ios_web_view::WebViewBrowserState*)browserState {
self = [super init];

Powered by Google App Engine
This is Rietveld 408576698