blob: 98476a4cd2824bfa74e6622ef0a0018f86522f16 [file] [log] [blame]
[email protected]f81fa202012-10-25 23:32:281// 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]f2ab1b152013-01-25 04:38:418#include <vector>
9
[email protected]efcd66b2013-05-15 08:38:4410#include "android_webview/browser/aw_autofill_manager_delegate.h"
[email protected]c347c4362012-12-05 06:05:3111#include "android_webview/browser/aw_download_manager_delegate.h"
[email protected]6bd30072013-02-08 18:17:1112#include "base/basictypes.h"
13#include "base/compiler_specific.h"
[email protected]57999812013-02-24 05:40:5214#include "base/files/file_path.h"
[email protected]f81fa202012-10-25 23:32:2815#include "base/memory/ref_counted.h"
[email protected]6bd30072013-02-08 18:17:1116#include "base/memory/scoped_ptr.h"
[email protected]f2ab1b152013-01-25 04:38:4117#include "components/visitedlink/browser/visitedlink_delegate.h"
[email protected]c347c4362012-12-05 06:05:3118#include "content/public/browser/browser_context.h"
[email protected]672c8c12013-03-07 12:30:0619#include "content/public/browser/content_browser_client.h"
[email protected]4230ed92013-01-10 05:51:4220#include "content/public/browser/geolocation_permission_context.h"
[email protected]6bd30072013-02-08 18:17:1121#include "net/url_request/url_request_job_factory.h"
[email protected]f81fa202012-10-25 23:32:2822
[email protected]f2ab1b152013-01-25 04:38:4123class GURL;
24
25namespace components {
26class VisitedLinkMaster;
27} // namespace components
28
29namespace content {
[email protected]6bd30072013-02-08 18:17:1130class ResourceContext;
[email protected]f2ab1b152013-01-25 04:38:4131class WebContents;
32} // namespace content
33
[email protected]f81fa202012-10-25 23:32:2834namespace android_webview {
35
[email protected]11401802013-05-08 16:16:3736class AwFormDatabaseService;
[email protected]2a3a0592013-02-22 18:53:0437class AwQuotaManagerBridge;
[email protected]11401802013-05-08 16:16:3738class AwURLRequestContextGetter;
[email protected]2a3a0592013-02-22 18:53:0439class JniDependencyFactory;
[email protected]4230ed92013-01-10 05:51:4240
[email protected]f2ab1b152013-01-25 04:38:4141class AwBrowserContext : public content::BrowserContext,
42 public components::VisitedLinkDelegate {
[email protected]f81fa202012-10-25 23:32:2843 public:
[email protected]f2ab1b152013-01-25 04:38:4144
[email protected]2a3a0592013-02-22 18:53:0445 AwBrowserContext(const base::FilePath path,
46 JniDependencyFactory* native_factory);
[email protected]f81fa202012-10-25 23:32:2847 virtual ~AwBrowserContext();
48
[email protected]f2ab1b152013-01-25 04:38:4149 // Convenience method to returns the AwBrowserContext corresponding to the
50 // given WebContents.
51 static AwBrowserContext* FromWebContents(
52 content::WebContents* web_contents);
53
[email protected]f81fa202012-10-25 23:32:2854 // Called before BrowserThreads are created.
55 void InitializeBeforeThreadCreation();
56
[email protected]f2ab1b152013-01-25 04:38:4157 // Maps to BrowserMainParts::PreMainMessageLoopRun.
58 void PreMainMessageLoopRun();
59
60 // These methods map to Add methods in components::VisitedLinkMaster.
[email protected]f2ab1b152013-01-25 04:38:4161 void AddVisitedURLs(const std::vector<GURL>& urls);
62
[email protected]6bd30072013-02-08 18:17:1163 net::URLRequestContextGetter* CreateRequestContext(
[email protected]672c8c12013-03-07 12:30:0664 content::ProtocolHandlerMap* protocol_handlers);
[email protected]6bd30072013-02-08 18:17:1165 net::URLRequestContextGetter* CreateRequestContextForStoragePartition(
[email protected]6d4b67a2013-02-10 04:49:3066 const base::FilePath& partition_path,
[email protected]6bd30072013-02-08 18:17:1167 bool in_memory,
[email protected]672c8c12013-03-07 12:30:0668 content::ProtocolHandlerMap* protocol_handlers);
[email protected]6bd30072013-02-08 18:17:1169
[email protected]2a3a0592013-02-22 18:53:0470 AwQuotaManagerBridge* GetQuotaManagerBridge();
71
[email protected]11401802013-05-08 16:16:3772 AwFormDatabaseService* GetFormDatabaseService();
[email protected]efcd66b2013-05-15 08:38:4473 AwAutofillManagerDelegate* AutofillManagerDelegate();
74 AwAutofillManagerDelegate* CreateAutofillManagerDelegate(bool enabled);
[email protected]11401802013-05-08 16:16:3775
[email protected]f81fa202012-10-25 23:32:2876 // content::BrowserContext implementation.
[email protected]6d4b67a2013-02-10 04:49:3077 virtual base::FilePath GetPath() OVERRIDE;
[email protected]f81fa202012-10-25 23:32:2878 virtual bool IsOffTheRecord() const OVERRIDE;
79 virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE;
80 virtual net::URLRequestContextGetter* GetRequestContextForRenderProcess(
81 int renderer_child_id) OVERRIDE;
[email protected]f81fa202012-10-25 23:32:2882 virtual net::URLRequestContextGetter* GetMediaRequestContext() OVERRIDE;
83 virtual net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess(
84 int renderer_child_id) OVERRIDE;
85 virtual net::URLRequestContextGetter*
86 GetMediaRequestContextForStoragePartition(
[email protected]6d4b67a2013-02-10 04:49:3087 const base::FilePath& partition_path, bool in_memory) OVERRIDE;
[email protected]f81fa202012-10-25 23:32:2888 virtual content::ResourceContext* GetResourceContext() OVERRIDE;
89 virtual content::DownloadManagerDelegate*
90 GetDownloadManagerDelegate() OVERRIDE;
91 virtual content::GeolocationPermissionContext*
92 GetGeolocationPermissionContext() OVERRIDE;
93 virtual content::SpeechRecognitionPreferences*
94 GetSpeechRecognitionPreferences() OVERRIDE;
95 virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE;
96
[email protected]f2ab1b152013-01-25 04:38:4197 // components::VisitedLinkDelegate implementation.
98 virtual void RebuildTable(
99 const scoped_refptr<URLEnumerator>& enumerator) OVERRIDE;
100
[email protected]f81fa202012-10-25 23:32:28101 private:
[email protected]f81fa202012-10-25 23:32:28102 // The file path where data for this context is persisted.
[email protected]6d4b67a2013-02-10 04:49:30103 base::FilePath context_storage_path_;
[email protected]f81fa202012-10-25 23:32:28104
[email protected]2a3a0592013-02-22 18:53:04105 JniDependencyFactory* native_factory_;
[email protected]f81fa202012-10-25 23:32:28106 scoped_refptr<AwURLRequestContextGetter> url_request_context_getter_;
[email protected]4230ed92013-01-10 05:51:42107 scoped_refptr<content::GeolocationPermissionContext>
108 geolocation_permission_context_;
[email protected]2a3a0592013-02-22 18:53:04109 scoped_ptr<AwQuotaManagerBridge> quota_manager_bridge_;
[email protected]11401802013-05-08 16:16:37110 scoped_ptr<AwFormDatabaseService> form_database_service_;
[email protected]efcd66b2013-05-15 08:38:44111 scoped_ptr<AwAutofillManagerDelegate> autofill_manager_delegate_;
[email protected]f81fa202012-10-25 23:32:28112
[email protected]c347c4362012-12-05 06:05:31113 AwDownloadManagerDelegate download_manager_delegate_;
114
[email protected]f2ab1b152013-01-25 04:38:41115 scoped_ptr<components::VisitedLinkMaster> visitedlink_master_;
[email protected]6bd30072013-02-08 18:17:11116 scoped_ptr<content::ResourceContext> resource_context_;
[email protected]f2ab1b152013-01-25 04:38:41117
[email protected]f81fa202012-10-25 23:32:28118 DISALLOW_COPY_AND_ASSIGN(AwBrowserContext);
119};
120
121} // namespace android_webview
122
123#endif // ANDROID_WEBVIEW_BROWSER_AW_BROWSER_CONTEXT_H_