media: Specify WebRTC owners in media OWNERS file.
[chromium-blink-merge.git] / chromecast / browser / cast_browser_context.cc
blobc1a4437f018963a7c651ec7960b76c6888bc0e22
1 // Copyright 2014 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 #include "chromecast/browser/cast_browser_context.h"
7 #include "base/command_line.h"
8 #include "base/files/file_util.h"
9 #include "base/macros.h"
10 #include "base/path_service.h"
11 #include "chromecast/browser/cast_download_manager_delegate.h"
12 #include "chromecast/browser/url_request_context_factory.h"
13 #include "chromecast/common/cast_paths.h"
14 #include "content/public/browser/browser_thread.h"
15 #include "content/public/browser/resource_context.h"
16 #include "content/public/browser/storage_partition.h"
17 #include "content/public/common/content_switches.h"
18 #include "net/url_request/url_request_context.h"
19 #include "net/url_request/url_request_context_getter.h"
21 namespace chromecast {
22 namespace shell {
24 class CastBrowserContext::CastResourceContext :
25 public content::ResourceContext {
26 public:
27 explicit CastResourceContext(
28 URLRequestContextFactory* url_request_context_factory) :
29 url_request_context_factory_(url_request_context_factory) {}
30 ~CastResourceContext() override {}
32 // ResourceContext implementation:
33 net::HostResolver* GetHostResolver() override {
34 return url_request_context_factory_->GetMainGetter()->
35 GetURLRequestContext()->host_resolver();
38 net::URLRequestContext* GetRequestContext() override {
39 return url_request_context_factory_->GetMainGetter()->
40 GetURLRequestContext();
43 private:
44 URLRequestContextFactory* url_request_context_factory_;
46 DISALLOW_COPY_AND_ASSIGN(CastResourceContext);
49 CastBrowserContext::CastBrowserContext(
50 URLRequestContextFactory* url_request_context_factory)
51 : url_request_context_factory_(url_request_context_factory),
52 resource_context_(new CastResourceContext(url_request_context_factory)),
53 download_manager_delegate_(new CastDownloadManagerDelegate()) {
54 InitWhileIOAllowed();
57 CastBrowserContext::~CastBrowserContext() {
58 content::BrowserThread::DeleteSoon(
59 content::BrowserThread::IO,
60 FROM_HERE,
61 resource_context_.release());
64 void CastBrowserContext::InitWhileIOAllowed() {
65 #if defined(OS_ANDROID)
66 CHECK(PathService::Get(base::DIR_ANDROID_APP_DATA, &path_));
67 path_ = path_.Append(FILE_PATH_LITERAL("cast_shell"));
69 if (!base::PathExists(path_))
70 base::CreateDirectory(path_);
71 #else
72 // Chromecast doesn't support user profiles nor does it have
73 // incognito mode. This means that all of the persistent
74 // data (currently only cookies and local storage) will be
75 // shared in a single location as defined here.
76 CHECK(PathService::Get(DIR_CAST_HOME, &path_));
77 #endif // defined(OS_ANDROID)
80 scoped_ptr<content::ZoomLevelDelegate>
81 CastBrowserContext::CreateZoomLevelDelegate(
82 const base::FilePath& partition_path) {
83 return nullptr;
86 base::FilePath CastBrowserContext::GetPath() const {
87 return path_;
90 bool CastBrowserContext::IsOffTheRecord() const {
91 return false;
94 net::URLRequestContextGetter* CastBrowserContext::GetRequestContext() {
95 return GetDefaultStoragePartition(this)->GetURLRequestContext();
98 net::URLRequestContextGetter*
99 CastBrowserContext::GetRequestContextForRenderProcess(int renderer_child_id) {
100 return GetRequestContext();
103 net::URLRequestContextGetter* CastBrowserContext::GetMediaRequestContext() {
104 return url_request_context_factory_->GetMediaGetter();
107 net::URLRequestContextGetter*
108 CastBrowserContext::GetMediaRequestContextForRenderProcess(
109 int renderer_child_id) {
110 return GetMediaRequestContext();
113 net::URLRequestContextGetter*
114 CastBrowserContext::GetMediaRequestContextForStoragePartition(
115 const base::FilePath& partition_path, bool in_memory) {
116 return GetMediaRequestContext();
119 net::URLRequestContextGetter* CastBrowserContext::GetSystemRequestContext() {
120 return url_request_context_factory_->GetSystemGetter();
123 content::ResourceContext* CastBrowserContext::GetResourceContext() {
124 return resource_context_.get();
127 content::DownloadManagerDelegate*
128 CastBrowserContext::GetDownloadManagerDelegate() {
129 return download_manager_delegate_.get();
132 content::BrowserPluginGuestManager* CastBrowserContext::GetGuestManager() {
133 NOTIMPLEMENTED();
134 return NULL;
137 storage::SpecialStoragePolicy* CastBrowserContext::GetSpecialStoragePolicy() {
138 NOTIMPLEMENTED();
139 return NULL;
142 content::PushMessagingService* CastBrowserContext::GetPushMessagingService() {
143 NOTIMPLEMENTED();
144 return NULL;
147 content::SSLHostStateDelegate* CastBrowserContext::GetSSLHostStateDelegate() {
148 NOTIMPLEMENTED();
149 return NULL;
152 } // namespace shell
153 } // namespace chromecast