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