blob: 72ed634ba2ac6e33fa8e6cab720008c8872a33ee [file] [log] [blame]
[email protected]de7d61ff2013-08-20 11:30:411// Copyright 2013 The Chromium Authors. All rights reserved.
[email protected]b0f146f2011-09-15 22:14:252// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]de7d61ff2013-08-20 11:30:415#ifndef CONTENT_SHELL_BROWSER_SHELL_BROWSER_CONTEXT_H_
6#define CONTENT_SHELL_BROWSER_SHELL_BROWSER_CONTEXT_H_
[email protected]b0f146f2011-09-15 22:14:257
dcheng6003e0b2016-04-09 18:42:348#include <memory>
9
[email protected]b0f146f2011-09-15 22:14:2510#include "base/compiler_specific.h"
[email protected]57999812013-02-24 05:40:5211#include "base/files/file_path.h"
avi66a07722015-12-25 23:38:1212#include "base/macros.h"
[email protected]b0f146f2011-09-15 22:14:2513#include "base/memory/ref_counted.h"
[email protected]ccb797302011-12-15 16:55:1114#include "content/public/browser/browser_context.h"
[email protected]672c8c12013-03-07 12:30:0615#include "content/public/browser/content_browser_client.h"
hanxi3328d992014-10-09 13:27:1116#include "content/public/browser/resource_context.h"
17#include "content/shell/browser/shell_url_request_context_getter.h"
[email protected]6bd30072013-02-08 18:17:1118#include "net/url_request/url_request_job_factory.h"
[email protected]b0f146f2011-09-15 22:14:2519
[email protected]d5869bf2013-07-03 16:21:4720namespace net {
21class NetLog;
22}
23
[email protected]b0f146f2011-09-15 22:14:2524namespace content {
25
jkarlin6f5078ed2015-10-06 15:13:3526class BackgroundSyncController;
[email protected]1bd0ef12011-10-20 05:24:1727class DownloadManagerDelegate;
mlamouri4e372022015-03-29 14:51:0628class PermissionManager;
[email protected]98d6f152011-09-29 19:35:5129class ShellDownloadManagerDelegate;
wjmacleancaa7d6d2014-11-12 16:42:1130class ZoomLevelDelegate;
[email protected]b0f146f2011-09-15 22:14:2531
32class ShellBrowserContext : public BrowserContext {
33 public:
[email protected]d5869bf2013-07-03 16:21:4734 ShellBrowserContext(bool off_the_record, net::NetLog* net_log);
dchenge933b3e2014-10-21 11:44:0935 ~ShellBrowserContext() override;
[email protected]b0f146f2011-09-15 22:14:2536
[email protected]139355f2014-05-11 14:21:2837 void set_guest_manager_for_testing(
38 BrowserPluginGuestManager* guest_manager) {
39 guest_manager_ = guest_manager;
[email protected]24569262014-05-06 03:31:3040 }
41
[email protected]b0f146f2011-09-15 22:14:2542 // BrowserContext implementation.
dchenge933b3e2014-10-21 11:44:0943 base::FilePath GetPath() const override;
dcheng6003e0b2016-04-09 18:42:3444 std::unique_ptr<ZoomLevelDelegate> CreateZoomLevelDelegate(
wjmacleancaa7d6d2014-11-12 16:42:1145 const base::FilePath& partition_path) override;
dchenge933b3e2014-10-21 11:44:0946 bool IsOffTheRecord() const override;
47 DownloadManagerDelegate* GetDownloadManagerDelegate() override;
48 net::URLRequestContextGetter* GetRequestContext() override;
dchenge933b3e2014-10-21 11:44:0949 net::URLRequestContextGetter* GetMediaRequestContext() override;
50 net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess(
anand.ratn449f39a42014-10-06 13:45:5751 int renderer_child_id) override;
dchenge933b3e2014-10-21 11:44:0952 net::URLRequestContextGetter* GetMediaRequestContextForStoragePartition(
53 const base::FilePath& partition_path,
54 bool in_memory) override;
55 ResourceContext* GetResourceContext() override;
56 BrowserPluginGuestManager* GetGuestManager() override;
57 storage::SpecialStoragePolicy* GetSpecialStoragePolicy() override;
58 PushMessagingService* GetPushMessagingService() override;
59 SSLHostStateDelegate* GetSSLHostStateDelegate() override;
mlamouri4e372022015-03-29 14:51:0660 PermissionManager* GetPermissionManager() override;
jkarlin6f5078ed2015-10-06 15:13:3561 BackgroundSyncController* GetBackgroundSyncController() override;
[email protected]6bd30072013-02-08 18:17:1162 net::URLRequestContextGetter* CreateRequestContext(
[email protected]7571263c2014-03-10 22:57:0963 ProtocolHandlerMap* protocol_handlers,
jam547f2672016-04-07 21:16:2264 URLRequestInterceptorScopedVector request_interceptors) override;
[email protected]6bd30072013-02-08 18:17:1165 net::URLRequestContextGetter* CreateRequestContextForStoragePartition(
[email protected]c42de732013-02-16 06:26:3166 const base::FilePath& partition_path,
[email protected]6bd30072013-02-08 18:17:1167 bool in_memory,
[email protected]7571263c2014-03-10 22:57:0968 ProtocolHandlerMap* protocol_handlers,
jam547f2672016-04-07 21:16:2269 URLRequestInterceptorScopedVector request_interceptors) override;
[email protected]6bd30072013-02-08 18:17:1170
hanxi3328d992014-10-09 13:27:1171 protected:
72 // Contains URLRequestContextGetter required for resource loading.
73 class ShellResourceContext : public ResourceContext {
74 public:
75 ShellResourceContext();
dchenge933b3e2014-10-21 11:44:0976 ~ShellResourceContext() override;
hanxi3328d992014-10-09 13:27:1177
78 // ResourceContext implementation:
dchenge933b3e2014-10-21 11:44:0979 net::HostResolver* GetHostResolver() override;
80 net::URLRequestContext* GetRequestContext() override;
hanxi3328d992014-10-09 13:27:1181
82 void set_url_request_context_getter(ShellURLRequestContextGetter* getter) {
83 getter_ = getter;
84 }
85
86 private:
87 ShellURLRequestContextGetter* getter_;
88
89 DISALLOW_COPY_AND_ASSIGN(ShellResourceContext);
90 };
91
92 ShellURLRequestContextGetter* url_request_context_getter() {
93 return url_request_getter_.get();
94 }
95
96 // Used by ShellBrowserContext to initiate and set different types of
97 // URLRequestContextGetter.
mkwst94388f792014-10-16 07:36:5298 virtual ShellURLRequestContextGetter* CreateURLRequestContextGetter(
99 ProtocolHandlerMap* protocol_handlers,
100 URLRequestInterceptorScopedVector request_interceptors);
hanxi3328d992014-10-09 13:27:11101 void set_url_request_context_getter(ShellURLRequestContextGetter* getter) {
102 url_request_getter_ = getter;
103 }
104
mkwst94388f792014-10-16 07:36:52105 bool ignore_certificate_errors() const { return ignore_certificate_errors_; }
106 net::NetLog* net_log() const { return net_log_; }
107
dcheng6003e0b2016-04-09 18:42:34108 std::unique_ptr<ShellResourceContext> resource_context_;
mkwstd993d06a2014-10-10 11:44:38109 bool ignore_certificate_errors_;
dcheng6003e0b2016-04-09 18:42:34110 std::unique_ptr<ShellDownloadManagerDelegate> download_manager_delegate_;
111 std::unique_ptr<PermissionManager> permission_manager_;
112 std::unique_ptr<BackgroundSyncController> background_sync_controller_;
mkwst98ce5ad2014-10-10 06:51:45113
114 private:
apavlov297746b2014-10-10 08:25:26115 // Performs initialization of the ShellBrowserContext while IO is still
116 // allowed on the current thread.
117 void InitWhileIOAllowed();
118
[email protected]71d504f2012-07-25 17:15:28119 bool off_the_record_;
[email protected]d5869bf2013-07-03 16:21:47120 net::NetLog* net_log_;
[email protected]d30a36f2013-02-07 04:16:26121 base::FilePath path_;
[email protected]139355f2014-05-11 14:21:28122 BrowserPluginGuestManager* guest_manager_;
[email protected]6bd30072013-02-08 18:17:11123 scoped_refptr<ShellURLRequestContextGetter> url_request_getter_;
[email protected]b0f146f2011-09-15 22:14:25124
[email protected]b0f146f2011-09-15 22:14:25125 DISALLOW_COPY_AND_ASSIGN(ShellBrowserContext);
126};
127
128} // namespace content
129
[email protected]de7d61ff2013-08-20 11:30:41130#endif // CONTENT_SHELL_BROWSER_SHELL_BROWSER_CONTEXT_H_