1 // Copyright 2013 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 CONTENT_SHELL_BROWSER_SHELL_BROWSER_CONTEXT_H_
6 #define CONTENT_SHELL_BROWSER_SHELL_BROWSER_CONTEXT_H_
8 #include "base/compiler_specific.h"
9 #include "base/files/file_path.h"
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "content/public/browser/browser_context.h"
13 #include "content/public/browser/content_browser_client.h"
14 #include "net/url_request/url_request_job_factory.h"
22 class DownloadManagerDelegate;
23 class ResourceContext;
24 class ShellDownloadManagerDelegate;
25 class ShellURLRequestContextGetter;
27 class ShellBrowserContext : public BrowserContext {
29 ShellBrowserContext(bool off_the_record, net::NetLog* net_log);
30 virtual ~ShellBrowserContext();
32 void set_guest_manager_delegate_for_testing(
33 BrowserPluginGuestManagerDelegate* guest_manager_delegate) {
34 guest_manager_delegate_ = guest_manager_delegate;
37 // BrowserContext implementation.
38 virtual base::FilePath GetPath() const OVERRIDE;
39 virtual bool IsOffTheRecord() const OVERRIDE;
40 virtual DownloadManagerDelegate* GetDownloadManagerDelegate() OVERRIDE;
41 virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE;
42 virtual net::URLRequestContextGetter* GetRequestContextForRenderProcess(
43 int renderer_child_id) OVERRIDE;
44 virtual net::URLRequestContextGetter* GetMediaRequestContext() OVERRIDE;
45 virtual net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess(
46 int renderer_child_id) OVERRIDE;
47 virtual net::URLRequestContextGetter*
48 GetMediaRequestContextForStoragePartition(
49 const base::FilePath& partition_path,
50 bool in_memory) OVERRIDE;
51 virtual void RequestMidiSysExPermission(
52 int render_process_id,
55 const GURL& requesting_frame,
57 const MidiSysExPermissionCallback& callback) OVERRIDE;
58 virtual void CancelMidiSysExPermissionRequest(
59 int render_process_id,
62 const GURL& requesting_frame) OVERRIDE;
63 virtual void RequestProtectedMediaIdentifierPermission(
64 int render_process_id,
68 const GURL& requesting_frame,
69 const ProtectedMediaIdentifierPermissionCallback& callback) OVERRIDE;
70 virtual void CancelProtectedMediaIdentifierPermissionRequests(
71 int group_id) OVERRIDE;
72 virtual ResourceContext* GetResourceContext() OVERRIDE;
73 virtual GeolocationPermissionContext*
74 GetGeolocationPermissionContext() OVERRIDE;
75 virtual content::BrowserPluginGuestManagerDelegate*
76 GetGuestManagerDelegate() OVERRIDE;
77 virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE;
79 net::URLRequestContextGetter* CreateRequestContext(
80 ProtocolHandlerMap* protocol_handlers,
81 ProtocolHandlerScopedVector protocol_interceptors);
82 net::URLRequestContextGetter* CreateRequestContextForStoragePartition(
83 const base::FilePath& partition_path,
85 ProtocolHandlerMap* protocol_handlers,
86 ProtocolHandlerScopedVector protocol_interceptors);
89 class ShellResourceContext;
91 // Performs initialization of the ShellBrowserContext while IO is still
92 // allowed on the current thread.
93 void InitWhileIOAllowed();
96 net::NetLog* net_log_;
97 bool ignore_certificate_errors_;
99 BrowserPluginGuestManagerDelegate* guest_manager_delegate_;
100 scoped_ptr<ShellResourceContext> resource_context_;
101 scoped_ptr<ShellDownloadManagerDelegate> download_manager_delegate_;
102 scoped_refptr<ShellURLRequestContextGetter> url_request_getter_;
104 DISALLOW_COPY_AND_ASSIGN(ShellBrowserContext);
107 } // namespace content
109 #endif // CONTENT_SHELL_BROWSER_SHELL_BROWSER_CONTEXT_H_