blob: b6a113407a5a5715c7ee428c95de1a7a8b9613ae [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
[email protected]ab3eaeed2013-05-17 00:18:4425namespace visitedlink {
[email protected]f2ab1b152013-01-25 04:38:4126class VisitedLinkMaster;
[email protected]ab3eaeed2013-05-17 00:18:4427}
[email protected]f2ab1b152013-01-25 04:38:4128
29namespace content {
[email protected]6bd30072013-02-08 18:17:1130class ResourceContext;
[email protected]f2ab1b152013-01-25 04:38:4131class WebContents;
[email protected]ab3eaeed2013-05-17 00:18:4432}
[email protected]f2ab1b152013-01-25 04:38:4133
[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,
[email protected]ab3eaeed2013-05-17 00:18:4442 public visitedlink::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]14a2df0d2013-06-14 23:40:3249 // Currently only one instance per process is supported.
50 static AwBrowserContext* GetDefault();
51
[email protected]f2ab1b152013-01-25 04:38:4152 // Convenience method to returns the AwBrowserContext corresponding to the
53 // given WebContents.
54 static AwBrowserContext* FromWebContents(
55 content::WebContents* web_contents);
56
[email protected]f81fa202012-10-25 23:32:2857 // Called before BrowserThreads are created.
58 void InitializeBeforeThreadCreation();
59
[email protected]f2ab1b152013-01-25 04:38:4160 // Maps to BrowserMainParts::PreMainMessageLoopRun.
61 void PreMainMessageLoopRun();
62
[email protected]ab3eaeed2013-05-17 00:18:4463 // These methods map to Add methods in visitedlink::VisitedLinkMaster.
[email protected]f2ab1b152013-01-25 04:38:4164 void AddVisitedURLs(const std::vector<GURL>& urls);
65
[email protected]6bd30072013-02-08 18:17:1166 net::URLRequestContextGetter* CreateRequestContext(
[email protected]672c8c12013-03-07 12:30:0667 content::ProtocolHandlerMap* protocol_handlers);
[email protected]6bd30072013-02-08 18:17:1168 net::URLRequestContextGetter* CreateRequestContextForStoragePartition(
[email protected]6d4b67a2013-02-10 04:49:3069 const base::FilePath& partition_path,
[email protected]6bd30072013-02-08 18:17:1170 bool in_memory,
[email protected]672c8c12013-03-07 12:30:0671 content::ProtocolHandlerMap* protocol_handlers);
[email protected]6bd30072013-02-08 18:17:1172
[email protected]2a3a0592013-02-22 18:53:0473 AwQuotaManagerBridge* GetQuotaManagerBridge();
74
[email protected]11401802013-05-08 16:16:3775 AwFormDatabaseService* GetFormDatabaseService();
[email protected]efcd66b2013-05-15 08:38:4476 AwAutofillManagerDelegate* AutofillManagerDelegate();
77 AwAutofillManagerDelegate* CreateAutofillManagerDelegate(bool enabled);
[email protected]11401802013-05-08 16:16:3778
[email protected]f81fa202012-10-25 23:32:2879 // content::BrowserContext implementation.
[email protected]6d4b67a2013-02-10 04:49:3080 virtual base::FilePath GetPath() OVERRIDE;
[email protected]f81fa202012-10-25 23:32:2881 virtual bool IsOffTheRecord() const OVERRIDE;
82 virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE;
83 virtual net::URLRequestContextGetter* GetRequestContextForRenderProcess(
84 int renderer_child_id) OVERRIDE;
[email protected]f81fa202012-10-25 23:32:2885 virtual net::URLRequestContextGetter* GetMediaRequestContext() OVERRIDE;
86 virtual net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess(
87 int renderer_child_id) OVERRIDE;
88 virtual net::URLRequestContextGetter*
89 GetMediaRequestContextForStoragePartition(
[email protected]6d4b67a2013-02-10 04:49:3090 const base::FilePath& partition_path, bool in_memory) OVERRIDE;
[email protected]f81fa202012-10-25 23:32:2891 virtual content::ResourceContext* GetResourceContext() OVERRIDE;
92 virtual content::DownloadManagerDelegate*
93 GetDownloadManagerDelegate() OVERRIDE;
94 virtual content::GeolocationPermissionContext*
95 GetGeolocationPermissionContext() OVERRIDE;
96 virtual content::SpeechRecognitionPreferences*
97 GetSpeechRecognitionPreferences() OVERRIDE;
98 virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE;
99
[email protected]ab3eaeed2013-05-17 00:18:44100 // visitedlink::VisitedLinkDelegate implementation.
[email protected]f2ab1b152013-01-25 04:38:41101 virtual void RebuildTable(
102 const scoped_refptr<URLEnumerator>& enumerator) OVERRIDE;
103
[email protected]f81fa202012-10-25 23:32:28104 private:
[email protected]f81fa202012-10-25 23:32:28105 // The file path where data for this context is persisted.
[email protected]6d4b67a2013-02-10 04:49:30106 base::FilePath context_storage_path_;
[email protected]f81fa202012-10-25 23:32:28107
[email protected]2a3a0592013-02-22 18:53:04108 JniDependencyFactory* native_factory_;
[email protected]f81fa202012-10-25 23:32:28109 scoped_refptr<AwURLRequestContextGetter> url_request_context_getter_;
[email protected]4230ed92013-01-10 05:51:42110 scoped_refptr<content::GeolocationPermissionContext>
111 geolocation_permission_context_;
[email protected]2a3a0592013-02-22 18:53:04112 scoped_ptr<AwQuotaManagerBridge> quota_manager_bridge_;
[email protected]11401802013-05-08 16:16:37113 scoped_ptr<AwFormDatabaseService> form_database_service_;
[email protected]efcd66b2013-05-15 08:38:44114 scoped_ptr<AwAutofillManagerDelegate> autofill_manager_delegate_;
[email protected]f81fa202012-10-25 23:32:28115
[email protected]c347c4362012-12-05 06:05:31116 AwDownloadManagerDelegate download_manager_delegate_;
117
[email protected]ab3eaeed2013-05-17 00:18:44118 scoped_ptr<visitedlink::VisitedLinkMaster> visitedlink_master_;
[email protected]6bd30072013-02-08 18:17:11119 scoped_ptr<content::ResourceContext> resource_context_;
[email protected]f2ab1b152013-01-25 04:38:41120
[email protected]f81fa202012-10-25 23:32:28121 DISALLOW_COPY_AND_ASSIGN(AwBrowserContext);
122};
123
124} // namespace android_webview
125
126#endif // ANDROID_WEBVIEW_BROWSER_AW_BROWSER_CONTEXT_H_