#ifndef ANDROID_WEBVIEW_BROWSER_AW_BROWSER_CONTEXT_H_
#define ANDROID_WEBVIEW_BROWSER_AW_BROWSER_CONTEXT_H_
#include <vector>
#include "android_webview/browser/aw_download_manager_delegate.h"
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/files/file_path.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "components/visitedlink/browser/visitedlink_delegate.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/geolocation_permission_context.h"
#include "net/url_request/url_request_job_factory.h"
class GURL;
class PrefService;
namespace content {
class ResourceContext;
class WebContents;
}
namespace net {
class CookieStore;
}
namespace visitedlink {
class VisitedLinkMaster;
}
namespace android_webview {
class AwFormDatabaseService;
class AwQuotaManagerBridge;
class AwURLRequestContextGetter;
class JniDependencyFactory;
class AwBrowserContext : public content::BrowserContext,
public visitedlink::VisitedLinkDelegate {
public:
AwBrowserContext(const base::FilePath path,
JniDependencyFactory* native_factory);
virtual ~AwBrowserContext();
static AwBrowserContext* GetDefault();
static AwBrowserContext* FromWebContents(
content::WebContents* web_contents);
void PreMainMessageLoopRun();
void AddVisitedURLs(const std::vector<GURL>& urls);
net::URLRequestContextGetter* CreateRequestContext(
content::ProtocolHandlerMap* protocol_handlers);
net::URLRequestContextGetter* CreateRequestContextForStoragePartition(
const base::FilePath& partition_path,
bool in_memory,
content::ProtocolHandlerMap* protocol_handlers);
AwQuotaManagerBridge* GetQuotaManagerBridge();
AwFormDatabaseService* GetFormDatabaseService();
void CreateUserPrefServiceIfNecessary();
virtual base::FilePath GetPath() const OVERRIDE;
virtual bool IsOffTheRecord() const OVERRIDE;
virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE;
virtual net::URLRequestContextGetter* GetRequestContextForRenderProcess(
int renderer_child_id) OVERRIDE;
virtual net::URLRequestContextGetter* GetMediaRequestContext() OVERRIDE;
virtual net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess(
int renderer_child_id) OVERRIDE;
virtual net::URLRequestContextGetter*
GetMediaRequestContextForStoragePartition(
const base::FilePath& partition_path, bool in_memory) OVERRIDE;
virtual void RequestMidiSysExPermission(
int render_process_id,
int render_view_id,
int bridge_id,
const GURL& requesting_frame,
bool user_gesture,
const MidiSysExPermissionCallback& callback) OVERRIDE;
virtual void CancelMidiSysExPermissionRequest(
int render_process_id,
int render_view_id,
int bridge_id,
const GURL& requesting_frame) OVERRIDE;
virtual void RequestProtectedMediaIdentifierPermission(
int render_process_id,
int render_view_id,
int bridge_id,
int group_id,
const GURL& requesting_frame,
const ProtectedMediaIdentifierPermissionCallback& callback) OVERRIDE;
virtual void CancelProtectedMediaIdentifierPermissionRequests(int group_id)
OVERRIDE;
virtual content::ResourceContext* GetResourceContext() OVERRIDE;
virtual content::DownloadManagerDelegate*
GetDownloadManagerDelegate() OVERRIDE;
virtual content::GeolocationPermissionContext*
GetGeolocationPermissionContext() OVERRIDE;
virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE;
virtual void RebuildTable(
const scoped_refptr<URLEnumerator>& enumerator) OVERRIDE;
private:
base::FilePath context_storage_path_;
JniDependencyFactory* native_factory_;
scoped_refptr<net::CookieStore> cookie_store_;
scoped_refptr<AwURLRequestContextGetter> url_request_context_getter_;
scoped_refptr<content::GeolocationPermissionContext>
geolocation_permission_context_;
scoped_refptr<AwQuotaManagerBridge> quota_manager_bridge_;
scoped_ptr<AwFormDatabaseService> form_database_service_;
AwDownloadManagerDelegate download_manager_delegate_;
scoped_ptr<visitedlink::VisitedLinkMaster> visitedlink_master_;
scoped_ptr<content::ResourceContext> resource_context_;
scoped_ptr<PrefService> user_pref_service_;
DISALLOW_COPY_AND_ASSIGN(AwBrowserContext);
};
}
#endif