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"
13 class HostContentSettingsMap
;
17 class SequencedTaskRunner
;
26 // This class is a Chrome-specific extension of the BrowserState interface.
27 class ChromeBrowserState
: public web::BrowserState
{
29 ~ChromeBrowserState() override
{}
31 // Returns the ChromeBrowserState corresponding to the given BrowserState.
32 static ChromeBrowserState
* FromBrowserState(BrowserState
* browser_state
);
34 // Returns the ChromeBrowserState corresponding to the given WebUIIOS.
35 static ChromeBrowserState
* FromWebUIIOS(web::WebUIIOS
* web_ui
);
37 // Returns sequenced task runner where browser state dependent I/O
38 // operations should be performed.
39 virtual scoped_refptr
<base::SequencedTaskRunner
> GetIOTaskRunner() = 0;
41 // Returns the original "recording" ChromeBrowserState. This method returns
42 // |this| if the ChromeBrowserState is not incognito.
43 virtual ChromeBrowserState
* GetOriginalChromeBrowserState() = 0;
45 // Returns true if the ChromeBrowserState is off-the-record or if the
46 // associated off-the-record browser state has been created.
47 // Calling this method does not create the off-the-record browser state if it
48 // does not already exist.
49 virtual bool HasOffTheRecordChromeBrowserState() const = 0;
51 // Returns the incognito version of this ChromeBrowserState. The returned
52 // ChromeBrowserState instance is owned by this ChromeBrowserState instance.
53 // WARNING: This will create the OffTheRecord ChromeBrowserState if it
54 // doesn't already exist.
55 virtual ChromeBrowserState
* GetOffTheRecordChromeBrowserState() = 0;
57 // Destroys the OffTheRecord ChromeBrowserState that is associated with this
58 // ChromeBrowserState, if one exists.
59 virtual void DestroyOffTheRecordChromeBrowserState() = 0;
61 // Retrieves a pointer to the PrefService that manages the preferences.
62 virtual PrefService
* GetPrefs() = 0;
64 // Returns the Hostname <-> Content settings map for the ChromeBrowserState.
65 virtual HostContentSettingsMap
* GetHostContentSettingsMap() = 0;
68 ChromeBrowserState() {}
71 DISALLOW_COPY_AND_ASSIGN(ChromeBrowserState
);
76 #endif // IOS_PUBLIC_PROVIDER_CHROME_BROWSER_BROWSER_STATE_CHROME_BROWSER_STATE_H_