Fix crash on app list start page contents not existing.
[chromium-blink-merge.git] / ios / web / public / browser_state.h
blob0a3c1311396cf4699c03d2f2bf57c317b9820f63
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_WEB_PUBLIC_BROWSER_STATE_H_
6 #define IOS_WEB_PUBLIC_BROWSER_STATE_H_
8 #include "base/supports_user_data.h"
10 namespace base {
11 class FilePath;
14 namespace net {
15 class URLRequestContextGetter;
18 namespace web {
20 // This class holds the context needed for a browsing session.
21 // It lives on the UI thread. All these methods must only be called on the UI
22 // thread.
23 class BrowserState : public base::SupportsUserData {
24 public:
25 ~BrowserState() override;
27 // Returns whether this BrowserState is incognito. Default is false.
28 virtual bool IsOffTheRecord() const = 0;
30 // Returns the path where the BrowserState data is stored.
31 virtual base::FilePath GetPath() const = 0;
33 // Returns the request context information associated with this
34 // BrowserState.
35 virtual net::URLRequestContextGetter* GetRequestContext() = 0;
37 // Safely cast a base::SupportsUserData to a BrowserState. Returns nullptr
38 // if |supports_user_data| is not a BrowserState.
39 static BrowserState* FromSupportsUserData(
40 base::SupportsUserData* supports_user_data);
42 protected:
43 BrowserState();
46 } // namespace web
48 #endif // IOS_WEB_PUBLIC_BROWSER_STATE_H_