OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #include "chromecast/shell/browser/cast_browser_context.h" |
| 6 |
| 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" |
| 18 |
| 19 namespace chromecast { |
| 20 namespace shell { |
| 21 |
| 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() {} |
| 28 |
| 29 // ResourceContext implementation: |
| 30 virtual net::HostResolver* GetHostResolver() OVERRIDE { |
| 31 return url_request_context_factory_->GetMainGetter()-> |
| 32 GetURLRequestContext()->host_resolver(); |
| 33 } |
| 34 |
| 35 virtual net::URLRequestContext* GetRequestContext() OVERRIDE { |
| 36 return url_request_context_factory_->GetMainGetter()-> |
| 37 GetURLRequestContext(); |
| 38 } |
| 39 |
| 40 virtual bool AllowMicAccess(const GURL& origin) OVERRIDE { |
| 41 return false; |
| 42 } |
| 43 |
| 44 virtual bool AllowCameraAccess(const GURL& origin) OVERRIDE { |
| 45 return false; |
| 46 } |
| 47 |
| 48 private: |
| 49 URLRequestContextFactory* url_request_context_factory_; |
| 50 |
| 51 DISALLOW_COPY_AND_ASSIGN(CastResourceContext); |
| 52 }; |
| 53 |
| 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(); |
| 59 } |
| 60 |
| 61 CastBrowserContext::~CastBrowserContext() { |
| 62 } |
| 63 |
| 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_)); |
| 70 } |
| 71 |
| 72 base::FilePath CastBrowserContext::GetPath() const { |
| 73 return path_; |
| 74 } |
| 75 |
| 76 bool CastBrowserContext::IsOffTheRecord() const { |
| 77 return false; |
| 78 } |
| 79 |
| 80 net::URLRequestContextGetter* CastBrowserContext::GetRequestContext() { |
| 81 return GetDefaultStoragePartition(this)->GetURLRequestContext(); |
| 82 } |
| 83 |
| 84 net::URLRequestContextGetter* |
| 85 CastBrowserContext::GetRequestContextForRenderProcess(int renderer_child_id) { |
| 86 return GetRequestContext(); |
| 87 } |
| 88 |
| 89 net::URLRequestContextGetter* CastBrowserContext::GetMediaRequestContext() { |
| 90 return url_request_context_factory_->GetMediaGetter(); |
| 91 } |
| 92 |
| 93 net::URLRequestContextGetter* |
| 94 CastBrowserContext::GetMediaRequestContextForRenderProcess( |
| 95 int renderer_child_id) { |
| 96 return GetMediaRequestContext(); |
| 97 } |
| 98 |
| 99 net::URLRequestContextGetter* |
| 100 CastBrowserContext::GetMediaRequestContextForStoragePartition( |
| 101 const base::FilePath& partition_path, bool in_memory) { |
| 102 return GetMediaRequestContext(); |
| 103 } |
| 104 |
| 105 content::ResourceContext* CastBrowserContext::GetResourceContext() { |
| 106 return resource_context_.get(); |
| 107 } |
| 108 |
| 109 content::DownloadManagerDelegate* |
| 110 CastBrowserContext::GetDownloadManagerDelegate() { |
| 111 NOTIMPLEMENTED(); |
| 112 return NULL; |
| 113 } |
| 114 |
| 115 content::BrowserPluginGuestManager* CastBrowserContext::GetGuestManager() { |
| 116 NOTIMPLEMENTED(); |
| 117 return NULL; |
| 118 } |
| 119 |
| 120 quota::SpecialStoragePolicy* CastBrowserContext::GetSpecialStoragePolicy() { |
| 121 NOTIMPLEMENTED(); |
| 122 return NULL; |
| 123 } |
| 124 |
| 125 content::PushMessagingService* CastBrowserContext::GetPushMessagingService() { |
| 126 NOTIMPLEMENTED(); |
| 127 return NULL; |
| 128 } |
| 129 |
| 130 } // namespace shell |
| 131 } // namespace chromecast |
OLD | NEW |