1 // Copyright 2013 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.
5 #ifndef IOS_PUBLIC_PROVIDER_CHROME_BROWSER_BROWSER_STATE_CHROME_BROWSER_STATE_H_
6 #define IOS_PUBLIC_PROVIDER_CHROME_BROWSER_BROWSER_STATE_CHROME_BROWSER_STATE_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/memory/ref_counted.h"
11 #include "ios/web/public/browser_state.h"
16 class SequencedTaskRunner
;
19 namespace syncable_prefs
{
20 class PrefServiceSyncable
;
29 // This class is a Chrome-specific extension of the BrowserState interface.
30 class ChromeBrowserState
: public web::BrowserState
{
32 ~ChromeBrowserState() override
{}
34 // Returns the ChromeBrowserState corresponding to the given BrowserState.
35 static ChromeBrowserState
* FromBrowserState(BrowserState
* browser_state
);
37 // Returns the ChromeBrowserState corresponding to the given WebUIIOS.
38 static ChromeBrowserState
* FromWebUIIOS(web::WebUIIOS
* web_ui
);
40 // Returns sequenced task runner where browser state dependent I/O
41 // operations should be performed.
42 virtual scoped_refptr
<base::SequencedTaskRunner
> GetIOTaskRunner() = 0;
44 // Returns the original "recording" ChromeBrowserState. This method returns
45 // |this| if the ChromeBrowserState is not incognito.
46 virtual ChromeBrowserState
* GetOriginalChromeBrowserState() = 0;
48 // Returns true if the ChromeBrowserState is off-the-record or if the
49 // associated off-the-record browser state has been created.
50 // Calling this method does not create the off-the-record browser state if it
51 // does not already exist.
52 virtual bool HasOffTheRecordChromeBrowserState() const = 0;
54 // Returns the incognito version of this ChromeBrowserState. The returned
55 // ChromeBrowserState instance is owned by this ChromeBrowserState instance.
56 // WARNING: This will create the OffTheRecord ChromeBrowserState if it
57 // doesn't already exist.
58 virtual ChromeBrowserState
* GetOffTheRecordChromeBrowserState() = 0;
60 // Destroys the OffTheRecord ChromeBrowserState that is associated with this
61 // ChromeBrowserState, if one exists.
62 virtual void DestroyOffTheRecordChromeBrowserState() = 0;
64 // Retrieves a pointer to the PrefService that manages the preferences.
65 virtual PrefService
* GetPrefs() = 0;
67 // Retrieves a pointer to the PrefService that manages the preferences as
68 // a syncable_prefs::PrefServiceSyncable.
69 virtual syncable_prefs::PrefServiceSyncable
* GetSyncablePrefs() = 0;
72 ChromeBrowserState() {}
75 DISALLOW_COPY_AND_ASSIGN(ChromeBrowserState
);
80 #endif // IOS_PUBLIC_PROVIDER_CHROME_BROWSER_BROWSER_STATE_CHROME_BROWSER_STATE_H_