blob: 517f3079fc74d1bfe322da38f7f65c8bf33ef2cd [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]c347c4362012-12-05 06:05:3110#include "android_webview/browser/aw_download_manager_delegate.h"
[email protected]6bd30072013-02-08 18:17:1111#include "base/basictypes.h"
12#include "base/compiler_specific.h"
[email protected]f81fa202012-10-25 23:32:2813#include "base/file_path.h"
14#include "base/memory/ref_counted.h"
[email protected]6bd30072013-02-08 18:17:1115#include "base/memory/scoped_ptr.h"
[email protected]f2ab1b152013-01-25 04:38:4116#include "components/visitedlink/browser/visitedlink_delegate.h"
[email protected]c347c4362012-12-05 06:05:3117#include "content/public/browser/browser_context.h"
[email protected]4230ed92013-01-10 05:51:4218#include "content/public/browser/geolocation_permission_context.h"
[email protected]6bd30072013-02-08 18:17:1119#include "net/url_request/url_request_job_factory.h"
[email protected]f81fa202012-10-25 23:32:2820
[email protected]f2ab1b152013-01-25 04:38:4121class GURL;
22
23namespace components {
24class VisitedLinkMaster;
25} // namespace components
26
27namespace content {
[email protected]6bd30072013-02-08 18:17:1128class ResourceContext;
[email protected]f2ab1b152013-01-25 04:38:4129class WebContents;
30} // namespace content
31
[email protected]f81fa202012-10-25 23:32:2832namespace android_webview {
33
34class AwURLRequestContextGetter;
[email protected]2a3a0592013-02-22 18:53:0435class AwQuotaManagerBridge;
36class JniDependencyFactory;
[email protected]4230ed92013-01-10 05:51:4237
[email protected]f2ab1b152013-01-25 04:38:4138class AwBrowserContext : public content::BrowserContext,
39 public components::VisitedLinkDelegate {
[email protected]f81fa202012-10-25 23:32:2840 public:
[email protected]f2ab1b152013-01-25 04:38:4141
[email protected]2a3a0592013-02-22 18:53:0442 AwBrowserContext(const base::FilePath path,
43 JniDependencyFactory* native_factory);
[email protected]f81fa202012-10-25 23:32:2844 virtual ~AwBrowserContext();
45
[email protected]f2ab1b152013-01-25 04:38:4146 // Convenience method to returns the AwBrowserContext corresponding to the
47 // given WebContents.
48 static AwBrowserContext* FromWebContents(
49 content::WebContents* web_contents);
50
[email protected]f81fa202012-10-25 23:32:2851 // Called before BrowserThreads are created.
52 void InitializeBeforeThreadCreation();
53
[email protected]f2ab1b152013-01-25 04:38:4154 // Maps to BrowserMainParts::PreMainMessageLoopRun.
55 void PreMainMessageLoopRun();
56
57 // These methods map to Add methods in components::VisitedLinkMaster.
[email protected]f2ab1b152013-01-25 04:38:4158 void AddVisitedURLs(const std::vector<GURL>& urls);
59
[email protected]6bd30072013-02-08 18:17:1160 net::URLRequestContextGetter* CreateRequestContext(
61 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
62 blob_protocol_handler,
63 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
64 file_system_protocol_handler,
65 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
66 developer_protocol_handler,
67 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
68 chrome_protocol_handler,
69 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
70 chrome_devtools_protocol_handler);
71 net::URLRequestContextGetter* CreateRequestContextForStoragePartition(
[email protected]6d4b67a2013-02-10 04:49:3072 const base::FilePath& partition_path,
[email protected]6bd30072013-02-08 18:17:1173 bool in_memory,
74 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
75 blob_protocol_handler,
76 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
77 file_system_protocol_handler,
78 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
79 developer_protocol_handler,
80 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
81 chrome_protocol_handler,
82 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
83 chrome_devtools_protocol_handler);
84
[email protected]2a3a0592013-02-22 18:53:0485 AwQuotaManagerBridge* GetQuotaManagerBridge();
86
[email protected]f81fa202012-10-25 23:32:2887 // content::BrowserContext implementation.
[email protected]6d4b67a2013-02-10 04:49:3088 virtual base::FilePath GetPath() OVERRIDE;
[email protected]f81fa202012-10-25 23:32:2889 virtual bool IsOffTheRecord() const OVERRIDE;
90 virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE;
91 virtual net::URLRequestContextGetter* GetRequestContextForRenderProcess(
92 int renderer_child_id) OVERRIDE;
[email protected]f81fa202012-10-25 23:32:2893 virtual net::URLRequestContextGetter* GetMediaRequestContext() OVERRIDE;
94 virtual net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess(
95 int renderer_child_id) OVERRIDE;
96 virtual net::URLRequestContextGetter*
97 GetMediaRequestContextForStoragePartition(
[email protected]6d4b67a2013-02-10 04:49:3098 const base::FilePath& partition_path, bool in_memory) OVERRIDE;
[email protected]f81fa202012-10-25 23:32:2899 virtual content::ResourceContext* GetResourceContext() OVERRIDE;
100 virtual content::DownloadManagerDelegate*
101 GetDownloadManagerDelegate() OVERRIDE;
102 virtual content::GeolocationPermissionContext*
103 GetGeolocationPermissionContext() OVERRIDE;
104 virtual content::SpeechRecognitionPreferences*
105 GetSpeechRecognitionPreferences() OVERRIDE;
106 virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE;
107
[email protected]f2ab1b152013-01-25 04:38:41108 // components::VisitedLinkDelegate implementation.
109 virtual void RebuildTable(
110 const scoped_refptr<URLEnumerator>& enumerator) OVERRIDE;
111
[email protected]f81fa202012-10-25 23:32:28112 private:
[email protected]f81fa202012-10-25 23:32:28113 // The file path where data for this context is persisted.
[email protected]6d4b67a2013-02-10 04:49:30114 base::FilePath context_storage_path_;
[email protected]f81fa202012-10-25 23:32:28115
[email protected]2a3a0592013-02-22 18:53:04116 JniDependencyFactory* native_factory_;
[email protected]f81fa202012-10-25 23:32:28117 scoped_refptr<AwURLRequestContextGetter> url_request_context_getter_;
[email protected]4230ed92013-01-10 05:51:42118 scoped_refptr<content::GeolocationPermissionContext>
119 geolocation_permission_context_;
[email protected]2a3a0592013-02-22 18:53:04120 scoped_ptr<AwQuotaManagerBridge> quota_manager_bridge_;
[email protected]f81fa202012-10-25 23:32:28121
[email protected]c347c4362012-12-05 06:05:31122 AwDownloadManagerDelegate download_manager_delegate_;
123
[email protected]f2ab1b152013-01-25 04:38:41124 scoped_ptr<components::VisitedLinkMaster> visitedlink_master_;
[email protected]6bd30072013-02-08 18:17:11125 scoped_ptr<content::ResourceContext> resource_context_;
[email protected]f2ab1b152013-01-25 04:38:41126
[email protected]f81fa202012-10-25 23:32:28127 DISALLOW_COPY_AND_ASSIGN(AwBrowserContext);
128};
129
130} // namespace android_webview
131
132#endif // ANDROID_WEBVIEW_BROWSER_AW_BROWSER_CONTEXT_H_