This source file includes following definitions.
- MaybeCreateJob
- IsSafeRedirectTarget
#include "net/url_request/file_protocol_handler.h"
#include "base/logging.h"
#include "base/task_runner.h"
#include "net/base/net_errors.h"
#include "net/base/net_util.h"
#include "net/url_request/url_request.h"
#include "net/url_request/url_request_error_job.h"
#include "net/url_request/url_request_file_dir_job.h"
#include "net/url_request/url_request_file_job.h"
namespace net {
FileProtocolHandler::FileProtocolHandler(
const scoped_refptr<base::TaskRunner>& file_task_runner)
: file_task_runner_(file_task_runner) {}
FileProtocolHandler::~FileProtocolHandler() {}
URLRequestJob* FileProtocolHandler::MaybeCreateJob(
URLRequest* request, NetworkDelegate* network_delegate) const {
base::FilePath file_path;
const bool is_file = FileURLToFilePath(request->url(), &file_path);
if (!network_delegate ||
!network_delegate->CanAccessFile(*request, file_path)) {
return new URLRequestErrorJob(request, network_delegate, ERR_ACCESS_DENIED);
}
if (is_file &&
file_path.EndsWithSeparator() &&
file_path.IsAbsolute()) {
return new URLRequestFileDirJob(request, network_delegate, file_path);
}
return new URLRequestFileJob(request, network_delegate, file_path,
file_task_runner_);
}
bool FileProtocolHandler::IsSafeRedirectTarget(const GURL& location) const {
return false;
}
}