Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / chromecast / shell / browser / cast_browser_context.cc
blob295c34b8d4a848bdfcb4b6b044e2f145f360af96
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/shell/browser/cast_browser_context.h"
7 #include "base/command_line.h"
8 #include "base/macros.h"
9 #include "base/path_service.h"
10 #include "chromecast/common/cast_paths.h"
11 #include "chromecast/shell/browser/url_request_context_factory.h"
12 #include "content/public/browser/browser_thread.h"
13 #include "content/public/browser/resource_context.h"
14 #include "content/public/browser/storage_partition.h"
15 #include "content/public/common/content_switches.h"
16 #include "net/url_request/url_request_context.h"
17 #include "net/url_request/url_request_context_getter.h"
19 namespace chromecast {
20 namespace shell {
22 class CastBrowserContext::CastResourceContext :
23 public content::ResourceContext {
24 public:
25 CastResourceContext(URLRequestContextFactory* url_request_context_factory) :
26 url_request_context_factory_(url_request_context_factory) {}
27 virtual ~CastResourceContext() {}
29 // ResourceContext implementation:
30 virtual net::HostResolver* GetHostResolver() OVERRIDE {
31 return url_request_context_factory_->GetMainGetter()->
32 GetURLRequestContext()->host_resolver();
35 virtual net::URLRequestContext* GetRequestContext() OVERRIDE {
36 return url_request_context_factory_->GetMainGetter()->
37 GetURLRequestContext();
40 virtual bool AllowMicAccess(const GURL& origin) OVERRIDE {
41 return false;
44 virtual bool AllowCameraAccess(const GURL& origin) OVERRIDE {
45 return false;
48 private:
49 URLRequestContextFactory* url_request_context_factory_;
51 DISALLOW_COPY_AND_ASSIGN(CastResourceContext);
54 CastBrowserContext::CastBrowserContext(
55 URLRequestContextFactory* url_request_context_factory)
56 : url_request_context_factory_(url_request_context_factory),
57 resource_context_(new CastResourceContext(url_request_context_factory)) {
58 InitWhileIOAllowed();
61 CastBrowserContext::~CastBrowserContext() {
64 void CastBrowserContext::InitWhileIOAllowed() {
65 // Chromecast doesn't support user profiles nor does it have
66 // incognito mode. This means that all of the persistent
67 // data (currently only cookies and local storage) will be
68 // shared in a single location as defined here.
69 CHECK(PathService::Get(DIR_CAST_HOME, &path_));
72 base::FilePath CastBrowserContext::GetPath() const {
73 return path_;
76 bool CastBrowserContext::IsOffTheRecord() const {
77 return false;
80 net::URLRequestContextGetter* CastBrowserContext::GetRequestContext() {
81 return GetDefaultStoragePartition(this)->GetURLRequestContext();
84 net::URLRequestContextGetter*
85 CastBrowserContext::GetRequestContextForRenderProcess(int renderer_child_id) {
86 return GetRequestContext();
89 net::URLRequestContextGetter* CastBrowserContext::GetMediaRequestContext() {
90 return url_request_context_factory_->GetMediaGetter();
93 net::URLRequestContextGetter*
94 CastBrowserContext::GetMediaRequestContextForRenderProcess(
95 int renderer_child_id) {
96 return GetMediaRequestContext();
99 net::URLRequestContextGetter*
100 CastBrowserContext::GetMediaRequestContextForStoragePartition(
101 const base::FilePath& partition_path, bool in_memory) {
102 return GetMediaRequestContext();
105 content::ResourceContext* CastBrowserContext::GetResourceContext() {
106 return resource_context_.get();
109 content::DownloadManagerDelegate*
110 CastBrowserContext::GetDownloadManagerDelegate() {
111 NOTIMPLEMENTED();
112 return NULL;
115 content::BrowserPluginGuestManager* CastBrowserContext::GetGuestManager() {
116 NOTIMPLEMENTED();
117 return NULL;
120 storage::SpecialStoragePolicy* CastBrowserContext::GetSpecialStoragePolicy() {
121 NOTIMPLEMENTED();
122 return NULL;
125 content::PushMessagingService* CastBrowserContext::GetPushMessagingService() {
126 NOTIMPLEMENTED();
127 return NULL;
130 content::SSLHostStateDelegate* CastBrowserContext::GetSSLHostStateDelegate() {
131 NOTIMPLEMENTED();
132 return NULL;
135 } // namespace shell
136 } // namespace chromecast