aw_browser_context.h revision 2a99a7e74a7f215066514fe81d2bfa6639d9eddd
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. 4 5#ifndef ANDROID_WEBVIEW_BROWSER_AW_BROWSER_CONTEXT_H_ 6#define ANDROID_WEBVIEW_BROWSER_AW_BROWSER_CONTEXT_H_ 7 8#include <vector> 9 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" 21 22class GURL; 23 24namespace components { 25class VisitedLinkMaster; 26} // namespace components 27 28namespace content { 29class ResourceContext; 30class WebContents; 31} // namespace content 32 33namespace android_webview { 34 35class AwURLRequestContextGetter; 36class AwQuotaManagerBridge; 37class JniDependencyFactory; 38 39class AwBrowserContext : public content::BrowserContext, 40 public components::VisitedLinkDelegate { 41 public: 42 43 AwBrowserContext(const base::FilePath path, 44 JniDependencyFactory* native_factory); 45 virtual ~AwBrowserContext(); 46 47 // Convenience method to returns the AwBrowserContext corresponding to the 48 // given WebContents. 49 static AwBrowserContext* FromWebContents( 50 content::WebContents* web_contents); 51 52 // Called before BrowserThreads are created. 53 void InitializeBeforeThreadCreation(); 54 55 // Maps to BrowserMainParts::PreMainMessageLoopRun. 56 void PreMainMessageLoopRun(); 57 58 // These methods map to Add methods in components::VisitedLinkMaster. 59 void AddVisitedURLs(const std::vector<GURL>& urls); 60 61 net::URLRequestContextGetter* CreateRequestContext( 62 content::ProtocolHandlerMap* protocol_handlers); 63 net::URLRequestContextGetter* CreateRequestContextForStoragePartition( 64 const base::FilePath& partition_path, 65 bool in_memory, 66 content::ProtocolHandlerMap* protocol_handlers); 67 68 AwQuotaManagerBridge* GetQuotaManagerBridge(); 69 70 // content::BrowserContext implementation. 71 virtual base::FilePath GetPath() OVERRIDE; 72 virtual bool IsOffTheRecord() const OVERRIDE; 73 virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE; 74 virtual net::URLRequestContextGetter* GetRequestContextForRenderProcess( 75 int renderer_child_id) OVERRIDE; 76 virtual net::URLRequestContextGetter* GetMediaRequestContext() OVERRIDE; 77 virtual net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess( 78 int renderer_child_id) OVERRIDE; 79 virtual net::URLRequestContextGetter* 80 GetMediaRequestContextForStoragePartition( 81 const base::FilePath& partition_path, bool in_memory) OVERRIDE; 82 virtual content::ResourceContext* GetResourceContext() OVERRIDE; 83 virtual content::DownloadManagerDelegate* 84 GetDownloadManagerDelegate() OVERRIDE; 85 virtual content::GeolocationPermissionContext* 86 GetGeolocationPermissionContext() OVERRIDE; 87 virtual content::SpeechRecognitionPreferences* 88 GetSpeechRecognitionPreferences() OVERRIDE; 89 virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE; 90 91 // components::VisitedLinkDelegate implementation. 92 virtual void RebuildTable( 93 const scoped_refptr<URLEnumerator>& enumerator) OVERRIDE; 94 95 private: 96 // The file path where data for this context is persisted. 97 base::FilePath context_storage_path_; 98 99 JniDependencyFactory* native_factory_; 100 scoped_refptr<AwURLRequestContextGetter> url_request_context_getter_; 101 scoped_refptr<content::GeolocationPermissionContext> 102 geolocation_permission_context_; 103 scoped_ptr<AwQuotaManagerBridge> quota_manager_bridge_; 104 105 AwDownloadManagerDelegate download_manager_delegate_; 106 107 scoped_ptr<components::VisitedLinkMaster> visitedlink_master_; 108 scoped_ptr<content::ResourceContext> resource_context_; 109 110 DISALLOW_COPY_AND_ASSIGN(AwBrowserContext); 111}; 112 113} // namespace android_webview 114 115#endif // ANDROID_WEBVIEW_BROWSER_AW_BROWSER_CONTEXT_H_ 116