forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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}
- Loading branch information
Showing
5 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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', | ||
], | ||
}, | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
include_rules = [ | ||
"+ios/public/provider/web", | ||
] |
18 changes: 18 additions & 0 deletions
18
ios/public/provider/chrome/browser/browser_state/chrome_browser_state.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
50 changes: 50 additions & 0 deletions
50
ios/public/provider/chrome/browser/browser_state/chrome_browser_state.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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_ |