Update V8 to version 4.3.57.1 (cherry-pick).
[chromium-blink-merge.git] / android_webview / browser / aw_browser_context.h
blob1e32255be1ae9a6df478d3e33b15675387d6fd4c
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 ResourceContext;
28 class SSLHostStateDelegate;
29 class WebContents;
32 namespace data_reduction_proxy {
33 class DataReductionProxyConfigurator;
34 class DataReductionProxyIOData;
35 class DataReductionProxyService;
36 class DataReductionProxySettings;
39 namespace net {
40 class CookieStore;
43 namespace visitedlink {
44 class VisitedLinkMaster;
47 namespace android_webview {
49 class AwFormDatabaseService;
50 class AwQuotaManagerBridge;
51 class AwURLRequestContextGetter;
52 class JniDependencyFactory;
54 class AwBrowserContext : public content::BrowserContext,
55 public visitedlink::VisitedLinkDelegate {
56 public:
58 AwBrowserContext(const base::FilePath path,
59 JniDependencyFactory* native_factory);
60 ~AwBrowserContext() override;
62 // Currently only one instance per process is supported.
63 static AwBrowserContext* GetDefault();
65 // Convenience method to returns the AwBrowserContext corresponding to the
66 // given WebContents.
67 static AwBrowserContext* FromWebContents(
68 content::WebContents* web_contents);
70 static void SetDataReductionProxyEnabled(bool enabled);
71 static void SetLegacyCacheRemovalDelayForTest(int delay_ms);
73 // Maps to BrowserMainParts::PreMainMessageLoopRun.
74 void PreMainMessageLoopRun();
76 // These methods map to Add methods in visitedlink::VisitedLinkMaster.
77 void AddVisitedURLs(const std::vector<GURL>& urls);
79 net::URLRequestContextGetter* CreateRequestContext(
80 content::ProtocolHandlerMap* protocol_handlers,
81 content::URLRequestInterceptorScopedVector request_interceptors);
82 net::URLRequestContextGetter* CreateRequestContextForStoragePartition(
83 const base::FilePath& partition_path,
84 bool in_memory,
85 content::ProtocolHandlerMap* protocol_handlers,
86 content::URLRequestInterceptorScopedVector request_interceptors);
88 AwQuotaManagerBridge* GetQuotaManagerBridge();
90 AwFormDatabaseService* GetFormDatabaseService();
92 data_reduction_proxy::DataReductionProxySettings*
93 GetDataReductionProxySettings();
95 data_reduction_proxy::DataReductionProxyIOData*
96 GetDataReductionProxyIOData();
98 AwURLRequestContextGetter* GetAwURLRequestContext();
100 void CreateUserPrefServiceIfNecessary();
102 AwMessagePortService* GetMessagePortService();
104 // content::BrowserContext implementation.
105 scoped_ptr<content::ZoomLevelDelegate> CreateZoomLevelDelegate(
106 const base::FilePath& partition_path) override;
107 base::FilePath GetPath() const override;
108 bool IsOffTheRecord() const override;
109 net::URLRequestContextGetter* GetRequestContext() override;
110 net::URLRequestContextGetter* GetRequestContextForRenderProcess(
111 int renderer_child_id) override;
112 net::URLRequestContextGetter* GetMediaRequestContext() override;
113 net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess(
114 int renderer_child_id) override;
115 net::URLRequestContextGetter* GetMediaRequestContextForStoragePartition(
116 const base::FilePath& partition_path,
117 bool in_memory) override;
118 content::ResourceContext* GetResourceContext() override;
119 content::DownloadManagerDelegate* GetDownloadManagerDelegate() override;
120 content::BrowserPluginGuestManager* GetGuestManager() override;
121 storage::SpecialStoragePolicy* GetSpecialStoragePolicy() override;
122 content::PushMessagingService* GetPushMessagingService() override;
123 content::SSLHostStateDelegate* GetSSLHostStateDelegate() override;
125 // visitedlink::VisitedLinkDelegate implementation.
126 void RebuildTable(const scoped_refptr<URLEnumerator>& enumerator) override;
128 private:
129 void CreateDataReductionProxyStatisticsIfNecessary();
130 static bool data_reduction_proxy_enabled_;
132 // Delay, in milliseconds, before removing the legacy cache dir.
133 // This is non-const for testing purposes.
134 static int legacy_cache_removal_delay_ms_;
136 // The file path where data for this context is persisted.
137 base::FilePath context_storage_path_;
139 JniDependencyFactory* native_factory_;
140 scoped_refptr<net::CookieStore> cookie_store_;
141 scoped_refptr<AwURLRequestContextGetter> url_request_context_getter_;
142 scoped_refptr<AwQuotaManagerBridge> quota_manager_bridge_;
143 scoped_ptr<AwFormDatabaseService> form_database_service_;
144 scoped_ptr<AwMessagePortService> message_port_service_;
146 AwDownloadManagerDelegate download_manager_delegate_;
148 scoped_ptr<visitedlink::VisitedLinkMaster> visitedlink_master_;
149 scoped_ptr<content::ResourceContext> resource_context_;
151 scoped_ptr<PrefService> user_pref_service_;
153 scoped_ptr<data_reduction_proxy::DataReductionProxySettings>
154 data_reduction_proxy_settings_;
155 scoped_ptr<AwSSLHostStateDelegate> ssl_host_state_delegate_;
156 scoped_ptr<data_reduction_proxy::DataReductionProxyIOData>
157 data_reduction_proxy_io_data_;
158 scoped_ptr<data_reduction_proxy::DataReductionProxyService>
159 data_reduction_proxy_service_;
161 DISALLOW_COPY_AND_ASSIGN(AwBrowserContext);
164 } // namespace android_webview
166 #endif // ANDROID_WEBVIEW_BROWSER_AW_BROWSER_CONTEXT_H_