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

Unified Diff: net/url_request/url_request_file_job.cc

Issue 10700117: Replaced static URLRequestFileJob factory with non-static protocol handler for File jobs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed nits Created 8 years, 4 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_job.h ('k') | webkit/tools/test_shell/test_shell.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/url_request/url_request_file_job.cc
diff --git a/net/url_request/url_request_file_job.cc b/net/url_request/url_request_file_job.cc
index c9378dda6b82f782cbbc92235beb7707593bc39a..f07e92fc565c025c189c3b4836f71663a73f44ab 100644
--- a/net/url_request/url_request_file_job.cc
+++ b/net/url_request/url_request_file_job.cc
@@ -84,8 +84,9 @@ class URLRequestFileJob::AsyncResolver
};
URLRequestFileJob::URLRequestFileJob(URLRequest* request,
- const FilePath& file_path)
- : URLRequestJob(request, request->context()->network_delegate()),
+ const FilePath& file_path,
+ NetworkDelegate* network_delegate)
+ : URLRequestJob(request, network_delegate),
file_path_(file_path),
stream_(NULL),
is_directory_(false),
@@ -99,8 +100,11 @@ URLRequestJob* URLRequestFileJob::Factory(URLRequest* request,
const bool is_file = FileURLToFilePath(request->url(), &file_path);
// Check file access permissions.
- if (!IsFileAccessAllowed(*request, file_path))
+ if (!request->context()->network_delegate() ||
+ !request->context()->network_delegate()->CanAccessFile(
+ *request, file_path)) {
return new URLRequestErrorJob(request, ERR_ACCESS_DENIED);
+ }
// We need to decide whether to create URLRequestFileJob for file access or
// URLRequestFileDirJob for directory access. To avoid accessing the
@@ -115,7 +119,8 @@ URLRequestJob* URLRequestFileJob::Factory(URLRequest* request,
// Use a regular file request job for all non-directories (including invalid
// file names).
- return new URLRequestFileJob(request, file_path);
+ return new URLRequestFileJob(
+ request, file_path, request->context()->network_delegate());
}
void URLRequestFileJob::Start() {
@@ -250,15 +255,6 @@ void URLRequestFileJob::SetExtraRequestHeaders(
}
}
-// static
-bool URLRequestFileJob::IsFileAccessAllowed(const URLRequest& request,
- const FilePath& path) {
- const NetworkDelegate* delegate = request.context()->network_delegate();
- if (delegate)
- return delegate->CanAccessFile(request, path);
- return false;
-}
-
URLRequestFileJob::~URLRequestFileJob() {
DCHECK(!async_resolver_);
}
« no previous file with comments | « net/url_request/url_request_file_job.h ('k') | webkit/tools/test_shell/test_shell.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698