summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsdefresne <sdefresne@chromium.org>2014-12-02 02:41:31 -0800
committerCommit bot <commit-bot@chromium.org>2014-12-02 10:41:52 +0000
commitd33ce990fed3926195cba037e09cdef2e5693796 (patch)
tree7a4ed0fb99614de71f6966fe5bfb476f9879028a
parent8e5e03533929cf41c852a02ade3104433f8fbcba (diff)
downloadchromium_src-d33ce990fed3926195cba037e09cdef2e5693796.zip
chromium_src-d33ce990fed3926195cba037e09cdef2e5693796.tar.gz
chromium_src-d33ce990fed3926195cba037e09cdef2e5693796.tar.bz2
Introduce ChromeBrowserState interface
The ChromeBrowserState interface will serve as iOS's alternative to Profile. BUG=436897 Review URL: https://codereview.chromium.org/748853005 Cr-Commit-Position: refs/heads/master@{#306357}
-rw-r--r--ios/ios.gyp1
-rw-r--r--ios/provider/ios_provider_chrome.gyp22
-rw-r--r--ios/public/provider/chrome/browser/DEPS3
-rw-r--r--ios/public/provider/chrome/browser/browser_state/chrome_browser_state.cc18
-rw-r--r--ios/public/provider/chrome/browser/browser_state/chrome_browser_state.h50
5 files changed, 94 insertions, 0 deletions
diff --git a/ios/ios.gyp b/ios/ios.gyp
index 81bda61..23c62c8 100644
--- a/ios/ios.gyp
+++ b/ios/ios.gyp
@@ -12,6 +12,7 @@
'dependencies': [
'ios_base.gyp:*',
'ios_tests_unit.gyp:*',
+ 'provider/ios_provider_chrome.gyp:*',
'provider/ios_provider_web.gyp:*',
'web/ios_web.gyp:*',
],
diff --git a/ios/provider/ios_provider_chrome.gyp b/ios/provider/ios_provider_chrome.gyp
new file mode 100644
index 0000000..eb8e1f1
--- /dev/null
+++ b/ios/provider/ios_provider_chrome.gyp
@@ -0,0 +1,22 @@
+# Copyright 2013 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.
+{
+ 'variables': {
+ 'chromium_code': 1,
+ },
+ 'targets': [
+ {
+ 'target_name': 'ios_provider_chrome_browser',
+ 'type': 'static_library',
+ 'sources': [
+ '../public/provider/chrome/browser/browser_state/chrome_browser_state.cc',
+ '../public/provider/chrome/browser/browser_state/chrome_browser_state.h',
+ ],
+ 'dependencies': [
+ '../../base/base.gyp:base',
+ 'ios_provider_web.gyp:ios_provider_web',
+ ],
+ },
+ ],
+}
diff --git a/ios/public/provider/chrome/browser/DEPS b/ios/public/provider/chrome/browser/DEPS
new file mode 100644
index 0000000..41a04b1
--- /dev/null
+++ b/ios/public/provider/chrome/browser/DEPS
@@ -0,0 +1,3 @@
+include_rules = [
+ "+ios/public/provider/web",
+]
diff --git a/ios/public/provider/chrome/browser/browser_state/chrome_browser_state.cc b/ios/public/provider/chrome/browser/browser_state/chrome_browser_state.cc
new file mode 100644
index 0000000..fc8f705
--- /dev/null
+++ b/ios/public/provider/chrome/browser/browser_state/chrome_browser_state.cc
@@ -0,0 +1,18 @@
+// Copyright 2014 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.
+
+#include "ios/public/provider/chrome/browser/browser_state/chrome_browser_state.h"
+
+#include "ios/public/provider/web/web_state.h"
+
+namespace ios {
+
+// static
+ChromeBrowserState* ChromeBrowserState::FromBrowserState(
+ web::BrowserState* browser_state) {
+ // This is safe; this is the only implementation of BrowserState.
+ return static_cast<ChromeBrowserState*>(browser_state);
+}
+
+} // namespace ios
diff --git a/ios/public/provider/chrome/browser/browser_state/chrome_browser_state.h b/ios/public/provider/chrome/browser/browser_state/chrome_browser_state.h
new file mode 100644
index 0000000..781bb93
--- /dev/null
+++ b/ios/public/provider/chrome/browser/browser_state/chrome_browser_state.h
@@ -0,0 +1,50 @@
+// Copyright 2013 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.
+
+#ifndef IOS_PUBLIC_PROVIDER_CHROME_BROWSER_BROWSER_STATE_CHROME_BROWSER_STATE_H_
+#define IOS_PUBLIC_PROVIDER_CHROME_BROWSER_BROWSER_STATE_CHROME_BROWSER_STATE_H_
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "ios/web/public/browser_state.h"
+
+class PrefService;
+
+namespace ios {
+
+// This class is a Chrome-specific extension of the BrowserState interface.
+class ChromeBrowserState : public web::BrowserState {
+ public:
+ ~ChromeBrowserState() override {}
+
+ // Returns the ChromeBrowserState corresponding to the given BrowserState.
+ static ChromeBrowserState* FromBrowserState(BrowserState* browser_state);
+
+ // Returns the original "recording" ChromeBrowserState. This method returns
+ // |this| if the ChromeBrowserState is not incognito.
+ virtual ChromeBrowserState* GetOriginalChromeBrowserState() = 0;
+
+ // Returns the incognito version of this ChromeBrowserState. The returned
+ // ChromeBrowserState instance is owned by this ChromeBrowserState instance.
+ // WARNING: This will create the OffTheRecord ChromeBrowserState if it
+ // doesn't already exist.
+ virtual ChromeBrowserState* GetOffTheRecordChromeBrowserState() = 0;
+
+ // Destroys the OffTheRecord ChromeBrowserState that is associated with this
+ // ChromeBrowserState, if one exists.
+ virtual void DestroyOffTheRecordChromeBrowserState() = 0;
+
+ // Retrieves a pointer to the PrefService that manages the preferences.
+ virtual PrefService* GetPrefs() = 0;
+
+ protected:
+ ChromeBrowserState() {}
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ChromeBrowserState);
+};
+
+} // namespace ios
+
+#endif // IOS_PUBLIC_PROVIDER_CHROME_BROWSER_BROWSER_STATE_CHROME_BROWSER_STATE_H_