[email protected] | f81fa20 | 2012-10-25 23:32:28 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef ANDROID_WEBVIEW_BROWSER_AW_BROWSER_CONTEXT_H_ |
| 6 | #define ANDROID_WEBVIEW_BROWSER_AW_BROWSER_CONTEXT_H_ |
| 7 | |
[email protected] | f2ab1b15 | 2013-01-25 04:38:41 | [diff] [blame] | 8 | #include <vector> |
| 9 | |
[email protected] | c347c436 | 2012-12-05 06:05:31 | [diff] [blame] | 10 | #include "android_webview/browser/aw_download_manager_delegate.h" |
[email protected] | 6bd3007 | 2013-02-08 18:17:11 | [diff] [blame] | 11 | #include "base/basictypes.h" |
| 12 | #include "base/compiler_specific.h" |
[email protected] | f81fa20 | 2012-10-25 23:32:28 | [diff] [blame] | 13 | #include "base/file_path.h" |
| 14 | #include "base/memory/ref_counted.h" |
[email protected] | 6bd3007 | 2013-02-08 18:17:11 | [diff] [blame] | 15 | #include "base/memory/scoped_ptr.h" |
[email protected] | f2ab1b15 | 2013-01-25 04:38:41 | [diff] [blame] | 16 | #include "components/visitedlink/browser/visitedlink_delegate.h" |
[email protected] | c347c436 | 2012-12-05 06:05:31 | [diff] [blame] | 17 | #include "content/public/browser/browser_context.h" |
[email protected] | 4230ed9 | 2013-01-10 05:51:42 | [diff] [blame] | 18 | #include "content/public/browser/geolocation_permission_context.h" |
[email protected] | 6bd3007 | 2013-02-08 18:17:11 | [diff] [blame] | 19 | #include "net/url_request/url_request_job_factory.h" |
[email protected] | f81fa20 | 2012-10-25 23:32:28 | [diff] [blame] | 20 | |
[email protected] | f2ab1b15 | 2013-01-25 04:38:41 | [diff] [blame] | 21 | class GURL; |
| 22 | |
| 23 | namespace components { |
| 24 | class VisitedLinkMaster; |
| 25 | } // namespace components |
| 26 | |
| 27 | namespace content { |
[email protected] | 6bd3007 | 2013-02-08 18:17:11 | [diff] [blame] | 28 | class ResourceContext; |
[email protected] | f2ab1b15 | 2013-01-25 04:38:41 | [diff] [blame] | 29 | class WebContents; |
| 30 | } // namespace content |
| 31 | |
[email protected] | f81fa20 | 2012-10-25 23:32:28 | [diff] [blame] | 32 | namespace android_webview { |
| 33 | |
| 34 | class AwURLRequestContextGetter; |
[email protected] | 2a3a059 | 2013-02-22 18:53:04 | [diff] [blame^] | 35 | class AwQuotaManagerBridge; |
| 36 | class JniDependencyFactory; |
[email protected] | 4230ed9 | 2013-01-10 05:51:42 | [diff] [blame] | 37 | |
[email protected] | f2ab1b15 | 2013-01-25 04:38:41 | [diff] [blame] | 38 | class AwBrowserContext : public content::BrowserContext, |
| 39 | public components::VisitedLinkDelegate { |
[email protected] | f81fa20 | 2012-10-25 23:32:28 | [diff] [blame] | 40 | public: |
[email protected] | f2ab1b15 | 2013-01-25 04:38:41 | [diff] [blame] | 41 | |
[email protected] | 2a3a059 | 2013-02-22 18:53:04 | [diff] [blame^] | 42 | AwBrowserContext(const base::FilePath path, |
| 43 | JniDependencyFactory* native_factory); |
[email protected] | f81fa20 | 2012-10-25 23:32:28 | [diff] [blame] | 44 | virtual ~AwBrowserContext(); |
| 45 | |
[email protected] | f2ab1b15 | 2013-01-25 04:38:41 | [diff] [blame] | 46 | // Convenience method to returns the AwBrowserContext corresponding to the |
| 47 | // given WebContents. |
| 48 | static AwBrowserContext* FromWebContents( |
| 49 | content::WebContents* web_contents); |
| 50 | |
[email protected] | f81fa20 | 2012-10-25 23:32:28 | [diff] [blame] | 51 | // Called before BrowserThreads are created. |
| 52 | void InitializeBeforeThreadCreation(); |
| 53 | |
[email protected] | f2ab1b15 | 2013-01-25 04:38:41 | [diff] [blame] | 54 | // Maps to BrowserMainParts::PreMainMessageLoopRun. |
| 55 | void PreMainMessageLoopRun(); |
| 56 | |
| 57 | // These methods map to Add methods in components::VisitedLinkMaster. |
[email protected] | f2ab1b15 | 2013-01-25 04:38:41 | [diff] [blame] | 58 | void AddVisitedURLs(const std::vector<GURL>& urls); |
| 59 | |
[email protected] | 6bd3007 | 2013-02-08 18:17:11 | [diff] [blame] | 60 | net::URLRequestContextGetter* CreateRequestContext( |
| 61 | scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 62 | blob_protocol_handler, |
| 63 | scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 64 | file_system_protocol_handler, |
| 65 | scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 66 | developer_protocol_handler, |
| 67 | scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 68 | chrome_protocol_handler, |
| 69 | scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 70 | chrome_devtools_protocol_handler); |
| 71 | net::URLRequestContextGetter* CreateRequestContextForStoragePartition( |
[email protected] | 6d4b67a | 2013-02-10 04:49:30 | [diff] [blame] | 72 | const base::FilePath& partition_path, |
[email protected] | 6bd3007 | 2013-02-08 18:17:11 | [diff] [blame] | 73 | bool in_memory, |
| 74 | scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 75 | blob_protocol_handler, |
| 76 | scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 77 | file_system_protocol_handler, |
| 78 | scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 79 | developer_protocol_handler, |
| 80 | scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 81 | chrome_protocol_handler, |
| 82 | scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 83 | chrome_devtools_protocol_handler); |
| 84 | |
[email protected] | 2a3a059 | 2013-02-22 18:53:04 | [diff] [blame^] | 85 | AwQuotaManagerBridge* GetQuotaManagerBridge(); |
| 86 | |
[email protected] | f81fa20 | 2012-10-25 23:32:28 | [diff] [blame] | 87 | // content::BrowserContext implementation. |
[email protected] | 6d4b67a | 2013-02-10 04:49:30 | [diff] [blame] | 88 | virtual base::FilePath GetPath() OVERRIDE; |
[email protected] | f81fa20 | 2012-10-25 23:32:28 | [diff] [blame] | 89 | virtual bool IsOffTheRecord() const OVERRIDE; |
| 90 | virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE; |
| 91 | virtual net::URLRequestContextGetter* GetRequestContextForRenderProcess( |
| 92 | int renderer_child_id) OVERRIDE; |
[email protected] | f81fa20 | 2012-10-25 23:32:28 | [diff] [blame] | 93 | virtual net::URLRequestContextGetter* GetMediaRequestContext() OVERRIDE; |
| 94 | virtual net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess( |
| 95 | int renderer_child_id) OVERRIDE; |
| 96 | virtual net::URLRequestContextGetter* |
| 97 | GetMediaRequestContextForStoragePartition( |
[email protected] | 6d4b67a | 2013-02-10 04:49:30 | [diff] [blame] | 98 | const base::FilePath& partition_path, bool in_memory) OVERRIDE; |
[email protected] | f81fa20 | 2012-10-25 23:32:28 | [diff] [blame] | 99 | virtual content::ResourceContext* GetResourceContext() OVERRIDE; |
| 100 | virtual content::DownloadManagerDelegate* |
| 101 | GetDownloadManagerDelegate() OVERRIDE; |
| 102 | virtual content::GeolocationPermissionContext* |
| 103 | GetGeolocationPermissionContext() OVERRIDE; |
| 104 | virtual content::SpeechRecognitionPreferences* |
| 105 | GetSpeechRecognitionPreferences() OVERRIDE; |
| 106 | virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE; |
| 107 | |
[email protected] | f2ab1b15 | 2013-01-25 04:38:41 | [diff] [blame] | 108 | // components::VisitedLinkDelegate implementation. |
| 109 | virtual void RebuildTable( |
| 110 | const scoped_refptr<URLEnumerator>& enumerator) OVERRIDE; |
| 111 | |
[email protected] | f81fa20 | 2012-10-25 23:32:28 | [diff] [blame] | 112 | private: |
[email protected] | f81fa20 | 2012-10-25 23:32:28 | [diff] [blame] | 113 | // The file path where data for this context is persisted. |
[email protected] | 6d4b67a | 2013-02-10 04:49:30 | [diff] [blame] | 114 | base::FilePath context_storage_path_; |
[email protected] | f81fa20 | 2012-10-25 23:32:28 | [diff] [blame] | 115 | |
[email protected] | 2a3a059 | 2013-02-22 18:53:04 | [diff] [blame^] | 116 | JniDependencyFactory* native_factory_; |
[email protected] | f81fa20 | 2012-10-25 23:32:28 | [diff] [blame] | 117 | scoped_refptr<AwURLRequestContextGetter> url_request_context_getter_; |
[email protected] | 4230ed9 | 2013-01-10 05:51:42 | [diff] [blame] | 118 | scoped_refptr<content::GeolocationPermissionContext> |
| 119 | geolocation_permission_context_; |
[email protected] | 2a3a059 | 2013-02-22 18:53:04 | [diff] [blame^] | 120 | scoped_ptr<AwQuotaManagerBridge> quota_manager_bridge_; |
[email protected] | f81fa20 | 2012-10-25 23:32:28 | [diff] [blame] | 121 | |
[email protected] | c347c436 | 2012-12-05 06:05:31 | [diff] [blame] | 122 | AwDownloadManagerDelegate download_manager_delegate_; |
| 123 | |
[email protected] | f2ab1b15 | 2013-01-25 04:38:41 | [diff] [blame] | 124 | scoped_ptr<components::VisitedLinkMaster> visitedlink_master_; |
[email protected] | 6bd3007 | 2013-02-08 18:17:11 | [diff] [blame] | 125 | scoped_ptr<content::ResourceContext> resource_context_; |
[email protected] | f2ab1b15 | 2013-01-25 04:38:41 | [diff] [blame] | 126 | |
[email protected] | f81fa20 | 2012-10-25 23:32:28 | [diff] [blame] | 127 | DISALLOW_COPY_AND_ASSIGN(AwBrowserContext); |
| 128 | }; |
| 129 | |
| 130 | } // namespace android_webview |
| 131 | |
| 132 | #endif // ANDROID_WEBVIEW_BROWSER_AW_BROWSER_CONTEXT_H_ |