Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / chromecast / shell / browser / cast_browser_context.cc
index ac1f22f..b0280f6 100644 (file)
@@ -5,9 +5,11 @@
 #include "chromecast/shell/browser/cast_browser_context.h"
 
 #include "base/command_line.h"
+#include "base/files/file_util.h"
 #include "base/macros.h"
 #include "base/path_service.h"
 #include "chromecast/common/cast_paths.h"
+#include "chromecast/shell/browser/cast_download_manager_delegate.h"
 #include "chromecast/shell/browser/url_request_context_factory.h"
 #include "content/public/browser/browser_thread.h"
 #include "content/public/browser/resource_context.h"
@@ -22,7 +24,8 @@ namespace shell {
 class CastBrowserContext::CastResourceContext :
     public content::ResourceContext {
  public:
-  CastResourceContext(URLRequestContextFactory* url_request_context_factory) :
+  explicit CastResourceContext(
+      URLRequestContextFactory* url_request_context_factory) :
     url_request_context_factory_(url_request_context_factory) {}
   virtual ~CastResourceContext() {}
 
@@ -37,14 +40,6 @@ class CastBrowserContext::CastResourceContext :
         GetURLRequestContext();
   }
 
-  virtual bool AllowMicAccess(const GURL& origin) OVERRIDE {
-    return false;
-  }
-
-  virtual bool AllowCameraAccess(const GURL& origin) OVERRIDE {
-    return false;
-  }
-
  private:
   URLRequestContextFactory* url_request_context_factory_;
 
@@ -54,19 +49,32 @@ class CastBrowserContext::CastResourceContext :
 CastBrowserContext::CastBrowserContext(
     URLRequestContextFactory* url_request_context_factory)
     : url_request_context_factory_(url_request_context_factory),
-      resource_context_(new CastResourceContext(url_request_context_factory)) {
+      resource_context_(new CastResourceContext(url_request_context_factory)),
+      download_manager_delegate_(new CastDownloadManagerDelegate()) {
   InitWhileIOAllowed();
 }
 
 CastBrowserContext::~CastBrowserContext() {
+  content::BrowserThread::DeleteSoon(
+      content::BrowserThread::IO,
+      FROM_HERE,
+      resource_context_.release());
 }
 
 void CastBrowserContext::InitWhileIOAllowed() {
+#if defined(OS_ANDROID)
+  CHECK(PathService::Get(base::DIR_ANDROID_APP_DATA, &path_));
+  path_ = path_.Append(FILE_PATH_LITERAL("cast_shell"));
+
+  if (!base::PathExists(path_))
+    base::CreateDirectory(path_);
+#else
   // Chromecast doesn't support user profiles nor does it have
   // incognito mode.  This means that all of the persistent
   // data (currently only cookies and local storage) will be
   // shared in a single location as defined here.
   CHECK(PathService::Get(DIR_CAST_HOME, &path_));
+#endif  // defined(OS_ANDROID)
 }
 
 base::FilePath CastBrowserContext::GetPath() const {
@@ -108,8 +116,7 @@ content::ResourceContext* CastBrowserContext::GetResourceContext() {
 
 content::DownloadManagerDelegate*
 CastBrowserContext::GetDownloadManagerDelegate() {
-  NOTIMPLEMENTED();
-  return NULL;
+  return download_manager_delegate_.get();
 }
 
 content::BrowserPluginGuestManager* CastBrowserContext::GetGuestManager() {
@@ -117,7 +124,7 @@ content::BrowserPluginGuestManager* CastBrowserContext::GetGuestManager() {
   return NULL;
 }
 
-quota::SpecialStoragePolicy* CastBrowserContext::GetSpecialStoragePolicy() {
+storage::SpecialStoragePolicy* CastBrowserContext::GetSpecialStoragePolicy() {
   NOTIMPLEMENTED();
   return NULL;
 }