| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef IOS_PUBLIC_PROVIDER_CHROME_BROWSER_BROWSER_STATE_CHROME_BROWSER_STATE_H_ | 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_ | 6 #define IOS_PUBLIC_PROVIDER_CHROME_BROWSER_BROWSER_STATE_CHROME_BROWSER_STATE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 // This is a forwarding header to avoid breaking Chrome on iOS downstream |
| 9 #include <string> | 9 // during merge. The header will be removed once all downstream code has |
| 10 | 10 // been ported to use the new path. |
| 11 #include "base/callback_forward.h" | 11 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" |
| 12 #include "base/compiler_specific.h" | |
| 13 #include "base/macros.h" | |
| 14 #include "base/memory/linked_ptr.h" | |
| 15 #include "base/memory/ref_counted.h" | |
| 16 #include "base/memory/scoped_vector.h" | |
| 17 #include "ios/web/public/browser_state.h" | |
| 18 #include "net/url_request/url_request_job_factory.h" | |
| 19 | |
| 20 class ChromeBrowserStateIOData; | |
| 21 class PrefProxyConfigTracker; | |
| 22 class PrefService; | |
| 23 class TestChromeBrowserState; | |
| 24 | |
| 25 namespace base { | |
| 26 class SequencedTaskRunner; | |
| 27 class Time; | |
| 28 } | |
| 29 | |
| 30 namespace net { | |
| 31 class SSLConfigService; | |
| 32 class URLRequestInterceptor; | |
| 33 } | |
| 34 | |
| 35 namespace syncable_prefs { | |
| 36 class PrefServiceSyncable; | |
| 37 } | |
| 38 | |
| 39 namespace web { | |
| 40 class WebUIIOS; | |
| 41 } | |
| 42 | |
| 43 namespace ios { | |
| 44 | |
| 45 enum class ChromeBrowserStateType { | |
| 46 REGULAR_BROWSER_STATE, | |
| 47 INCOGNITO_BROWSER_STATE, | |
| 48 }; | |
| 49 | |
| 50 // This class is a Chrome-specific extension of the BrowserState interface. | |
| 51 class ChromeBrowserState : public web::BrowserState { | |
| 52 public: | |
| 53 ~ChromeBrowserState() override {} | |
| 54 | |
| 55 // Returns the ChromeBrowserState corresponding to the given BrowserState. | |
| 56 static ChromeBrowserState* FromBrowserState(BrowserState* browser_state); | |
| 57 | |
| 58 // Returns the ChromeBrowserState corresponding to the given WebUIIOS. | |
| 59 static ChromeBrowserState* FromWebUIIOS(web::WebUIIOS* web_ui); | |
| 60 | |
| 61 // Returns sequenced task runner where browser state dependent I/O | |
| 62 // operations should be performed. | |
| 63 virtual scoped_refptr<base::SequencedTaskRunner> GetIOTaskRunner() = 0; | |
| 64 | |
| 65 // Returns the original "recording" ChromeBrowserState. This method returns | |
| 66 // |this| if the ChromeBrowserState is not incognito. | |
| 67 virtual ChromeBrowserState* GetOriginalChromeBrowserState() = 0; | |
| 68 | |
| 69 // Returns true if the ChromeBrowserState is off-the-record or if the | |
| 70 // associated off-the-record browser state has been created. | |
| 71 // Calling this method does not create the off-the-record browser state if it | |
| 72 // does not already exist. | |
| 73 virtual bool HasOffTheRecordChromeBrowserState() const = 0; | |
| 74 | |
| 75 // Returns the incognito version of this ChromeBrowserState. The returned | |
| 76 // ChromeBrowserState instance is owned by this ChromeBrowserState instance. | |
| 77 // WARNING: This will create the OffTheRecord ChromeBrowserState if it | |
| 78 // doesn't already exist. | |
| 79 virtual ChromeBrowserState* GetOffTheRecordChromeBrowserState() = 0; | |
| 80 | |
| 81 // Destroys the OffTheRecord ChromeBrowserState that is associated with this | |
| 82 // ChromeBrowserState, if one exists. | |
| 83 virtual void DestroyOffTheRecordChromeBrowserState() = 0; | |
| 84 | |
| 85 // Retrieves a pointer to the PrefService that manages the preferences. | |
| 86 virtual PrefService* GetPrefs() = 0; | |
| 87 | |
| 88 // Retrieves a pointer to the PrefService that manages the preferences | |
| 89 // for OffTheRecord browser states. | |
| 90 virtual PrefService* GetOffTheRecordPrefs() = 0; | |
| 91 | |
| 92 // Allows access to ChromeBrowserStateIOData without going through | |
| 93 // ResourceContext that is not compiled on iOS. This method must be called on | |
| 94 // UI thread, but the returned object must only be accessed on the IO thread. | |
| 95 virtual ChromeBrowserStateIOData* GetIOData() = 0; | |
| 96 | |
| 97 // Retrieves a pointer to the PrefService that manages the preferences as | |
| 98 // a syncable_prefs::PrefServiceSyncable. | |
| 99 virtual syncable_prefs::PrefServiceSyncable* GetSyncablePrefs() = 0; | |
| 100 | |
| 101 // Deletes all network related data since |time|. It deletes transport | |
| 102 // security state since |time| and it also deletes HttpServerProperties data. | |
| 103 // Works asynchronously, however if the |completion| callback is non-null, it | |
| 104 // will be posted on the UI thread once the removal process completes. | |
| 105 // Be aware that theoretically it is possible that |completion| will be | |
| 106 // invoked after the Profile instance has been destroyed. | |
| 107 virtual void ClearNetworkingHistorySince(base::Time time, | |
| 108 const base::Closure& completion) = 0; | |
| 109 | |
| 110 // Returns an identifier of the browser state for debugging. | |
| 111 std::string GetDebugName(); | |
| 112 | |
| 113 // Returns the helper object that provides the proxy configuration service | |
| 114 // access to the the proxy configuration possibly defined by preferences. | |
| 115 virtual PrefProxyConfigTracker* GetProxyConfigTracker() = 0; | |
| 116 | |
| 117 // Returns the SSLConfigService for this browser state. | |
| 118 virtual net::SSLConfigService* GetSSLConfigService() = 0; | |
| 119 | |
| 120 // Creates the main net::URLRequestContextGetter that will be returned by | |
| 121 // GetRequestContext(). Should only be called once. | |
| 122 virtual net::URLRequestContextGetter* CreateRequestContext( | |
| 123 std::map<std::string, | |
| 124 linked_ptr<net::URLRequestJobFactory::ProtocolHandler>>* | |
| 125 protocol_handlers, | |
| 126 ScopedVector<net::URLRequestInterceptor> request_interceptors) = 0; | |
| 127 | |
| 128 // Creates a isolated net::URLRequestContextGetter. Should only be called once | |
| 129 // per partition_path per browser state object. | |
| 130 virtual net::URLRequestContextGetter* CreateIsolatedRequestContext( | |
| 131 const base::FilePath& partition_path) = 0; | |
| 132 | |
| 133 // Returns the current ChromeBrowserState casted as a TestChromeBrowserState | |
| 134 // or null if it is not a TestChromeBrowserState. | |
| 135 virtual TestChromeBrowserState* AsTestChromeBrowserState() = 0; | |
| 136 | |
| 137 protected: | |
| 138 ChromeBrowserState() {} | |
| 139 | |
| 140 private: | |
| 141 DISALLOW_COPY_AND_ASSIGN(ChromeBrowserState); | |
| 142 }; | |
| 143 | |
| 144 } // namespace ios | |
| 145 | 12 |
| 146 #endif // IOS_PUBLIC_PROVIDER_CHROME_BROWSER_BROWSER_STATE_CHROME_BROWSER_STATE
_H_ | 13 #endif // IOS_PUBLIC_PROVIDER_CHROME_BROWSER_BROWSER_STATE_CHROME_BROWSER_STATE
_H_ |
| OLD | NEW |