Chromium Code Reviews| 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 01568c5ce1ef7b841e4a762581d6c70d9a4b59dd..f29c00200f7f99c04fed224227d111cba1ff0edb 100644 |
| --- a/ios/web_view/internal/cwv_web_view_configuration.mm |
| +++ b/ios/web_view/internal/cwv_web_view_configuration.mm |
| @@ -3,39 +3,70 @@ |
| // found in the LICENSE file. |
| #import "ios/web_view/public/cwv_web_view_configuration.h" |
| +#import "ios/web_view/internal/cwv_web_view_configuration_internal.h" |
| -#import "ios/web_view/public/cwv_website_data_store.h" |
| +#import "ios/web_view/internal/web_view_browser_state.h" |
| +#import "ios/web_view/internal/web_view_web_client.h" |
| #if !defined(__has_feature) || !__has_feature(objc_arc) |
| #error "This file requires ARC support." |
| #endif |
| @interface CWVWebViewConfiguration () |
| -// Initialize configuration with specified data store. |
| -- (instancetype)initWithDataStore:(CWVWebsiteDataStore*)dataStore; |
| +// Initialize configuration with the specified browser state. |
| +- (instancetype)initWithBrowserState: |
| + (ios_web_view::WebViewBrowserState*)browserState; |
| @end |
| -@implementation CWVWebViewConfiguration |
| +@implementation CWVWebViewConfiguration { |
| + // TODO(crbug.com/690182): CWVWebViewConfiguration should own _browserState. |
| + ios_web_view::WebViewBrowserState* _browserState; |
| +} |
| -@synthesize websiteDataStore = _websiteDataStore; |
| ++ (instancetype)defaultConfiguration { |
| + static dispatch_once_t once; |
|
Eugene But (OOO till 7-30)
2017/03/13 21:17:01
In WKWebView these these methods return new object
Hiroshi Ichikawa
2017/03/16 05:38:57
With the current implementation where WebViewMainP
Eugene But (OOO till 7-30)
2017/03/16 16:45:25
Yes, the suggestion is to create a new BrowserStat
|
| + 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()]; |
|
michaeldo
2017/03/13 14:54:02
Please use explicit class name here:
[CWVWebViewC
Eugene But (OOO till 7-30)
2017/03/13 21:17:01
Why? self is better because it respects subclassin
michaeldo
2017/03/13 21:27:58
That's true, |[self alloc]| is preferable. (I miss
|
| + }); |
| + return configuration; |
| +} |
| -- (instancetype)init { |
| - return [self initWithDataStore:[CWVWebsiteDataStore defaultDataStore]]; |
| ++ (instancetype)incognitoConfiguration { |
| + 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] |
|
michaeldo
2017/03/13 14:54:02
Please use explicit class name here:
[CWVWebViewC
michaeldo
2017/03/13 21:27:57
Please ignore, correct as-is.
|
| + initWithBrowserState:client->off_the_record_browser_state()]; |
| + }); |
| + return configuration; |
| } |
| -- (instancetype)initWithDataStore:(CWVWebsiteDataStore*)dataStore { |
| +- (instancetype)initWithBrowserState: |
| + (ios_web_view::WebViewBrowserState*)browserState { |
| self = [super init]; |
| if (self) { |
| - _websiteDataStore = dataStore; |
| + _browserState = browserState; |
| } |
| return self; |
| } |
| +- (BOOL)isPersistent { |
| + return !_browserState->IsOffTheRecord(); |
| +} |
| + |
| +- (ios_web_view::WebViewBrowserState*)browserState { |
| + return _browserState; |
| +} |
| + |
| // NSCopying |
| - (id)copyWithZone:(NSZone*)zone { |
| - return |
| - [[[self class] allocWithZone:zone] initWithDataStore:_websiteDataStore]; |
| + return [[[self class] allocWithZone:zone] initWithBrowserState:_browserState]; |
| } |
| @end |