Revert "Fix broken channel icon in chrome://help on CrOS" and try again
[chromium-blink-merge.git] / android_webview / browser / aw_browser_context.h
blob687ae53fed3f22f84c39b4f1474dd417f2999d3a
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 visitedlink {
45 class VisitedLinkMaster;
48 namespace android_webview {
50 class AwFormDatabaseService;
51 class AwQuotaManagerBridge;
52 class AwURLRequestContextGetter;
53 class JniDependencyFactory;
55 class AwBrowserContext : public content::BrowserContext,
56 public visitedlink::VisitedLinkDelegate {
57 public:
59 AwBrowserContext(const base::FilePath path,
60 JniDependencyFactory* native_factory);
61 ~AwBrowserContext() override;
63 // Currently only one instance per process is supported.
64 static AwBrowserContext* GetDefault();
66 // Convenience method to returns the AwBrowserContext corresponding to the
67 // given WebContents.
68 static AwBrowserContext* FromWebContents(
69 content::WebContents* web_contents);
71 static void SetDataReductionProxyEnabled(bool enabled);
72 static void SetLegacyCacheRemovalDelayForTest(int delay_ms);
74 // Maps to BrowserMainParts::PreMainMessageLoopRun.
75 void PreMainMessageLoopRun();
77 // These methods map to Add methods in visitedlink::VisitedLinkMaster.
78 void AddVisitedURLs(const std::vector<GURL>& urls);
80 net::URLRequestContextGetter* CreateRequestContext(
81 content::ProtocolHandlerMap* protocol_handlers,
82 content::URLRequestInterceptorScopedVector request_interceptors);
83 net::URLRequestContextGetter* CreateRequestContextForStoragePartition(
84 const base::FilePath& partition_path,
85 bool in_memory,
86 content::ProtocolHandlerMap* protocol_handlers,
87 content::URLRequestInterceptorScopedVector request_interceptors);
89 AwQuotaManagerBridge* GetQuotaManagerBridge();
91 AwFormDatabaseService* GetFormDatabaseService();
93 data_reduction_proxy::DataReductionProxySettings*
94 GetDataReductionProxySettings();
96 data_reduction_proxy::DataReductionProxyIOData*
97 GetDataReductionProxyIOData();
99 AwURLRequestContextGetter* GetAwURLRequestContext();
101 void CreateUserPrefServiceIfNecessary();
103 AwMessagePortService* GetMessagePortService();
105 // content::BrowserContext implementation.
106 scoped_ptr<content::ZoomLevelDelegate> CreateZoomLevelDelegate(
107 const base::FilePath& partition_path) override;
108 base::FilePath GetPath() const override;
109 bool IsOffTheRecord() const override;
110 net::URLRequestContextGetter* GetRequestContext() override;
111 net::URLRequestContextGetter* GetRequestContextForRenderProcess(
112 int renderer_child_id) override;
113 net::URLRequestContextGetter* GetMediaRequestContext() override;
114 net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess(
115 int renderer_child_id) override;
116 net::URLRequestContextGetter* GetMediaRequestContextForStoragePartition(
117 const base::FilePath& partition_path,
118 bool in_memory) override;
119 content::ResourceContext* GetResourceContext() override;
120 content::DownloadManagerDelegate* GetDownloadManagerDelegate() override;
121 content::BrowserPluginGuestManager* GetGuestManager() override;
122 storage::SpecialStoragePolicy* GetSpecialStoragePolicy() override;
123 content::PushMessagingService* GetPushMessagingService() override;
124 content::SSLHostStateDelegate* GetSSLHostStateDelegate() override;
125 content::PermissionManager* GetPermissionManager() override;
127 // visitedlink::VisitedLinkDelegate implementation.
128 void RebuildTable(const scoped_refptr<URLEnumerator>& enumerator) override;
130 private:
131 void CreateDataReductionProxyStatisticsIfNecessary();
132 static bool data_reduction_proxy_enabled_;
134 // Delay, in milliseconds, before removing the legacy cache dir.
135 // This is non-const for testing purposes.
136 static int legacy_cache_removal_delay_ms_;
138 // The file path where data for this context is persisted.
139 base::FilePath context_storage_path_;
141 JniDependencyFactory* native_factory_;
142 scoped_refptr<net::CookieStore> cookie_store_;
143 scoped_refptr<AwURLRequestContextGetter> url_request_context_getter_;
144 scoped_refptr<AwQuotaManagerBridge> quota_manager_bridge_;
145 scoped_ptr<AwFormDatabaseService> form_database_service_;
146 scoped_ptr<AwMessagePortService> message_port_service_;
148 AwDownloadManagerDelegate download_manager_delegate_;
150 scoped_ptr<visitedlink::VisitedLinkMaster> visitedlink_master_;
151 scoped_ptr<content::ResourceContext> resource_context_;
153 scoped_ptr<PrefService> user_pref_service_;
155 scoped_ptr<data_reduction_proxy::DataReductionProxySettings>
156 data_reduction_proxy_settings_;
157 scoped_ptr<AwSSLHostStateDelegate> ssl_host_state_delegate_;
158 scoped_ptr<data_reduction_proxy::DataReductionProxyIOData>
159 data_reduction_proxy_io_data_;
160 scoped_ptr<data_reduction_proxy::DataReductionProxyService>
161 data_reduction_proxy_service_;
162 scoped_ptr<content::PermissionManager> permission_manager_;
164 DISALLOW_COPY_AND_ASSIGN(AwBrowserContext);
167 } // namespace android_webview
169 #endif // ANDROID_WEBVIEW_BROWSER_AW_BROWSER_CONTEXT_H_