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

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

Issue 2679003002: Initialize CRIWVWebView with Configuration object instead of browserState. (Closed)
Patch Set: Created 3 years, 10 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_website_data_store.mm
diff --git a/ios/web_view/internal/criwv_website_data_store.mm b/ios/web_view/internal/criwv_website_data_store.mm
new file mode 100644
index 0000000000000000000000000000000000000000..3353d242ee07c62235aa305ca33419752c98c725
--- /dev/null
+++ b/ios/web_view/internal/criwv_website_data_store.mm
@@ -0,0 +1,53 @@
+// Copyright 2017 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/internal/criwv_website_data_store_internal.h"
+
+#include <memory.h>
+
+#include "ios/web_view/internal/criwv_browser_state.h"
+#import "ios/web_view/internal/criwv_web_client.h"
+
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
+@implementation CRIWVWebsiteDataStore
+// Backing storage for |browserState|.
+std::unique_ptr<ios_web_view::CRIWVBrowserState> _browserState;
+
+- (BOOL)isPersistent {
+ return !_browserState->IsOffTheRecord();
+}
+
+- (ios_web_view::CRIWVBrowserState*)browserState {
+ return _browserState.get();
+}
+
+- (void)setBrowserState:
+ (ios_web_view::CRIWVBrowserState* _Nonnull)browserState {
+ _browserState.reset(browserState);
+}
+
++ (instancetype)defaultDataStore {
+ CRIWVWebsiteDataStore* dataStore = [[CRIWVWebsiteDataStore alloc] init];
+
+ ios_web_view::CRIWVWebClient* client =
+ static_cast<ios_web_view::CRIWVWebClient*>(web::GetWebClient());
+ [dataStore setBrowserState:client->browser_state()];
+
+ return dataStore;
+}
+
++ (instancetype)nonPersistentDataStore {
+ CRIWVWebsiteDataStore* dataStore = [[CRIWVWebsiteDataStore alloc] init];
+
+ ios_web_view::CRIWVWebClient* client =
+ static_cast<ios_web_view::CRIWVWebClient*>(web::GetWebClient());
+ [dataStore setBrowserState:client->off_the_record_browser_state()];
+
+ return dataStore;
+}
+
+@end

Powered by Google App Engine
This is Rietveld 408576698