blob: 660c6026c4b07909e7047a7831af158f9a27437f [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;
mcnee336ea2c2017-05-23 22:50:5930#if !defined(OS_ANDROID)
wjmacleancaa7d6d2014-11-12 16:42:1131class ZoomLevelDelegate;
mcnee336ea2c2017-05-23 22:50:5932#endif // !defined(OS_ANDROID)
[email protected]b0f146f2011-09-15 22:14:2533
34class ShellBrowserContext : public BrowserContext {
35 public:
[email protected]d5869bf2013-07-03 16:21:4736 ShellBrowserContext(bool off_the_record, net::NetLog* net_log);
dchenge933b3e2014-10-21 11:44:0937 ~ShellBrowserContext() override;
[email protected]b0f146f2011-09-15 22:14:2538
[email protected]139355f2014-05-11 14:21:2839 void set_guest_manager_for_testing(
40 BrowserPluginGuestManager* guest_manager) {
41 guest_manager_ = guest_manager;
[email protected]24569262014-05-06 03:31:3042 }
43
[email protected]b0f146f2011-09-15 22:14:2544 // BrowserContext implementation.
dchenge933b3e2014-10-21 11:44:0945 base::FilePath GetPath() const override;
mcnee336ea2c2017-05-23 22:50:5946#if !defined(OS_ANDROID)
dcheng6003e0b2016-04-09 18:42:3447 std::unique_ptr<ZoomLevelDelegate> CreateZoomLevelDelegate(
wjmacleancaa7d6d2014-11-12 16:42:1148 const base::FilePath& partition_path) override;
mcnee336ea2c2017-05-23 22:50:5949#endif // !defined(OS_ANDROID)
dchenge933b3e2014-10-21 11:44:0950 bool IsOffTheRecord() const override;
51 DownloadManagerDelegate* GetDownloadManagerDelegate() override;
dchenge933b3e2014-10-21 11:44:0952 ResourceContext* GetResourceContext() override;
53 BrowserPluginGuestManager* GetGuestManager() override;
54 storage::SpecialStoragePolicy* GetSpecialStoragePolicy() override;
55 PushMessagingService* GetPushMessagingService() override;
56 SSLHostStateDelegate* GetSSLHostStateDelegate() override;
mlamouri4e372022015-03-29 14:51:0657 PermissionManager* GetPermissionManager() override;
jkarlin6f5078ed2015-10-06 15:13:3558 BackgroundSyncController* GetBackgroundSyncController() override;
msramek86b6bc72017-05-31 12:21:1059 BrowsingDataRemoverDelegate* GetBrowsingDataRemoverDelegate() override;
[email protected]6bd30072013-02-08 18:17:1160 net::URLRequestContextGetter* CreateRequestContext(
[email protected]7571263c2014-03-10 22:57:0961 ProtocolHandlerMap* protocol_handlers,
jam547f2672016-04-07 21:16:2262 URLRequestInterceptorScopedVector request_interceptors) override;
[email protected]6bd30072013-02-08 18:17:1163 net::URLRequestContextGetter* CreateRequestContextForStoragePartition(
[email protected]c42de732013-02-16 06:26:3164 const base::FilePath& partition_path,
[email protected]6bd30072013-02-08 18:17:1165 bool in_memory,
[email protected]7571263c2014-03-10 22:57:0966 ProtocolHandlerMap* protocol_handlers,
jam547f2672016-04-07 21:16:2267 URLRequestInterceptorScopedVector request_interceptors) override;
jam2503f932016-04-15 20:08:3068 net::URLRequestContextGetter* CreateMediaRequestContext() override;
69 net::URLRequestContextGetter* CreateMediaRequestContextForStoragePartition(
70 const base::FilePath& partition_path,
71 bool in_memory) override;
[email protected]6bd30072013-02-08 18:17:1172
hanxi3328d992014-10-09 13:27:1173 protected:
74 // Contains URLRequestContextGetter required for resource loading.
75 class ShellResourceContext : public ResourceContext {
76 public:
77 ShellResourceContext();
dchenge933b3e2014-10-21 11:44:0978 ~ShellResourceContext() override;
hanxi3328d992014-10-09 13:27:1179
80 // ResourceContext implementation:
dchenge933b3e2014-10-21 11:44:0981 net::HostResolver* GetHostResolver() override;
82 net::URLRequestContext* GetRequestContext() override;
hanxi3328d992014-10-09 13:27:1183
84 void set_url_request_context_getter(ShellURLRequestContextGetter* getter) {
85 getter_ = getter;
86 }
87
88 private:
89 ShellURLRequestContextGetter* getter_;
90
91 DISALLOW_COPY_AND_ASSIGN(ShellResourceContext);
92 };
93
94 ShellURLRequestContextGetter* url_request_context_getter() {
95 return url_request_getter_.get();
96 }
97
98 // Used by ShellBrowserContext to initiate and set different types of
99 // URLRequestContextGetter.
mkwst94388f792014-10-16 07:36:52100 virtual ShellURLRequestContextGetter* CreateURLRequestContextGetter(
101 ProtocolHandlerMap* protocol_handlers,
102 URLRequestInterceptorScopedVector request_interceptors);
hanxi3328d992014-10-09 13:27:11103 void set_url_request_context_getter(ShellURLRequestContextGetter* getter) {
104 url_request_getter_ = getter;
105 }
106
mkwst94388f792014-10-16 07:36:52107 bool ignore_certificate_errors() const { return ignore_certificate_errors_; }
108 net::NetLog* net_log() const { return net_log_; }
109
dcheng6003e0b2016-04-09 18:42:34110 std::unique_ptr<ShellResourceContext> resource_context_;
mkwstd993d06a2014-10-10 11:44:38111 bool ignore_certificate_errors_;
dcheng6003e0b2016-04-09 18:42:34112 std::unique_ptr<ShellDownloadManagerDelegate> download_manager_delegate_;
113 std::unique_ptr<PermissionManager> permission_manager_;
114 std::unique_ptr<BackgroundSyncController> background_sync_controller_;
mkwst98ce5ad2014-10-10 06:51:45115
116 private:
apavlov297746b2014-10-10 08:25:26117 // Performs initialization of the ShellBrowserContext while IO is still
118 // allowed on the current thread.
119 void InitWhileIOAllowed();
120
[email protected]71d504f2012-07-25 17:15:28121 bool off_the_record_;
[email protected]d5869bf2013-07-03 16:21:47122 net::NetLog* net_log_;
[email protected]d30a36f2013-02-07 04:16:26123 base::FilePath path_;
[email protected]139355f2014-05-11 14:21:28124 BrowserPluginGuestManager* guest_manager_;
[email protected]6bd30072013-02-08 18:17:11125 scoped_refptr<ShellURLRequestContextGetter> url_request_getter_;
[email protected]b0f146f2011-09-15 22:14:25126
[email protected]b0f146f2011-09-15 22:14:25127 DISALLOW_COPY_AND_ASSIGN(ShellBrowserContext);
128};
129
130} // namespace content
131
[email protected]de7d61ff2013-08-20 11:30:41132#endif // CONTENT_SHELL_BROWSER_SHELL_BROWSER_CONTEXT_H_