Made top controls work with virtual viewport pinch-to-zoom. (Chromium)
[chromium-blink-merge.git] / chromecast / shell / browser / cast_browser_context.cc
blobe3d3e75336859a86c0c48fa416a745f5b196e469
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/files/file_util.h"
9 #include "base/macros.h"
10 #include "base/path_service.h"
11 #include "chromecast/common/cast_paths.h"
12 #include "chromecast/shell/browser/cast_download_manager_delegate.h"
13 #include "chromecast/shell/browser/url_request_context_factory.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 virtual ~CastResourceContext() {}
32 // ResourceContext implementation:
33 virtual net::HostResolver* GetHostResolver() override {
34 return url_request_context_factory_->GetMainGetter()->
35 GetURLRequestContext()->host_resolver();
38 virtual 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 base::FilePath CastBrowserContext::GetPath() const {
81 return path_;
84 bool CastBrowserContext::IsOffTheRecord() const {
85 return false;
88 net::URLRequestContextGetter* CastBrowserContext::GetRequestContext() {
89 return GetDefaultStoragePartition(this)->GetURLRequestContext();
92 net::URLRequestContextGetter*
93 CastBrowserContext::GetRequestContextForRenderProcess(int renderer_child_id) {
94 return GetRequestContext();
97 net::URLRequestContextGetter* CastBrowserContext::GetMediaRequestContext() {
98 return url_request_context_factory_->GetMediaGetter();
101 net::URLRequestContextGetter*
102 CastBrowserContext::GetMediaRequestContextForRenderProcess(
103 int renderer_child_id) {
104 return GetMediaRequestContext();
107 net::URLRequestContextGetter*
108 CastBrowserContext::GetMediaRequestContextForStoragePartition(
109 const base::FilePath& partition_path, bool in_memory) {
110 return GetMediaRequestContext();
113 content::ResourceContext* CastBrowserContext::GetResourceContext() {
114 return resource_context_.get();
117 content::DownloadManagerDelegate*
118 CastBrowserContext::GetDownloadManagerDelegate() {
119 return download_manager_delegate_.get();
122 content::BrowserPluginGuestManager* CastBrowserContext::GetGuestManager() {
123 NOTIMPLEMENTED();
124 return NULL;
127 storage::SpecialStoragePolicy* CastBrowserContext::GetSpecialStoragePolicy() {
128 NOTIMPLEMENTED();
129 return NULL;
132 content::PushMessagingService* CastBrowserContext::GetPushMessagingService() {
133 NOTIMPLEMENTED();
134 return NULL;
137 content::SSLHostStateDelegate* CastBrowserContext::GetSSLHostStateDelegate() {
138 NOTIMPLEMENTED();
139 return NULL;
142 } // namespace shell
143 } // namespace chromecast