diff options
author | qinmin <qinmin@chromium.org> | 2014-11-25 19:02:16 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-11-26 03:03:21 +0000 |
commit | 120a15519703dfe8601596f1f436a322ea0a2aff (patch) | |
tree | 78ac7a415a86b465712808a2386e1a0d5ba6cd67 /content/browser/android/content_protocol_handler_impl.cc | |
parent | e674d6dc2fbadd946912426f49d71e3af8482e4a (diff) | |
download | chromium_src-120a15519703dfe8601596f1f436a322ea0a2aff.zip chromium_src-120a15519703dfe8601596f1f436a322ea0a2aff.tar.gz chromium_src-120a15519703dfe8601596f1f436a322ea0a2aff.tar.bz2 |
Support content scheme uri for Chrome on Android
Android uses content scheme to store files and ensure permission checks.
For example, the downloaded files are stored as content://downloads/all_downloads/123.
However, chrome currently cannot handle url requests for content uri.
As a result, chrome can save html pages to sdcard, but cannot open it.
This change adds the content scheme support for chrome on android.
BUG=433011
Review URL: https://codereview.chromium.org/739033003
Cr-Commit-Position: refs/heads/master@{#305772}
Diffstat (limited to 'content/browser/android/content_protocol_handler_impl.cc')
-rw-r--r-- | content/browser/android/content_protocol_handler_impl.cc | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/content/browser/android/content_protocol_handler_impl.cc b/content/browser/android/content_protocol_handler_impl.cc new file mode 100644 index 0000000..f5e5d20 --- /dev/null +++ b/content/browser/android/content_protocol_handler_impl.cc @@ -0,0 +1,43 @@ +// Copyright (c) 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 "content/browser/android/content_protocol_handler_impl.h" + +#include "base/task_runner.h" +#include "content/browser/android/url_request_content_job.h" +#include "net/base/net_errors.h" +#include "net/url_request/url_request.h" +#include "net/url_request/url_request_error_job.h" + +namespace content { + +// static +ContentProtocolHandler* ContentProtocolHandler::Create( + const scoped_refptr<base::TaskRunner>& content_task_runner) { + return new ContentProtocolHandlerImpl(content_task_runner); +} + +ContentProtocolHandlerImpl::ContentProtocolHandlerImpl( + const scoped_refptr<base::TaskRunner>& content_task_runner) + : content_task_runner_(content_task_runner) {} + +ContentProtocolHandlerImpl::~ContentProtocolHandlerImpl() {} + +net::URLRequestJob* ContentProtocolHandlerImpl::MaybeCreateJob( + net::URLRequest* request, net::NetworkDelegate* network_delegate) const { + if (!network_delegate) { + return new net::URLRequestErrorJob( + request, network_delegate, net::ERR_ACCESS_DENIED); + } + return new URLRequestContentJob( + request, network_delegate, base::FilePath(request->url().spec()), + content_task_runner_); +} + +bool ContentProtocolHandlerImpl::IsSafeRedirectTarget( + const GURL& location) const { + return false; +} + +} // namespace content |