blob: b840d785db72e34cb6c416cde92f3ef8d5e7d419 [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;
[email protected]98d6f152011-09-29 19:35:5125class ShellDownloadManagerDelegate;
[email protected]b0f146f2011-09-15 22:14:2526
27class ShellBrowserContext : public BrowserContext {
28 public:
[email protected]d5869bf2013-07-03 16:21:4729 ShellBrowserContext(bool off_the_record, net::NetLog* net_log);
[email protected]3560b572012-04-04 20:47:3230 virtual ~ShellBrowserContext();
[email protected]b0f146f2011-09-15 22:14:2531
[email protected]139355f2014-05-11 14:21:2832 void set_guest_manager_for_testing(
33 BrowserPluginGuestManager* guest_manager) {
34 guest_manager_ = guest_manager;
[email protected]24569262014-05-06 03:31:3035 }
36
[email protected]b0f146f2011-09-15 22:14:2537 // BrowserContext implementation.
anand.ratn449f39a42014-10-06 13:45:5738 virtual base::FilePath GetPath() const override;
39 virtual bool IsOffTheRecord() const override;
40 virtual DownloadManagerDelegate* GetDownloadManagerDelegate() override;
41 virtual net::URLRequestContextGetter* GetRequestContext() override;
[email protected]b0f146f2011-09-15 22:14:2542 virtual net::URLRequestContextGetter* GetRequestContextForRenderProcess(
anand.ratn449f39a42014-10-06 13:45:5743 int renderer_child_id) override;
44 virtual net::URLRequestContextGetter* GetMediaRequestContext() override;
[email protected]10705a7b2012-08-21 19:07:0845 virtual net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess(
anand.ratn449f39a42014-10-06 13:45:5746 int renderer_child_id) override;
[email protected]10eb28162012-09-18 03:04:0947 virtual net::URLRequestContextGetter*
48 GetMediaRequestContextForStoragePartition(
[email protected]d30a36f2013-02-07 04:16:2649 const base::FilePath& partition_path,
anand.ratn449f39a42014-10-06 13:45:5750 bool in_memory) override;
51 virtual ResourceContext* GetResourceContext() override;
52 virtual BrowserPluginGuestManager* GetGuestManager() override;
53 virtual storage::SpecialStoragePolicy* GetSpecialStoragePolicy() override;
54 virtual PushMessagingService* GetPushMessagingService() override;
55 virtual SSLHostStateDelegate* GetSSLHostStateDelegate() override;
[email protected]b0f146f2011-09-15 22:14:2556
[email protected]6bd30072013-02-08 18:17:1157 net::URLRequestContextGetter* CreateRequestContext(
[email protected]7571263c2014-03-10 22:57:0958 ProtocolHandlerMap* protocol_handlers,
[email protected]3b90aab2014-05-30 17:56:1559 URLRequestInterceptorScopedVector request_interceptors);
[email protected]6bd30072013-02-08 18:17:1160 net::URLRequestContextGetter* CreateRequestContextForStoragePartition(
[email protected]c42de732013-02-16 06:26:3161 const base::FilePath& partition_path,
[email protected]6bd30072013-02-08 18:17:1162 bool in_memory,
[email protected]7571263c2014-03-10 22:57:0963 ProtocolHandlerMap* protocol_handlers,
[email protected]3b90aab2014-05-30 17:56:1564 URLRequestInterceptorScopedVector request_interceptors);
[email protected]6bd30072013-02-08 18:17:1165
hanxi3328d992014-10-09 13:27:1166 protected:
67 // Contains URLRequestContextGetter required for resource loading.
68 class ShellResourceContext : public ResourceContext {
69 public:
70 ShellResourceContext();
71 virtual ~ShellResourceContext();
72
73 // ResourceContext implementation:
74 virtual net::HostResolver* GetHostResolver() override;
75 virtual net::URLRequestContext* GetRequestContext() override;
76
77 void set_url_request_context_getter(ShellURLRequestContextGetter* getter) {
78 getter_ = getter;
79 }
80
81 private:
82 ShellURLRequestContextGetter* getter_;
83
84 DISALLOW_COPY_AND_ASSIGN(ShellResourceContext);
85 };
86
87 ShellURLRequestContextGetter* url_request_context_getter() {
88 return url_request_getter_.get();
89 }
90
91 // Used by ShellBrowserContext to initiate and set different types of
92 // URLRequestContextGetter.
93 void set_url_request_context_getter(ShellURLRequestContextGetter* getter) {
94 url_request_getter_ = getter;
95 }
96
mkwst98ce5ad2014-10-10 06:51:4597 scoped_ptr<ShellResourceContext> resource_context_;
mkwstd993d06a2014-10-10 11:44:3898 bool ignore_certificate_errors_;
99 scoped_ptr<ShellDownloadManagerDelegate> download_manager_delegate_;
mkwst98ce5ad2014-10-10 06:51:45100
101 private:
apavlov297746b2014-10-10 08:25:26102 // Performs initialization of the ShellBrowserContext while IO is still
103 // allowed on the current thread.
104 void InitWhileIOAllowed();
105
[email protected]71d504f2012-07-25 17:15:28106 bool off_the_record_;
[email protected]d5869bf2013-07-03 16:21:47107 net::NetLog* net_log_;
[email protected]d30a36f2013-02-07 04:16:26108 base::FilePath path_;
[email protected]139355f2014-05-11 14:21:28109 BrowserPluginGuestManager* guest_manager_;
[email protected]6bd30072013-02-08 18:17:11110 scoped_refptr<ShellURLRequestContextGetter> url_request_getter_;
[email protected]b0f146f2011-09-15 22:14:25111
[email protected]b0f146f2011-09-15 22:14:25112 DISALLOW_COPY_AND_ASSIGN(ShellBrowserContext);
113};
114
115} // namespace content
116
[email protected]de7d61ff2013-08-20 11:30:41117#endif // CONTENT_SHELL_BROWSER_SHELL_BROWSER_CONTEXT_H_