[Password Autofill] Fix crash when triggering popup after in page navigation
[chromium-blink-merge.git] / android_webview / browser / aw_browser_context.h
blobbc2b11cb5dcc38a3e2019a2f822f8275cb1a4212
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_ssl_host_state_delegate.h"
12 #include "base/basictypes.h"
13 #include "base/compiler_specific.h"
14 #include "base/files/file_path.h"
15 #include "base/memory/ref_counted.h"
16 #include "base/memory/scoped_ptr.h"
17 #include "components/visitedlink/browser/visitedlink_delegate.h"
18 #include "content/public/browser/browser_context.h"
19 #include "content/public/browser/content_browser_client.h"
20 #include "net/url_request/url_request_job_factory.h"
22 class GURL;
23 class PrefService;
25 namespace content {
26 class ResourceContext;
27 class SSLHostStateDelegate;
28 class WebContents;
31 namespace data_reduction_proxy {
32 class DataReductionProxyConfigurator;
33 class DataReductionProxyEventStore;
34 class DataReductionProxySettings;
35 class DataReductionProxyStatisticsPrefs;
38 namespace net {
39 class CookieStore;
42 namespace visitedlink {
43 class VisitedLinkMaster;
46 namespace android_webview {
48 class AwFormDatabaseService;
49 class AwQuotaManagerBridge;
50 class AwURLRequestContextGetter;
51 class JniDependencyFactory;
53 class AwBrowserContext : public content::BrowserContext,
54 public visitedlink::VisitedLinkDelegate {
55 public:
57 AwBrowserContext(const base::FilePath path,
58 JniDependencyFactory* native_factory);
59 virtual ~AwBrowserContext();
61 // Currently only one instance per process is supported.
62 static AwBrowserContext* GetDefault();
64 // Convenience method to returns the AwBrowserContext corresponding to the
65 // given WebContents.
66 static AwBrowserContext* FromWebContents(
67 content::WebContents* web_contents);
69 static void SetDataReductionProxyEnabled(bool enabled);
70 static void SetLegacyCacheRemovalDelayForTest(int delay_ms);
72 // Maps to BrowserMainParts::PreMainMessageLoopRun.
73 void PreMainMessageLoopRun();
75 // These methods map to Add methods in visitedlink::VisitedLinkMaster.
76 void AddVisitedURLs(const std::vector<GURL>& urls);
78 net::URLRequestContextGetter* CreateRequestContext(
79 content::ProtocolHandlerMap* protocol_handlers,
80 content::URLRequestInterceptorScopedVector request_interceptors);
81 net::URLRequestContextGetter* CreateRequestContextForStoragePartition(
82 const base::FilePath& partition_path,
83 bool in_memory,
84 content::ProtocolHandlerMap* protocol_handlers,
85 content::URLRequestInterceptorScopedVector request_interceptors);
87 AwQuotaManagerBridge* GetQuotaManagerBridge();
89 AwFormDatabaseService* GetFormDatabaseService();
91 data_reduction_proxy::DataReductionProxySettings*
92 GetDataReductionProxySettings();
94 data_reduction_proxy::DataReductionProxyEventStore*
95 GetDataReductionProxyEventStore();
97 AwURLRequestContextGetter* GetAwURLRequestContext();
99 void CreateUserPrefServiceIfNecessary();
101 // content::BrowserContext implementation.
102 scoped_ptr<content::ZoomLevelDelegate> CreateZoomLevelDelegate(
103 const base::FilePath& partition_path) override;
104 virtual base::FilePath GetPath() const override;
105 virtual bool IsOffTheRecord() const override;
106 virtual net::URLRequestContextGetter* GetRequestContext() override;
107 virtual net::URLRequestContextGetter* GetRequestContextForRenderProcess(
108 int renderer_child_id) override;
109 virtual net::URLRequestContextGetter* GetMediaRequestContext() override;
110 virtual net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess(
111 int renderer_child_id) override;
112 virtual net::URLRequestContextGetter*
113 GetMediaRequestContextForStoragePartition(
114 const base::FilePath& partition_path, bool in_memory) override;
115 virtual content::ResourceContext* GetResourceContext() override;
116 virtual content::DownloadManagerDelegate*
117 GetDownloadManagerDelegate() override;
118 virtual content::BrowserPluginGuestManager* GetGuestManager() override;
119 virtual storage::SpecialStoragePolicy* GetSpecialStoragePolicy() override;
120 virtual content::PushMessagingService* GetPushMessagingService() override;
121 virtual content::SSLHostStateDelegate* GetSSLHostStateDelegate() override;
123 // visitedlink::VisitedLinkDelegate implementation.
124 virtual void RebuildTable(
125 const scoped_refptr<URLEnumerator>& enumerator) override;
127 private:
128 void CreateDataReductionProxyStatisticsIfNecessary();
129 static bool data_reduction_proxy_enabled_;
131 // Delay, in milliseconds, before removing the legacy cache dir.
132 // This is non-const for testing purposes.
133 static int legacy_cache_removal_delay_ms_;
135 // The file path where data for this context is persisted.
136 base::FilePath context_storage_path_;
138 JniDependencyFactory* native_factory_;
139 scoped_refptr<net::CookieStore> cookie_store_;
140 scoped_refptr<AwURLRequestContextGetter> url_request_context_getter_;
141 scoped_refptr<AwQuotaManagerBridge> quota_manager_bridge_;
142 scoped_ptr<AwFormDatabaseService> form_database_service_;
144 AwDownloadManagerDelegate download_manager_delegate_;
146 scoped_ptr<visitedlink::VisitedLinkMaster> visitedlink_master_;
147 scoped_ptr<content::ResourceContext> resource_context_;
149 scoped_ptr<PrefService> user_pref_service_;
151 scoped_ptr<data_reduction_proxy::DataReductionProxyConfigurator>
152 data_reduction_proxy_configurator_;
153 scoped_ptr<data_reduction_proxy::DataReductionProxyStatisticsPrefs>
154 data_reduction_proxy_statistics_;
155 scoped_ptr<data_reduction_proxy::DataReductionProxySettings>
156 data_reduction_proxy_settings_;
157 scoped_ptr<data_reduction_proxy::DataReductionProxyEventStore>
158 data_reduction_proxy_event_store_;
159 scoped_ptr<AwSSLHostStateDelegate> ssl_host_state_delegate_;
161 DISALLOW_COPY_AND_ASSIGN(AwBrowserContext);
164 } // namespace android_webview
166 #endif // ANDROID_WEBVIEW_BROWSER_AW_BROWSER_CONTEXT_H_