Removed 'anonymous' from namespace, added whitespace in thread_restrictions.cc
[chromium-blink-merge.git] / android_webview / browser / aw_browser_context.h
blob053ed6ac3b0c2ab79e748fc645aa9464078852aa
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.
5 #ifndef ANDROID_WEBVIEW_BROWSER_AW_BROWSER_CONTEXT_H_
6 #define ANDROID_WEBVIEW_BROWSER_AW_BROWSER_CONTEXT_H_
8 #include <vector>
10 #include "android_webview/browser/aw_download_manager_delegate.h"
11 #include "android_webview/browser/aw_message_port_service.h"
12 #include "android_webview/browser/aw_ssl_host_state_delegate.h"
13 #include "base/basictypes.h"
14 #include "base/compiler_specific.h"
15 #include "base/files/file_path.h"
16 #include "base/memory/ref_counted.h"
17 #include "base/memory/scoped_ptr.h"
18 #include "components/visitedlink/browser/visitedlink_delegate.h"
19 #include "content/public/browser/browser_context.h"
20 #include "content/public/browser/content_browser_client.h"
21 #include "net/url_request/url_request_job_factory.h"
23 class GURL;
24 class PrefService;
26 namespace content {
27 class PermissionManager;
28 class ResourceContext;
29 class SSLHostStateDelegate;
30 class WebContents;
33 namespace data_reduction_proxy {
34 class DataReductionProxyConfigurator;
35 class DataReductionProxyIOData;
36 class DataReductionProxyService;
37 class DataReductionProxySettings;
40 namespace net {
41 class CookieStore;
44 namespace policy {
45 class URLBlacklistManager;
46 class BrowserPolicyConnectorBase;
49 namespace visitedlink {
50 class VisitedLinkMaster;
53 namespace android_webview {
55 class AwFormDatabaseService;
56 class AwQuotaManagerBridge;
57 class AwURLRequestContextGetter;
58 class JniDependencyFactory;
60 class AwBrowserContext : public content::BrowserContext,
61 public visitedlink::VisitedLinkDelegate {
62 public:
64 AwBrowserContext(const base::FilePath path,
65 JniDependencyFactory* native_factory);
66 ~AwBrowserContext() override;
68 // Currently only one instance per process is supported.
69 static AwBrowserContext* GetDefault();
71 // Convenience method to returns the AwBrowserContext corresponding to the
72 // given WebContents.
73 static AwBrowserContext* FromWebContents(
74 content::WebContents* web_contents);
76 static void SetDataReductionProxyEnabled(bool enabled);
77 static void SetLegacyCacheRemovalDelayForTest(int delay_ms);
79 // Maps to BrowserMainParts::PreMainMessageLoopRun.
80 void PreMainMessageLoopRun();
82 // These methods map to Add methods in visitedlink::VisitedLinkMaster.
83 void AddVisitedURLs(const std::vector<GURL>& urls);
85 net::URLRequestContextGetter* CreateRequestContext(
86 content::ProtocolHandlerMap* protocol_handlers,
87 content::URLRequestInterceptorScopedVector request_interceptors);
88 net::URLRequestContextGetter* CreateRequestContextForStoragePartition(
89 const base::FilePath& partition_path,
90 bool in_memory,
91 content::ProtocolHandlerMap* protocol_handlers,
92 content::URLRequestInterceptorScopedVector request_interceptors);
94 AwQuotaManagerBridge* GetQuotaManagerBridge();
96 AwFormDatabaseService* GetFormDatabaseService();
98 data_reduction_proxy::DataReductionProxySettings*
99 GetDataReductionProxySettings();
101 data_reduction_proxy::DataReductionProxyIOData*
102 GetDataReductionProxyIOData();
104 AwURLRequestContextGetter* GetAwURLRequestContext();
106 AwMessagePortService* GetMessagePortService();
108 policy::URLBlacklistManager* GetURLBlacklistManager();
110 // content::BrowserContext implementation.
111 scoped_ptr<content::ZoomLevelDelegate> CreateZoomLevelDelegate(
112 const base::FilePath& partition_path) override;
113 base::FilePath GetPath() const override;
114 bool IsOffTheRecord() const override;
115 net::URLRequestContextGetter* GetRequestContext() override;
116 net::URLRequestContextGetter* GetRequestContextForRenderProcess(
117 int renderer_child_id) override;
118 net::URLRequestContextGetter* GetMediaRequestContext() override;
119 net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess(
120 int renderer_child_id) override;
121 net::URLRequestContextGetter* GetMediaRequestContextForStoragePartition(
122 const base::FilePath& partition_path,
123 bool in_memory) override;
124 content::ResourceContext* GetResourceContext() override;
125 content::DownloadManagerDelegate* GetDownloadManagerDelegate() override;
126 content::BrowserPluginGuestManager* GetGuestManager() override;
127 storage::SpecialStoragePolicy* GetSpecialStoragePolicy() override;
128 content::PushMessagingService* GetPushMessagingService() override;
129 content::SSLHostStateDelegate* GetSSLHostStateDelegate() override;
130 content::PermissionManager* GetPermissionManager() override;
132 // visitedlink::VisitedLinkDelegate implementation.
133 void RebuildTable(const scoped_refptr<URLEnumerator>& enumerator) override;
135 private:
136 void InitUserPrefService();
137 void CreateDataReductionProxyStatisticsIfNecessary();
138 static bool data_reduction_proxy_enabled_;
140 // Delay, in milliseconds, before removing the legacy cache dir.
141 // This is non-const for testing purposes.
142 static int legacy_cache_removal_delay_ms_;
144 // The file path where data for this context is persisted.
145 base::FilePath context_storage_path_;
147 JniDependencyFactory* native_factory_;
148 scoped_refptr<net::CookieStore> cookie_store_;
149 scoped_refptr<AwURLRequestContextGetter> url_request_context_getter_;
150 scoped_refptr<AwQuotaManagerBridge> quota_manager_bridge_;
151 scoped_ptr<AwFormDatabaseService> form_database_service_;
152 scoped_ptr<AwMessagePortService> message_port_service_;
154 AwDownloadManagerDelegate download_manager_delegate_;
156 scoped_ptr<visitedlink::VisitedLinkMaster> visitedlink_master_;
157 scoped_ptr<content::ResourceContext> resource_context_;
159 scoped_ptr<PrefService> user_pref_service_;
160 scoped_ptr<policy::BrowserPolicyConnectorBase> browser_policy_connector_;
161 scoped_ptr<policy::URLBlacklistManager> blacklist_manager_;
163 scoped_ptr<data_reduction_proxy::DataReductionProxySettings>
164 data_reduction_proxy_settings_;
165 scoped_ptr<AwSSLHostStateDelegate> ssl_host_state_delegate_;
166 scoped_ptr<data_reduction_proxy::DataReductionProxyIOData>
167 data_reduction_proxy_io_data_;
168 scoped_ptr<data_reduction_proxy::DataReductionProxyService>
169 data_reduction_proxy_service_;
170 scoped_ptr<content::PermissionManager> permission_manager_;
172 DISALLOW_COPY_AND_ASSIGN(AwBrowserContext);
175 } // namespace android_webview
177 #endif // ANDROID_WEBVIEW_BROWSER_AW_BROWSER_CONTEXT_H_