This source file includes following definitions.
- HandleReadError
- native_factory_
- GetDefault
- FromWebContents
- PreMainMessageLoopRun
- AddVisitedURLs
- CreateRequestContext
- CreateRequestContextForStoragePartition
- GetQuotaManagerBridge
- GetFormDatabaseService
- CreateUserPrefServiceIfNecessary
- GetPath
- IsOffTheRecord
- GetRequestContext
- GetRequestContextForRenderProcess
- GetMediaRequestContext
- RequestMidiSysExPermission
- CancelMidiSysExPermissionRequest
- RequestProtectedMediaIdentifierPermission
- CancelProtectedMediaIdentifierPermissionRequests
- GetMediaRequestContextForRenderProcess
- GetMediaRequestContextForStoragePartition
- GetResourceContext
- GetDownloadManagerDelegate
- GetGeolocationPermissionContext
- GetSpecialStoragePolicy
- RebuildTable
#include "android_webview/browser/aw_browser_context.h"
#include "android_webview/browser/aw_form_database_service.h"
#include "android_webview/browser/aw_pref_store.h"
#include "android_webview/browser/aw_quota_manager_bridge.h"
#include "android_webview/browser/aw_resource_context.h"
#include "android_webview/browser/jni_dependency_factory.h"
#include "android_webview/browser/net/aw_url_request_context_getter.h"
#include "android_webview/browser/net/init_native_callback.h"
#include "base/prefs/pref_registry_simple.h"
#include "base/prefs/pref_service.h"
#include "base/prefs/pref_service_factory.h"
#include "components/autofill/core/common/autofill_pref_names.h"
#include "components/user_prefs/user_prefs.h"
#include "components/visitedlink/browser/visitedlink_master.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/browser/web_contents.h"
#include "net/cookies/cookie_store.h"
using base::FilePath;
using content::BrowserThread;
namespace android_webview {
namespace {
void HandleReadError(PersistentPrefStore::PrefReadError error) {
}
AwBrowserContext* g_browser_context = NULL;
}
AwBrowserContext::AwBrowserContext(
const FilePath path,
JniDependencyFactory* native_factory)
: context_storage_path_(path),
native_factory_(native_factory) {
DCHECK(g_browser_context == NULL);
g_browser_context = this;
}
AwBrowserContext::~AwBrowserContext() {
DCHECK(g_browser_context == this);
g_browser_context = NULL;
}
AwBrowserContext* AwBrowserContext::GetDefault() {
return g_browser_context;
}
AwBrowserContext* AwBrowserContext::FromWebContents(
content::WebContents* web_contents) {
return static_cast<AwBrowserContext*>(web_contents->GetBrowserContext());
}
void AwBrowserContext::PreMainMessageLoopRun() {
cookie_store_ = CreateCookieStore(this);
url_request_context_getter_ =
new AwURLRequestContextGetter(GetPath(), cookie_store_.get());
visitedlink_master_.reset(
new visitedlink::VisitedLinkMaster(this, this, false));
visitedlink_master_->Init();
form_database_service_.reset(
new AwFormDatabaseService(context_storage_path_));
}
void AwBrowserContext::AddVisitedURLs(const std::vector<GURL>& urls) {
DCHECK(visitedlink_master_);
visitedlink_master_->AddURLs(urls);
}
net::URLRequestContextGetter* AwBrowserContext::CreateRequestContext(
content::ProtocolHandlerMap* protocol_handlers) {
DCHECK(url_request_context_getter_);
url_request_context_getter_->SetProtocolHandlers(protocol_handlers);
return url_request_context_getter_;
}
net::URLRequestContextGetter*
AwBrowserContext::CreateRequestContextForStoragePartition(
const base::FilePath& partition_path,
bool in_memory,
content::ProtocolHandlerMap* protocol_handlers) {
NOTREACHED();
return NULL;
}
AwQuotaManagerBridge* AwBrowserContext::GetQuotaManagerBridge() {
if (!quota_manager_bridge_.get()) {
quota_manager_bridge_ = native_factory_->CreateAwQuotaManagerBridge(this);
}
return quota_manager_bridge_.get();
}
AwFormDatabaseService* AwBrowserContext::GetFormDatabaseService() {
return form_database_service_.get();
}
void AwBrowserContext::CreateUserPrefServiceIfNecessary() {
if (user_pref_service_)
return;
PrefRegistrySimple* pref_registry = new PrefRegistrySimple();
pref_registry->RegisterBooleanPref(
autofill::prefs::kAutofillEnabled, false);
pref_registry->RegisterDoublePref(
autofill::prefs::kAutofillPositiveUploadRate, 0.0);
pref_registry->RegisterDoublePref(
autofill::prefs::kAutofillNegativeUploadRate, 0.0);
base::PrefServiceFactory pref_service_factory;
pref_service_factory.set_user_prefs(make_scoped_refptr(new AwPrefStore()));
pref_service_factory.set_read_error_callback(base::Bind(&HandleReadError));
user_pref_service_ = pref_service_factory.Create(pref_registry).Pass();
user_prefs::UserPrefs::Set(this, user_pref_service_.get());
}
base::FilePath AwBrowserContext::GetPath() const {
return context_storage_path_;
}
bool AwBrowserContext::IsOffTheRecord() const {
return false;
}
net::URLRequestContextGetter* AwBrowserContext::GetRequestContext() {
return GetDefaultStoragePartition(this)->GetURLRequestContext();
}
net::URLRequestContextGetter*
AwBrowserContext::GetRequestContextForRenderProcess(
int renderer_child_id) {
return GetRequestContext();
}
net::URLRequestContextGetter* AwBrowserContext::GetMediaRequestContext() {
return GetRequestContext();
}
void AwBrowserContext::RequestMidiSysExPermission(
int render_process_id,
int render_view_id,
int bridge_id,
const GURL& requesting_frame,
bool user_gesture,
const MidiSysExPermissionCallback& callback) {
callback.Run(false);
}
void AwBrowserContext::CancelMidiSysExPermissionRequest(
int render_process_id,
int render_view_id,
int bridge_id,
const GURL& requesting_frame) {
}
void AwBrowserContext::RequestProtectedMediaIdentifierPermission(
int render_process_id,
int render_view_id,
int bridge_id,
int group_id,
const GURL& requesting_frame,
const ProtectedMediaIdentifierPermissionCallback& callback) {
NOTIMPLEMENTED();
callback.Run(false);
}
void AwBrowserContext::CancelProtectedMediaIdentifierPermissionRequests(
int group_id) {
NOTIMPLEMENTED();
}
net::URLRequestContextGetter*
AwBrowserContext::GetMediaRequestContextForRenderProcess(
int renderer_child_id) {
return GetRequestContext();
}
net::URLRequestContextGetter*
AwBrowserContext::GetMediaRequestContextForStoragePartition(
const base::FilePath& partition_path,
bool in_memory) {
NOTREACHED();
return NULL;
}
content::ResourceContext* AwBrowserContext::GetResourceContext() {
if (!resource_context_) {
resource_context_.reset(
new AwResourceContext(url_request_context_getter_.get()));
}
return resource_context_.get();
}
content::DownloadManagerDelegate*
AwBrowserContext::GetDownloadManagerDelegate() {
return &download_manager_delegate_;
}
content::GeolocationPermissionContext*
AwBrowserContext::GetGeolocationPermissionContext() {
if (!geolocation_permission_context_.get()) {
geolocation_permission_context_ =
native_factory_->CreateGeolocationPermission(this);
}
return geolocation_permission_context_.get();
}
quota::SpecialStoragePolicy* AwBrowserContext::GetSpecialStoragePolicy() {
return NULL;
}
void AwBrowserContext::RebuildTable(
const scoped_refptr<URLEnumerator>& enumerator) {
enumerator->OnComplete(true);
}
}