| OLD | NEW |
| (Empty) |
| 1 // Copyright 2017 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/internal/cwv_website_data_store_internal.h" | |
| 6 | |
| 7 #include <memory.h> | |
| 8 | |
| 9 #include "ios/web_view/internal/web_view_browser_state.h" | |
| 10 #import "ios/web_view/internal/web_view_web_client.h" | |
| 11 | |
| 12 #if !defined(__has_feature) || !__has_feature(objc_arc) | |
| 13 #error "This file requires ARC support." | |
| 14 #endif | |
| 15 | |
| 16 @implementation CWVWebsiteDataStore { | |
| 17 // TODO(crbug.com/690182): CWVWebsiteDataStore should own _browserState. | |
| 18 ios_web_view::WebViewBrowserState* _browserState; | |
| 19 } | |
| 20 | |
| 21 - (BOOL)isPersistent { | |
| 22 return !_browserState->IsOffTheRecord(); | |
| 23 } | |
| 24 | |
| 25 - (ios_web_view::WebViewBrowserState*)browserState { | |
| 26 return _browserState; | |
| 27 } | |
| 28 | |
| 29 - (void)setBrowserState: | |
| 30 (ios_web_view::WebViewBrowserState* _Nonnull)browserState { | |
| 31 _browserState = browserState; | |
| 32 } | |
| 33 | |
| 34 + (instancetype)defaultDataStore { | |
| 35 CWVWebsiteDataStore* dataStore = [[CWVWebsiteDataStore alloc] init]; | |
| 36 | |
| 37 ios_web_view::WebViewWebClient* client = | |
| 38 static_cast<ios_web_view::WebViewWebClient*>(web::GetWebClient()); | |
| 39 [dataStore setBrowserState:client->browser_state()]; | |
| 40 | |
| 41 return dataStore; | |
| 42 } | |
| 43 | |
| 44 + (instancetype)nonPersistentDataStore { | |
| 45 CWVWebsiteDataStore* dataStore = [[CWVWebsiteDataStore alloc] init]; | |
| 46 | |
| 47 ios_web_view::WebViewWebClient* client = | |
| 48 static_cast<ios_web_view::WebViewWebClient*>(web::GetWebClient()); | |
| 49 [dataStore setBrowserState:client->off_the_record_browser_state()]; | |
| 50 | |
| 51 return dataStore; | |
| 52 } | |
| 53 | |
| 54 @end | |
| OLD | NEW |