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

Unified Diff: net/url_request/url_request_file_job.cc

Issue 10855209: Refactoring: ProtocolHandler::MaybeCreateJob takes NetworkDelegate as argument (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: NetworkDelegate fixed almost everywhere 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
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..0f29c0ee3423a66e499d9cddbf5990c69455db5e 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,
+ NetworkDelegate* network_delegate,
const FilePath& file_path)
- : URLRequestJob(request, request->context()->network_delegate()),
+ : URLRequestJob(request, network_delegate),
file_path_(file_path),
stream_(NULL),
is_directory_(false),
@@ -94,14 +95,16 @@ URLRequestFileJob::URLRequestFileJob(URLRequest* request,
// static
URLRequestJob* URLRequestFileJob::Factory(URLRequest* request,
+ NetworkDelegate* network_delegate,
const std::string& scheme) {
FilePath file_path;
const bool is_file = FileURLToFilePath(request->url(), &file_path);
// Check file access permissions.
- if (!IsFileAccessAllowed(*request, file_path))
- return new URLRequestErrorJob(request, ERR_ACCESS_DENIED);
-
+ if (!network_delegate ||
+ !network_delegate->CanAccessFile(*request, file_path)) {
+ return new URLRequestErrorJob(request, network_delegate, ERR_ACCESS_DENIED);
+ }
// We need to decide whether to create URLRequestFileJob for file access or
// URLRequestFileDirJob for directory access. To avoid accessing the
// filesystem, we only look at the path string here.
@@ -111,11 +114,11 @@ URLRequestJob* URLRequestFileJob::Factory(URLRequest* request,
if (is_file &&
file_util::EndsWithSeparator(file_path) &&
file_path.IsAbsolute())
- return new URLRequestFileDirJob(request, file_path);
+ return new URLRequestFileDirJob(request, network_delegate, file_path);
// Use a regular file request job for all non-directories (including invalid
// file names).
- return new URLRequestFileJob(request, file_path);
+ return new URLRequestFileJob(request, network_delegate, file_path);
}
void URLRequestFileJob::Start() {
@@ -250,15 +253,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_);
}

Powered by Google App Engine
This is Rietveld 408576698