Send compressed histograms with system logs when sending feedback.
[chromium-blink-merge.git] / android_webview / browser / aw_browser_context.h
blob0705baa9b1860d684e58eecbb8e7f0414b4beb8a
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 "base/basictypes.h"
12 #include "base/compiler_specific.h"
13 #include "base/files/file_path.h"
14 #include "base/memory/ref_counted.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "components/visitedlink/browser/visitedlink_delegate.h"
17 #include "content/public/browser/browser_context.h"
18 #include "content/public/browser/content_browser_client.h"
19 #include "content/public/browser/geolocation_permission_context.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 WebContents;
30 namespace net {
31 class CookieStore;
34 namespace visitedlink {
35 class VisitedLinkMaster;
38 namespace android_webview {
40 class AwFormDatabaseService;
41 class AwQuotaManagerBridge;
42 class AwURLRequestContextGetter;
43 class JniDependencyFactory;
45 class AwBrowserContext : public content::BrowserContext,
46 public visitedlink::VisitedLinkDelegate {
47 public:
49 AwBrowserContext(const base::FilePath path,
50 JniDependencyFactory* native_factory);
51 virtual ~AwBrowserContext();
53 // Currently only one instance per process is supported.
54 static AwBrowserContext* GetDefault();
56 // Convenience method to returns the AwBrowserContext corresponding to the
57 // given WebContents.
58 static AwBrowserContext* FromWebContents(
59 content::WebContents* web_contents);
61 // Maps to BrowserMainParts::PreMainMessageLoopRun.
62 void PreMainMessageLoopRun();
64 // These methods map to Add methods in visitedlink::VisitedLinkMaster.
65 void AddVisitedURLs(const std::vector<GURL>& urls);
67 net::URLRequestContextGetter* CreateRequestContext(
68 content::ProtocolHandlerMap* protocol_handlers);
69 net::URLRequestContextGetter* CreateRequestContextForStoragePartition(
70 const base::FilePath& partition_path,
71 bool in_memory,
72 content::ProtocolHandlerMap* protocol_handlers);
74 AwQuotaManagerBridge* GetQuotaManagerBridge();
76 AwFormDatabaseService* GetFormDatabaseService();
77 void CreateUserPrefServiceIfNecessary();
79 // content::BrowserContext implementation.
80 virtual base::FilePath GetPath() const OVERRIDE;
81 virtual bool IsOffTheRecord() const OVERRIDE;
82 virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE;
83 virtual net::URLRequestContextGetter* GetRequestContextForRenderProcess(
84 int renderer_child_id) OVERRIDE;
85 virtual net::URLRequestContextGetter* GetMediaRequestContext() OVERRIDE;
86 virtual net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess(
87 int renderer_child_id) OVERRIDE;
88 virtual net::URLRequestContextGetter*
89 GetMediaRequestContextForStoragePartition(
90 const base::FilePath& partition_path, bool in_memory) OVERRIDE;
91 virtual void RequestMIDISysExPermission(
92 int render_process_id,
93 int render_view_id,
94 int bridge_id,
95 const GURL& requesting_frame,
96 const MIDISysExPermissionCallback& callback) OVERRIDE;
97 virtual void CancelMIDISysExPermissionRequest(
98 int render_process_id,
99 int render_view_id,
100 int bridge_id,
101 const GURL& requesting_frame) OVERRIDE;
102 virtual content::ResourceContext* GetResourceContext() OVERRIDE;
103 virtual content::DownloadManagerDelegate*
104 GetDownloadManagerDelegate() OVERRIDE;
105 virtual content::GeolocationPermissionContext*
106 GetGeolocationPermissionContext() OVERRIDE;
107 virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE;
109 // visitedlink::VisitedLinkDelegate implementation.
110 virtual void RebuildTable(
111 const scoped_refptr<URLEnumerator>& enumerator) OVERRIDE;
113 private:
114 // The file path where data for this context is persisted.
115 base::FilePath context_storage_path_;
117 JniDependencyFactory* native_factory_;
118 scoped_refptr<net::CookieStore> cookie_store_;
119 scoped_refptr<AwURLRequestContextGetter> url_request_context_getter_;
120 scoped_refptr<content::GeolocationPermissionContext>
121 geolocation_permission_context_;
122 scoped_refptr<AwQuotaManagerBridge> quota_manager_bridge_;
123 scoped_ptr<AwFormDatabaseService> form_database_service_;
125 AwDownloadManagerDelegate download_manager_delegate_;
127 scoped_ptr<visitedlink::VisitedLinkMaster> visitedlink_master_;
128 scoped_ptr<content::ResourceContext> resource_context_;
130 scoped_ptr<PrefService> user_pref_service_;
132 DISALLOW_COPY_AND_ASSIGN(AwBrowserContext);
135 } // namespace android_webview
137 #endif // ANDROID_WEBVIEW_BROWSER_AW_BROWSER_CONTEXT_H_