| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CONTENT_PUBLIC_BROWSER_BROWSER_CONTEXT_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_BROWSER_CONTEXT_H_ |
| 6 #define CONTENT_PUBLIC_BROWSER_BROWSER_CONTEXT_H_ | 6 #define CONTENT_PUBLIC_BROWSER_BROWSER_CONTEXT_H_ |
| 7 | 7 |
| 8 #include "base/callback_forward.h" | 8 #include "base/callback_forward.h" |
| 9 #include "base/containers/hash_tables.h" | 9 #include "base/containers/hash_tables.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 | 31 |
| 32 namespace content { | 32 namespace content { |
| 33 | 33 |
| 34 class DownloadManager; | 34 class DownloadManager; |
| 35 class DownloadManagerDelegate; | 35 class DownloadManagerDelegate; |
| 36 class GeolocationPermissionContext; | 36 class GeolocationPermissionContext; |
| 37 class IndexedDBContext; | 37 class IndexedDBContext; |
| 38 class ResourceContext; | 38 class ResourceContext; |
| 39 class SiteInstance; | 39 class SiteInstance; |
| 40 class StoragePartition; | 40 class StoragePartition; |
| 41 struct CookieStoreConfig; | |
| 42 | 41 |
| 43 // This class holds the context needed for a browsing session. | 42 // This class holds the context needed for a browsing session. |
| 44 // It lives on the UI thread. All these methods must only be called on the UI | 43 // It lives on the UI thread. All these methods must only be called on the UI |
| 45 // thread. | 44 // thread. |
| 46 // | |
| 47 // TODO(jam): Pure virtual methods should be converted to ones with empty or | |
| 48 // trivial default implementations. | |
| 49 class CONTENT_EXPORT BrowserContext : public base::SupportsUserData { | 45 class CONTENT_EXPORT BrowserContext : public base::SupportsUserData { |
| 50 public: | 46 public: |
| 51 static DownloadManager* GetDownloadManager(BrowserContext* browser_context); | 47 static DownloadManager* GetDownloadManager(BrowserContext* browser_context); |
| 52 | 48 |
| 53 // Returns BrowserContext specific external mount points. It may return NULL | 49 // Returns BrowserContext specific external mount points. It may return NULL |
| 54 // if the context doesn't have any BrowserContext specific external mount | 50 // if the context doesn't have any BrowserContext specific external mount |
| 55 // points. Currenty, non-NULL value is returned only on ChromeOS. | 51 // points. Currenty, non-NULL value is returned only on ChromeOS. |
| 56 static fileapi::ExternalMountPoints* GetMountPoints(BrowserContext* context); | 52 static fileapi::ExternalMountPoints* GetMountPoints(BrowserContext* context); |
| 57 | 53 |
| 58 static content::StoragePartition* GetStoragePartition( | 54 static content::StoragePartition* GetStoragePartition( |
| 59 BrowserContext* browser_context, SiteInstance* site_instance); | 55 BrowserContext* browser_context, SiteInstance* site_instance); |
| 60 static content::StoragePartition* GetStoragePartitionForSite( | 56 static content::StoragePartition* GetStoragePartitionForSite( |
| 61 BrowserContext* browser_context, const GURL& site); | 57 BrowserContext* browser_context, const GURL& site); |
| 62 typedef base::Callback<void(StoragePartition*)> StoragePartitionCallback; | 58 typedef base::Callback<void(StoragePartition*)> StoragePartitionCallback; |
| 63 static void ForEachStoragePartition( | 59 static void ForEachStoragePartition( |
| 64 BrowserContext* browser_context, | 60 BrowserContext* browser_context, |
| 65 const StoragePartitionCallback& callback); | 61 const StoragePartitionCallback& callback); |
| 66 static void AsyncObliterateStoragePartition( | 62 static void AsyncObliterateStoragePartition( |
| 67 BrowserContext* browser_context, | 63 BrowserContext* browser_context, |
| 68 const GURL& site, | 64 const GURL& site, |
| 69 const base::Closure& on_gc_required); | 65 const base::Closure& on_gc_required); |
| 70 | 66 |
| 71 // This function clears the contents of |active_paths| but does not take | 67 // This function clears the contents of |active_paths| but does not take |
| 72 // ownership of the pointer. | 68 // ownership of the pointer. |
| 73 static void GarbageCollectStoragePartitions( | 69 static void GarbageCollectStoragePartitions( |
| 74 BrowserContext* browser_context, | 70 BrowserContext* browser_context, |
| 75 scoped_ptr<base::hash_set<base::FilePath> > active_paths, | 71 scoped_ptr<base::hash_set<base::FilePath> > active_paths, |
| 76 const base::Closure& done); | 72 const base::Closure& done); |
| 77 | 73 |
| 78 // Prefer GetStoragePartition() or GetStoragePartitionForSite() above. Only | 74 // DON'T USE THIS. GetDefaultStoragePartition() is going away. |
| 79 // use this if it is 100% certain that the cookie store, cache, etc., that | 75 // Use GetStoragePartition() instead. Ask ajwong@ if you have problems. |
| 80 // is returned by this will be the correct one. | |
| 81 static content::StoragePartition* GetDefaultStoragePartition( | 76 static content::StoragePartition* GetDefaultStoragePartition( |
| 82 BrowserContext* browser_context); | 77 BrowserContext* browser_context); |
| 83 | 78 |
| 84 // Ensures that the corresponding ResourceContext is initialized. Normally the | 79 // Ensures that the corresponding ResourceContext is initialized. Normally the |
| 85 // BrowserContext initializs the corresponding getters when its objects are | 80 // BrowserContext initializs the corresponding getters when its objects are |
| 86 // created, but if the embedder wants to pass the ResourceContext to another | 81 // created, but if the embedder wants to pass the ResourceContext to another |
| 87 // thread before they use BrowserContext, they should call this to make sure | 82 // thread before they use BrowserContext, they should call this to make sure |
| 88 // that the ResourceContext is ready. | 83 // that the ResourceContext is ready. |
| 89 static void EnsureResourceContextInitialized(BrowserContext* browser_context); | 84 static void EnsureResourceContextInitialized(BrowserContext* browser_context); |
| 90 | 85 |
| 91 // Tells the HTML5 objects on this context to persist their session state | 86 // Tells the HTML5 objects on this context to persist their session state |
| 92 // across the next restart. | 87 // across the next restart. |
| 93 static void SaveSessionState(BrowserContext* browser_context); | 88 static void SaveSessionState(BrowserContext* browser_context); |
| 94 | 89 |
| 95 // Tells the HTML5 objects on this context to purge any uneeded memory. | 90 // Tells the HTML5 objects on this context to purge any uneeded memory. |
| 96 static void PurgeMemory(BrowserContext* browser_context); | 91 static void PurgeMemory(BrowserContext* browser_context); |
| 97 | 92 |
| 98 virtual ~BrowserContext(); | 93 virtual ~BrowserContext(); |
| 99 | 94 |
| 100 // Returns the path of the directory where this context's data is stored. | 95 // Returns the path of the directory where this context's data is stored. |
| 101 virtual base::FilePath GetPath() const = 0; | 96 virtual base::FilePath GetPath() const = 0; |
| 102 | 97 |
| 103 // Return whether this context is incognito. Default is false. | 98 // Return whether this context is incognito. Default is false. |
| 104 virtual bool IsOffTheRecord() const; | 99 virtual bool IsOffTheRecord() const = 0; |
| 105 | |
| 106 // kDefaultCookieScheme is used in place of a scheme to specify the | |
| 107 // CookieStoreConfig for the http, https, and possibly file scheme. | |
| 108 // | |
| 109 // The http and https scheme must share a single cookie jar in order for | |
| 110 // the web to function properly. The legacy setup also has the file scheme | |
| 111 // share the same cookie jar when file cookies are enabled. | |
| 112 static const char kDefaultCookieScheme[]; | |
| 113 typedef std::map<std::string, CookieStoreConfig> CookieSchemeMap; | |
| 114 | |
| 115 // Allows embedder to change how the Cookie stores are configured. | |
| 116 virtual void OverrideCookieStoreConfigs( | |
| 117 const base::FilePath& partition_path, | |
| 118 bool in_memory_partition, | |
| 119 bool is_default_partition, | |
| 120 CookieSchemeMap* configs) {} | |
| 121 | 100 |
| 122 // Returns the request context information associated with this context. Call | 101 // Returns the request context information associated with this context. Call |
| 123 // this only on the UI thread, since it can send notifications that should | 102 // this only on the UI thread, since it can send notifications that should |
| 124 // happen on the UI thread. | 103 // happen on the UI thread. |
| 125 // TODO(creis): Remove this version in favor of the one below. | 104 // TODO(creis): Remove this version in favor of the one below. |
| 126 virtual net::URLRequestContextGetter* GetRequestContext() = 0; | 105 virtual net::URLRequestContextGetter* GetRequestContext() = 0; |
| 127 | 106 |
| 128 // Returns the request context appropriate for the given renderer. If the | 107 // Returns the request context appropriate for the given renderer. If the |
| 129 // renderer process doesn't have an associated installed app, or if the | 108 // renderer process doesn't have an associated installed app, or if the |
| 130 // installed app doesn't have isolated storage, this is equivalent to calling | 109 // installed app doesn't have isolated storage, this is equivalent to calling |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 struct hash<content::BrowserContext*> { | 160 struct hash<content::BrowserContext*> { |
| 182 std::size_t operator()(content::BrowserContext* const& p) const { | 161 std::size_t operator()(content::BrowserContext* const& p) const { |
| 183 return reinterpret_cast<std::size_t>(p); | 162 return reinterpret_cast<std::size_t>(p); |
| 184 } | 163 } |
| 185 }; | 164 }; |
| 186 | 165 |
| 187 } // namespace BASE_HASH_NAMESPACE | 166 } // namespace BASE_HASH_NAMESPACE |
| 188 #endif | 167 #endif |
| 189 | 168 |
| 190 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_CONTEXT_H_ | 169 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_CONTEXT_H_ |
| OLD | NEW |