blob: 07802ee955e8b4510cefdd2a388e5c1b2e3a0dfa [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
8#include "base/compiler_specific.h"
[email protected]57999812013-02-24 05:40:529#include "base/files/file_path.h"
[email protected]b0f146f2011-09-15 22:14:2510#include "base/memory/ref_counted.h"
11#include "base/memory/scoped_ptr.h"
[email protected]ccb797302011-12-15 16:55:1112#include "content/public/browser/browser_context.h"
[email protected]672c8c12013-03-07 12:30:0613#include "content/public/browser/content_browser_client.h"
hanxi3328d992014-10-09 13:27:1114#include "content/public/browser/resource_context.h"
15#include "content/shell/browser/shell_url_request_context_getter.h"
[email protected]6bd30072013-02-08 18:17:1116#include "net/url_request/url_request_job_factory.h"
[email protected]b0f146f2011-09-15 22:14:2517
[email protected]d5869bf2013-07-03 16:21:4718namespace net {
19class NetLog;
20}
21
[email protected]b0f146f2011-09-15 22:14:2522namespace content {
23
[email protected]1bd0ef12011-10-20 05:24:1724class DownloadManagerDelegate;
mlamouri4e372022015-03-29 14:51:0625class PermissionManager;
[email protected]98d6f152011-09-29 19:35:5126class ShellDownloadManagerDelegate;
wjmacleancaa7d6d2014-11-12 16:42:1127class ZoomLevelDelegate;
[email protected]b0f146f2011-09-15 22:14:2528
29class ShellBrowserContext : public BrowserContext {
30 public:
[email protected]d5869bf2013-07-03 16:21:4731 ShellBrowserContext(bool off_the_record, net::NetLog* net_log);
dchenge933b3e2014-10-21 11:44:0932 ~ShellBrowserContext() override;
[email protected]b0f146f2011-09-15 22:14:2533
[email protected]139355f2014-05-11 14:21:2834 void set_guest_manager_for_testing(
35 BrowserPluginGuestManager* guest_manager) {
36 guest_manager_ = guest_manager;
[email protected]24569262014-05-06 03:31:3037 }
38
[email protected]b0f146f2011-09-15 22:14:2539 // BrowserContext implementation.
dchenge933b3e2014-10-21 11:44:0940 base::FilePath GetPath() const override;
wjmacleancaa7d6d2014-11-12 16:42:1141 scoped_ptr<ZoomLevelDelegate> CreateZoomLevelDelegate(
42 const base::FilePath& partition_path) override;
dchenge933b3e2014-10-21 11:44:0943 bool IsOffTheRecord() const override;
44 DownloadManagerDelegate* GetDownloadManagerDelegate() override;
45 net::URLRequestContextGetter* GetRequestContext() override;
46 net::URLRequestContextGetter* GetRequestContextForRenderProcess(
anand.ratn449f39a42014-10-06 13:45:5747 int renderer_child_id) override;
dchenge933b3e2014-10-21 11:44:0948 net::URLRequestContextGetter* GetMediaRequestContext() override;
49 net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess(
anand.ratn449f39a42014-10-06 13:45:5750 int renderer_child_id) override;
dchenge933b3e2014-10-21 11:44:0951 net::URLRequestContextGetter* GetMediaRequestContextForStoragePartition(
52 const base::FilePath& partition_path,
53 bool in_memory) override;
54 ResourceContext* GetResourceContext() override;
55 BrowserPluginGuestManager* GetGuestManager() override;
56 storage::SpecialStoragePolicy* GetSpecialStoragePolicy() override;
57 PushMessagingService* GetPushMessagingService() override;
58 SSLHostStateDelegate* GetSSLHostStateDelegate() override;
mlamouri4e372022015-03-29 14:51:0659 PermissionManager* GetPermissionManager() override;
[email protected]b0f146f2011-09-15 22:14:2560
[email protected]6bd30072013-02-08 18:17:1161 net::URLRequestContextGetter* CreateRequestContext(
[email protected]7571263c2014-03-10 22:57:0962 ProtocolHandlerMap* protocol_handlers,
[email protected]3b90aab2014-05-30 17:56:1563 URLRequestInterceptorScopedVector request_interceptors);
[email protected]6bd30072013-02-08 18:17:1164 net::URLRequestContextGetter* CreateRequestContextForStoragePartition(
[email protected]c42de732013-02-16 06:26:3165 const base::FilePath& partition_path,
[email protected]6bd30072013-02-08 18:17:1166 bool in_memory,
[email protected]7571263c2014-03-10 22:57:0967 ProtocolHandlerMap* protocol_handlers,
[email protected]3b90aab2014-05-30 17:56:1568 URLRequestInterceptorScopedVector request_interceptors);
[email protected]6bd30072013-02-08 18:17:1169
hanxi3328d992014-10-09 13:27:1170 protected:
71 // Contains URLRequestContextGetter required for resource loading.
72 class ShellResourceContext : public ResourceContext {
73 public:
74 ShellResourceContext();
dchenge933b3e2014-10-21 11:44:0975 ~ShellResourceContext() override;
hanxi3328d992014-10-09 13:27:1176
77 // ResourceContext implementation:
dchenge933b3e2014-10-21 11:44:0978 net::HostResolver* GetHostResolver() override;
79 net::URLRequestContext* GetRequestContext() override;
hanxi3328d992014-10-09 13:27:1180
81 void set_url_request_context_getter(ShellURLRequestContextGetter* getter) {
82 getter_ = getter;
83 }
84
85 private:
86 ShellURLRequestContextGetter* getter_;
87
88 DISALLOW_COPY_AND_ASSIGN(ShellResourceContext);
89 };
90
91 ShellURLRequestContextGetter* url_request_context_getter() {
92 return url_request_getter_.get();
93 }
94
95 // Used by ShellBrowserContext to initiate and set different types of
96 // URLRequestContextGetter.
mkwst94388f792014-10-16 07:36:5297 virtual ShellURLRequestContextGetter* CreateURLRequestContextGetter(
98 ProtocolHandlerMap* protocol_handlers,
99 URLRequestInterceptorScopedVector request_interceptors);
hanxi3328d992014-10-09 13:27:11100 void set_url_request_context_getter(ShellURLRequestContextGetter* getter) {
101 url_request_getter_ = getter;
102 }
103
mkwst94388f792014-10-16 07:36:52104 bool ignore_certificate_errors() const { return ignore_certificate_errors_; }
105 net::NetLog* net_log() const { return net_log_; }
106
mkwst98ce5ad2014-10-10 06:51:45107 scoped_ptr<ShellResourceContext> resource_context_;
mkwstd993d06a2014-10-10 11:44:38108 bool ignore_certificate_errors_;
109 scoped_ptr<ShellDownloadManagerDelegate> download_manager_delegate_;
mlamouri4e372022015-03-29 14:51:06110 scoped_ptr<PermissionManager> permission_manager_;
mkwst98ce5ad2014-10-10 06:51:45111
112 private:
apavlov297746b2014-10-10 08:25:26113 // Performs initialization of the ShellBrowserContext while IO is still
114 // allowed on the current thread.
115 void InitWhileIOAllowed();
116
[email protected]71d504f2012-07-25 17:15:28117 bool off_the_record_;
[email protected]d5869bf2013-07-03 16:21:47118 net::NetLog* net_log_;
[email protected]d30a36f2013-02-07 04:16:26119 base::FilePath path_;
[email protected]139355f2014-05-11 14:21:28120 BrowserPluginGuestManager* guest_manager_;
[email protected]6bd30072013-02-08 18:17:11121 scoped_refptr<ShellURLRequestContextGetter> url_request_getter_;
[email protected]b0f146f2011-09-15 22:14:25122
[email protected]b0f146f2011-09-15 22:14:25123 DISALLOW_COPY_AND_ASSIGN(ShellBrowserContext);
124};
125
126} // namespace content
127
[email protected]de7d61ff2013-08-20 11:30:41128#endif // CONTENT_SHELL_BROWSER_SHELL_BROWSER_CONTEXT_H_