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

Unified Diff: net/url_request/url_request_file_dir_job.cc

Issue 2786583002: chromeos: Check both original and absolute paths for file: scheme (Closed)
Patch Set: remove dcheck Created 3 years, 7 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/url_request/url_request_file_dir_job.h ('k') | net/url_request/url_request_file_job.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/url_request/url_request_file_dir_job.cc
diff --git a/net/url_request/url_request_file_dir_job.cc b/net/url_request/url_request_file_dir_job.cc
index 435ccb008655fc2c83d64c24eb783703f73f428b..27d7ec7fe52861aea00fc60fd7deca689823e63c 100644
--- a/net/url_request/url_request_file_dir_job.cc
+++ b/net/url_request/url_request_file_dir_job.cc
@@ -6,10 +6,12 @@
#include "base/bind.h"
#include "base/compiler_specific.h"
+#include "base/files/file_util.h"
#include "base/location.h"
#include "base/single_thread_task_runner.h"
#include "base/strings/sys_string_conversions.h"
#include "base/strings/utf_string_conversions.h"
+#include "base/task_scheduler/post_task.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h"
#include "net/base/directory_listing.h"
@@ -37,8 +39,12 @@ URLRequestFileDirJob::URLRequestFileDirJob(URLRequest* request,
weak_factory_(this) {}
void URLRequestFileDirJob::StartAsync() {
- lister_.Start();
- NotifyHeadersComplete();
+ base::PostTaskWithTraitsAndReplyWithResult(
+ FROM_HERE,
+ {base::MayBlock(), base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN},
+ base::Bind(&base::MakeAbsoluteFilePath, dir_path_),
+ base::Bind(&URLRequestFileDirJob::DidMakeAbsolutePath,
+ weak_factory_.GetWeakPtr()));
}
void URLRequestFileDirJob::Start() {
@@ -136,6 +142,18 @@ void URLRequestFileDirJob::OnListDone(int error) {
URLRequestFileDirJob::~URLRequestFileDirJob() {}
+void URLRequestFileDirJob::DidMakeAbsolutePath(
+ const base::FilePath& absolute_path) {
+ if (network_delegate() && !network_delegate()->CanAccessFile(
+ *request(), dir_path_, absolute_path)) {
+ NotifyStartError(URLRequestStatus::FromError(ERR_ACCESS_DENIED));
+ return;
+ }
+
+ lister_.Start();
+ NotifyHeadersComplete();
+}
+
void URLRequestFileDirJob::CompleteRead(Error error) {
DCHECK_LE(error, OK);
DCHECK_NE(error, ERR_IO_PENDING);
« no previous file with comments | « net/url_request/url_request_file_dir_job.h ('k') | net/url_request/url_request_file_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698