| 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;
|
| + 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()];
|
| + });
|
| + 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]
|
| + 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
|
|
|