OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #ifndef IOS_CHROME_BROWSER_BROWSER_STATE_CHROME_BROWSER_STATE_IMPL_ |
| 6 #define IOS_CHROME_BROWSER_BROWSER_STATE_CHROME_BROWSER_STATE_IMPL_ |
| 7 |
| 8 #include "base/macros.h" |
| 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" |
| 11 #include "ios/chrome/browser/browser_state/chrome_browser_state_impl_io_data.h" |
| 12 |
| 13 namespace ssl_config { |
| 14 class SSLConfigServiceManager; |
| 15 } |
| 16 |
| 17 namespace syncable_prefs { |
| 18 class PrefServiceSyncable; |
| 19 } |
| 20 |
| 21 namespace user_prefs { |
| 22 class PrefRegistrySyncable; |
| 23 } |
| 24 |
| 25 class PrefProxyConfigTracker; |
| 26 |
| 27 // This class is the implementation of ChromeBrowserState used for |
| 28 // non-incognito browsing. |
| 29 class ChromeBrowserStateImpl : public ios::ChromeBrowserState { |
| 30 public: |
| 31 ~ChromeBrowserStateImpl() override; |
| 32 |
| 33 // ChromeBrowserState: |
| 34 ios::ChromeBrowserState* GetOriginalChromeBrowserState() override; |
| 35 bool HasOffTheRecordChromeBrowserState() const override; |
| 36 ios::ChromeBrowserState* GetOffTheRecordChromeBrowserState() override; |
| 37 void DestroyOffTheRecordChromeBrowserState() override; |
| 38 PrefProxyConfigTracker* GetProxyConfigTracker() override; |
| 39 net::SSLConfigService* GetSSLConfigService() override; |
| 40 PrefService* GetPrefs() override; |
| 41 PrefService* GetOffTheRecordPrefs() override; |
| 42 ChromeBrowserStateIOData* GetIOData() override; |
| 43 void ClearNetworkingHistorySince(base::Time time, |
| 44 const base::Closure& completion) override; |
| 45 net::URLRequestContextGetter* CreateRequestContext( |
| 46 ProtocolHandlerMap* protocol_handlers, |
| 47 URLRequestInterceptorScopedVector request_interceptors) override; |
| 48 net::URLRequestContextGetter* CreateIsolatedRequestContext( |
| 49 const base::FilePath& partition_path) override; |
| 50 |
| 51 // BrowserState: |
| 52 bool IsOffTheRecord() const override; |
| 53 base::FilePath GetStatePath() const override; |
| 54 |
| 55 private: |
| 56 friend class ChromeBrowserStateManagerImpl; |
| 57 |
| 58 explicit ChromeBrowserStateImpl(const base::FilePath& path); |
| 59 |
| 60 // Sets the OffTheRecordChromeBrowserState. |
| 61 void SetOffTheRecordChromeBrowserState( |
| 62 scoped_ptr<ios::ChromeBrowserState> otr_state); |
| 63 |
| 64 base::FilePath state_path_; |
| 65 |
| 66 // The incognito ChromeBrowserState instance that is associated with this |
| 67 // ChromeBrowserState instance. NULL if |GetOffTheRecordChromeBrowserState()| |
| 68 // has never been called or has not been called since |
| 69 // |DestroyOffTheRecordChromeBrowserState()|. |
| 70 scoped_ptr<ios::ChromeBrowserState> otr_state_; |
| 71 base::FilePath otr_state_path_; |
| 72 |
| 73 // !!! BIG HONKING WARNING !!! |
| 74 // The order of the members below is important. Do not change it unless |
| 75 // you know what you're doing. Also, if adding a new member here make sure |
| 76 // that the declaration occurs AFTER things it depends on as destruction |
| 77 // happens in reverse order of declaration. |
| 78 |
| 79 // Keep |prefs_| on top for destruction order because |io_data_| and others |
| 80 // store pointers to |prefs_| and shall be destructed first. |
| 81 scoped_refptr<user_prefs::PrefRegistrySyncable> pref_registry_; |
| 82 scoped_ptr<syncable_prefs::PrefServiceSyncable> prefs_; |
| 83 scoped_ptr<syncable_prefs::PrefServiceSyncable> otr_prefs_; |
| 84 scoped_ptr<ChromeBrowserStateImplIOData::Handle> io_data_; |
| 85 |
| 86 scoped_ptr<PrefProxyConfigTracker> pref_proxy_config_tracker_; |
| 87 scoped_ptr<ssl_config::SSLConfigServiceManager> ssl_config_service_manager_; |
| 88 |
| 89 // STOP!!!! DO NOT ADD ANY MORE ITEMS HERE!!!! |
| 90 // |
| 91 // Instead, make your Service/Manager/whatever object you're hanging off the |
| 92 // BrowserState use our BrowserStateKeyedServiceFactory system instead. |
| 93 // You can find the design document here: |
| 94 // |
| 95 // https://sites.google.com/a/chromium.org/dev/developers/design-documents/p
rofile-architecture |
| 96 // |
| 97 // and you can read the raw headers here: |
| 98 // |
| 99 // components/keyed_service/ios/browser_state_dependency_manager.* |
| 100 // components/keyed_service/core/keyed_service.h |
| 101 // components/keyed_service/ios/browser_state_keyed_service_factory.* |
| 102 |
| 103 DISALLOW_COPY_AND_ASSIGN(ChromeBrowserStateImpl); |
| 104 }; |
| 105 |
| 106 #endif // IOS_CHROME_BROWSER_BROWSER_STATE_CHROME_BROWSER_STATE_IMPL_ |
OLD | NEW |