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/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 content::ResourceContext* CastBrowserContext::GetResourceContext() { |
| 105 return resource_context_.get(); |
| 106 } |
| 107 |
| 108 content::DownloadManagerDelegate* |
| 109 CastBrowserContext::GetDownloadManagerDelegate() { |
| 110 NOTIMPLEMENTED(); |
| 111 return NULL; |
| 112 } |
| 113 |
| 114 content::BrowserPluginGuestManager* CastBrowserContext::GetGuestManager() { |
| 115 NOTIMPLEMENTED(); |
| 116 return NULL; |
| 117 } |
| 118 |
| 119 quota::SpecialStoragePolicy* CastBrowserContext::GetSpecialStoragePolicy() { |
| 120 NOTIMPLEMENTED(); |
| 121 return NULL; |
| 122 } |
| 123 |
| 124 content::PushMessagingService* CastBrowserContext::GetPushMessagingService() { |
| 125 NOTIMPLEMENTED(); |
| 126 return NULL; |
| 127 } |
| 128 |
| 129 } // namespace shell |
| 130 } // namespace chromecast |
OLD | NEW |