Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(337)

Side by Side Diff: net/url_request/file_protocol_handler.cc

Issue 739033003: Support content scheme uri for Chrome on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/url_request/file_protocol_handler.h" 5 #include "net/url_request/file_protocol_handler.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/task_runner.h" 8 #include "base/task_runner.h"
9 #include "net/base/filename_util.h" 9 #include "net/base/filename_util.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
11 #include "net/url_request/url_request.h" 11 #include "net/url_request/url_request.h"
12 #include "net/url_request/url_request_error_job.h" 12 #include "net/url_request/url_request_error_job.h"
13 #include "net/url_request/url_request_file_dir_job.h" 13 #include "net/url_request/url_request_file_dir_job.h"
14 #include "net/url_request/url_request_file_job.h" 14 #include "net/url_request/url_request_file_job.h"
15 15
16 namespace net { 16 namespace net {
17 17
18 FileProtocolHandler::FileProtocolHandler( 18 FileProtocolHandler::FileProtocolHandler(
19 const scoped_refptr<base::TaskRunner>& file_task_runner) 19 const scoped_refptr<base::TaskRunner>& file_task_runner)
20 : file_task_runner_(file_task_runner) {} 20 : file_task_runner_(file_task_runner) {}
21 21
22 FileProtocolHandler::~FileProtocolHandler() {} 22 FileProtocolHandler::~FileProtocolHandler() {}
23 23
24 URLRequestJob* FileProtocolHandler::MaybeCreateJob( 24 URLRequestJob* FileProtocolHandler::MaybeCreateJob(
25 URLRequest* request, NetworkDelegate* network_delegate) const { 25 URLRequest* request, NetworkDelegate* network_delegate) const {
26 #if defined(OS_ANDROID)
27 if (request->url().SchemeIs("content")) {
28 return new URLRequestFileJob(
29 request, network_delegate, base::FilePath(request->url().spec()),
palmer 2014/11/19 00:23:54 Will content://data/data/org.chromium.blah/foo/Pro
qinmin 2014/11/19 02:13:07 no, android ContentResolver has it's own permissio
30 file_task_runner_);
31 }
32 #endif
33
26 base::FilePath file_path; 34 base::FilePath file_path;
27 const bool is_file = FileURLToFilePath(request->url(), &file_path); 35 const bool is_file = FileURLToFilePath(request->url(), &file_path);
28 36
29 // Check file access permissions. 37 // Check file access permissions.
30 if (!network_delegate || 38 if (!network_delegate ||
31 !network_delegate->CanAccessFile(*request, file_path)) { 39 !network_delegate->CanAccessFile(*request, file_path)) {
32 return new URLRequestErrorJob(request, network_delegate, ERR_ACCESS_DENIED); 40 return new URLRequestErrorJob(request, network_delegate, ERR_ACCESS_DENIED);
33 } 41 }
34 42
35 // We need to decide whether to create URLRequestFileJob for file access or 43 // We need to decide whether to create URLRequestFileJob for file access or
(...skipping 12 matching lines...) Expand all
48 // file names). 56 // file names).
49 return new URLRequestFileJob(request, network_delegate, file_path, 57 return new URLRequestFileJob(request, network_delegate, file_path,
50 file_task_runner_); 58 file_task_runner_);
51 } 59 }
52 60
53 bool FileProtocolHandler::IsSafeRedirectTarget(const GURL& location) const { 61 bool FileProtocolHandler::IsSafeRedirectTarget(const GURL& location) const {
54 return false; 62 return false;
55 } 63 }
56 64
57 } // namespace net 65 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698