1 // Copyright (c) 2013 Intel Corporation. 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 XWALK_RUNTIME_BROWSER_RUNTIME_CONTEXT_H_
6 #define XWALK_RUNTIME_BROWSER_RUNTIME_CONTEXT_H_
8 #if defined(OS_ANDROID)
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 "content/public/browser/browser_context.h"
17 #include "content/public/browser/content_browser_client.h"
18 #include "content/public/browser/geolocation_permission_context.h"
21 class URLRequestContextGetter;
25 class DownloadManagerDelegate;
30 class RuntimeDownloadManagerDelegate;
31 class RuntimeURLRequestContextGetter;
33 class RuntimeContext : public content::BrowserContext {
36 virtual ~RuntimeContext();
38 // Convenience method to returns the RuntimeContext corresponding to the
40 static RuntimeContext* FromWebContents(content::WebContents* web_contents);
42 // BrowserContext implementation.
43 virtual base::FilePath GetPath() const OVERRIDE;
44 virtual bool IsOffTheRecord() const OVERRIDE;
45 virtual content::DownloadManagerDelegate*
46 GetDownloadManagerDelegate() OVERRIDE;
47 virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE;
48 virtual net::URLRequestContextGetter* GetRequestContextForRenderProcess(
49 int renderer_child_id) OVERRIDE;
50 virtual net::URLRequestContextGetter* GetMediaRequestContext() OVERRIDE;
51 virtual net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess(
52 int renderer_child_id) OVERRIDE;
53 virtual net::URLRequestContextGetter*
54 GetMediaRequestContextForStoragePartition(
55 const base::FilePath& partition_path,
56 bool in_memory) OVERRIDE;
57 virtual content::ResourceContext* GetResourceContext() OVERRIDE;
58 virtual content::GeolocationPermissionContext*
59 GetGeolocationPermissionContext() OVERRIDE;
60 virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE;
61 virtual void RequestMidiSysExPermission(
62 int render_process_id,
65 const GURL& requesting_frame,
66 const MidiSysExPermissionCallback& callback) OVERRIDE { }
67 virtual void CancelMidiSysExPermissionRequest(
68 int render_process_id,
71 const GURL& requesting_frame) OVERRIDE {}
72 virtual void RequestProtectedMediaIdentifierPermission(
73 int render_process_id,
77 const GURL& requesting_frame,
78 const ProtectedMediaIdentifierPermissionCallback& callback) OVERRIDE;
79 virtual void CancelProtectedMediaIdentifierPermissionRequests(
80 int group_id) OVERRIDE;
82 net::URLRequestContextGetter* CreateRequestContext(
83 content::ProtocolHandlerMap* protocol_handlers);
84 net::URLRequestContextGetter* CreateRequestContextForStoragePartition(
85 const base::FilePath& partition_path,
87 content::ProtocolHandlerMap* protocol_handlers);
88 #if defined(OS_ANDROID)
89 void SetCSPString(const std::string& csp);
90 std::string GetCSPString() const;
94 class RuntimeResourceContext;
96 // Performs initialization of the RuntimeContext while IO is still
97 // allowed on the current thread.
98 void InitWhileIOAllowed();
100 scoped_ptr<RuntimeResourceContext> resource_context_;
101 scoped_refptr<RuntimeDownloadManagerDelegate> download_manager_delegate_;
102 scoped_refptr<RuntimeURLRequestContextGetter> url_request_getter_;
103 scoped_refptr<content::GeolocationPermissionContext>
104 geolocation_permission_context_;
105 #if defined(OS_ANDROID)
108 DISALLOW_COPY_AND_ASSIGN(RuntimeContext);
113 #endif // XWALK_RUNTIME_BROWSER_RUNTIME_CONTEXT_H_