OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 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. |
| 4 |
| 5 #include "chromecast/shell/browser/cast_browser_context.h" |
| 6 |
| 7 #include "base/command_line.h" |
| 8 #include "base/path_service.h" |
| 9 #include "chromecast/common/cast_paths.h" |
| 10 #include "chromecast/shell/browser/url_request_context_factory.h" |
| 11 #include "content/public/browser/browser_thread.h" |
| 12 #include "content/public/browser/resource_context.h" |
| 13 #include "content/public/browser/storage_partition.h" |
| 14 #include "content/public/common/content_switches.h" |
| 15 #include "net/url_request/url_request_context.h" |
| 16 #include "net/url_request/url_request_context_getter.h" |
| 17 |
| 18 namespace chromecast { |
| 19 namespace shell { |
| 20 |
| 21 class CastBrowserContext::CastResourceContext : |
| 22 public content::ResourceContext { |
| 23 public: |
| 24 CastResourceContext(URLRequestContextFactory* url_request_context_factory) : |
| 25 url_request_context_factory_(url_request_context_factory) {} |
| 26 virtual ~CastResourceContext() {} |
| 27 |
| 28 // ResourceContext implementation: |
| 29 virtual net::HostResolver* GetHostResolver() OVERRIDE { |
| 30 return url_request_context_factory_->GetMainGetter()-> |
| 31 GetURLRequestContext()->host_resolver(); |
| 32 } |
| 33 |
| 34 virtual net::URLRequestContext* GetRequestContext() OVERRIDE { |
| 35 return url_request_context_factory_->GetMainGetter()-> |
| 36 GetURLRequestContext(); |
| 37 } |
| 38 |
| 39 virtual bool AllowMicAccess(const GURL& origin) OVERRIDE { |
| 40 return false; |
| 41 } |
| 42 |
| 43 virtual bool AllowCameraAccess(const GURL& origin) OVERRIDE { |
| 44 return false; |
| 45 } |
| 46 |
| 47 private: |
| 48 URLRequestContextFactory* url_request_context_factory_; |
| 49 |
| 50 DISALLOW_COPY_AND_ASSIGN(CastResourceContext); |
| 51 }; |
| 52 |
| 53 CastBrowserContext::CastBrowserContext( |
| 54 URLRequestContextFactory* url_request_context_factory) |
| 55 : url_request_context_factory_(url_request_context_factory), |
| 56 resource_context_(new CastResourceContext(url_request_context_factory)) { |
| 57 InitWhileIOAllowed(); |
| 58 } |
| 59 |
| 60 CastBrowserContext::~CastBrowserContext() { |
| 61 } |
| 62 |
| 63 void CastBrowserContext::InitWhileIOAllowed() { |
| 64 // On Chromecast, we don't support user profiles nor do we have |
| 65 // incognito mode. This means that all of the persistent |
| 66 // data (currently only cookies and local storage) will be |
| 67 // shared in a single location as defined here. |
| 68 CHECK(PathService::Get(DIR_CAST_HOME, &path_)); |
| 69 } |
| 70 |
| 71 base::FilePath CastBrowserContext::GetPath() const { |
| 72 return path_; |
| 73 } |
| 74 |
| 75 bool CastBrowserContext::IsOffTheRecord() const { |
| 76 return false; |
| 77 } |
| 78 |
| 79 net::URLRequestContextGetter* CastBrowserContext::GetRequestContext() { |
| 80 return GetDefaultStoragePartition(this)->GetURLRequestContext(); |
| 81 } |
| 82 |
| 83 net::URLRequestContextGetter* |
| 84 CastBrowserContext::GetRequestContextForRenderProcess(int renderer_child_id) { |
| 85 return GetRequestContext(); |
| 86 } |
| 87 |
| 88 net::URLRequestContextGetter* CastBrowserContext::GetMediaRequestContext() { |
| 89 return url_request_context_factory_->GetMediaGetter(); |
| 90 } |
| 91 |
| 92 net::URLRequestContextGetter* |
| 93 CastBrowserContext::GetMediaRequestContextForRenderProcess( |
| 94 int renderer_child_id) { |
| 95 return GetMediaRequestContext(); |
| 96 } |
| 97 |
| 98 net::URLRequestContextGetter* |
| 99 CastBrowserContext::GetMediaRequestContextForStoragePartition( |
| 100 const base::FilePath& partition_path, bool in_memory) { |
| 101 return GetMediaRequestContext(); |
| 102 } |
| 103 |
| 104 void CastBrowserContext::RequestMidiSysExPermission( |
| 105 int render_process_id, |
| 106 int render_view_id, |
| 107 int bridge_id, |
| 108 const GURL& requesting_frame, |
| 109 bool user_gesture, |
| 110 const MidiSysExPermissionCallback& callback) { |
| 111 // Always reject requests for testing. |
| 112 callback.Run(false); |
| 113 } |
| 114 |
| 115 void CastBrowserContext::CancelMidiSysExPermissionRequest( |
| 116 int render_process_id, |
| 117 int render_view_id, |
| 118 int bridge_id, |
| 119 const GURL& requesting_frame) { |
| 120 } |
| 121 |
| 122 void CastBrowserContext::RequestProtectedMediaIdentifierPermission( |
| 123 int render_process_id, |
| 124 int render_view_id, |
| 125 int bridge_id, |
| 126 int group_id, |
| 127 const GURL& requesting_frame, |
| 128 const ProtectedMediaIdentifierPermissionCallback& callback) { |
| 129 callback.Run(true); |
| 130 } |
| 131 |
| 132 void CastBrowserContext::CancelProtectedMediaIdentifierPermissionRequests( |
| 133 int group_id) { |
| 134 } |
| 135 |
| 136 content::ResourceContext* CastBrowserContext::GetResourceContext() { |
| 137 return resource_context_.get(); |
| 138 } |
| 139 |
| 140 content::DownloadManagerDelegate* |
| 141 CastBrowserContext::GetDownloadManagerDelegate() { |
| 142 NOTIMPLEMENTED(); |
| 143 return NULL; |
| 144 } |
| 145 |
| 146 content::GeolocationPermissionContext* |
| 147 CastBrowserContext::GetGeolocationPermissionContext() { |
| 148 NOTIMPLEMENTED(); |
| 149 return NULL; |
| 150 } |
| 151 |
| 152 quota::SpecialStoragePolicy* CastBrowserContext::GetSpecialStoragePolicy() { |
| 153 NOTIMPLEMENTED(); |
| 154 return NULL; |
| 155 } |
| 156 |
| 157 } // namespace shell |
| 158 } // namespace chromecast |
OLD | NEW |