Commit a88fa855 authored by gunsch's avatar gunsch Committed by Commit bot

Chromecast: disables downloads from the Chromecast shell.

R=lcwu@chromium.org
BUG=336640

Review URL: https://codereview.chromium.org/602593004

Cr-Commit-Position: refs/heads/master@{#296615}
parent e6a5d22f
......@@ -222,6 +222,8 @@
'shell/browser/cast_browser_process.h',
'shell/browser/cast_content_browser_client.cc',
'shell/browser/cast_content_browser_client.h',
'shell/browser/cast_download_manager_delegate.cc',
'shell/browser/cast_download_manager_delegate.h',
'shell/browser/cast_http_user_agent_settings.cc',
'shell/browser/cast_http_user_agent_settings.h',
'shell/browser/devtools/cast_dev_tools_delegate.cc',
......
......@@ -8,6 +8,7 @@
#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"
......@@ -47,7 +48,8 @@ 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();
}
......@@ -113,8 +115,7 @@ content::ResourceContext* CastBrowserContext::GetResourceContext() {
content::DownloadManagerDelegate*
CastBrowserContext::GetDownloadManagerDelegate() {
NOTIMPLEMENTED();
return NULL;
return download_manager_delegate_.get();
}
content::BrowserPluginGuestManager* CastBrowserContext::GetGuestManager() {
......
......@@ -13,6 +13,7 @@
namespace chromecast {
namespace shell {
class CastDownloadManagerDelegate;
class URLRequestContextFactory;
// Chromecast does not currently support multiple profiles. So there is a
......@@ -55,6 +56,7 @@ class CastBrowserContext : public content::BrowserContext {
URLRequestContextFactory* const url_request_context_factory_;
base::FilePath path_;
scoped_ptr<CastResourceContext> resource_context_;
scoped_ptr<CastDownloadManagerDelegate> download_manager_delegate_;
DISALLOW_COPY_AND_ASSIGN(CastBrowserContext);
};
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chromecast/shell/browser/cast_download_manager_delegate.h"
#include "base/files/file_path.h"
#include "base/logging.h"
#include "content/public/browser/download_danger_type.h"
#include "content/public/browser/download_item.h"
namespace chromecast {
namespace shell {
CastDownloadManagerDelegate::CastDownloadManagerDelegate() {}
CastDownloadManagerDelegate::~CastDownloadManagerDelegate() {}
void CastDownloadManagerDelegate::GetNextId(
const content::DownloadIdCallback& callback) {
// See default behavior of DownloadManagerImpl::GetNextId()
static uint32 next_id = content::DownloadItem::kInvalidId + 1;
callback.Run(next_id++);
}
bool CastDownloadManagerDelegate::DetermineDownloadTarget(
content::DownloadItem* item,
const content::DownloadTargetCallback& callback) {
// Running the DownloadTargetCallback with an empty FilePath signals
// that the download should be cancelled.
base::FilePath empty;
callback.Run(
empty,
content::DownloadItem::TARGET_DISPOSITION_OVERWRITE,
content::DOWNLOAD_DANGER_TYPE_MAYBE_DANGEROUS_CONTENT,
empty);
return true;
}
bool CastDownloadManagerDelegate::ShouldOpenFileBasedOnExtension(
const base::FilePath& path) {
return false;
}
bool CastDownloadManagerDelegate::ShouldCompleteDownload(
content::DownloadItem* item,
const base::Closure& callback) {
return false;
}
bool CastDownloadManagerDelegate::ShouldOpenDownload(
content::DownloadItem* item,
const content::DownloadOpenDelayedCallback& callback) {
return false;
}
} // namespace shell
} // namespace chromecast
\ No newline at end of file
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROMECAST_SHELL_BROWSER_CAST_DOWNLOAD_MANAGER_DELEGATE_H_
#define CHROMECAST_SHELL_BROWSER_CAST_DOWNLOAD_MANAGER_DELEGATE_H_
#include "base/macros.h"
#include "content/public/browser/download_manager_delegate.h"
namespace chromecast {
namespace shell {
class CastDownloadManagerDelegate : public content::DownloadManagerDelegate {
public:
CastDownloadManagerDelegate();
virtual ~CastDownloadManagerDelegate();
// content::DownloadManagerDelegate implementation:
virtual void GetNextId(
const content::DownloadIdCallback& callback) OVERRIDE;
virtual bool DetermineDownloadTarget(
content::DownloadItem* item,
const content::DownloadTargetCallback& callback) OVERRIDE;
virtual bool ShouldOpenFileBasedOnExtension(
const base::FilePath& path) OVERRIDE;
virtual bool ShouldCompleteDownload(
content::DownloadItem* item,
const base::Closure& complete_callback) OVERRIDE;
virtual bool ShouldOpenDownload(
content::DownloadItem* item,
const content::DownloadOpenDelayedCallback& callback) OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(CastDownloadManagerDelegate);
};
} // namespace shell
} // namespace chromecast
#endif // CHROMECAST_SHELL_BROWSER_CAST_DOWNLOAD_MANAGER_DELEGATE_H_
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment