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

Unified Diff: net/url_request/url_request_file_job.cc

Issue 10068021: Fix file access on Chrome for ChromeOS on Linux (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix net unittests Created 8 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_job.h ('k') | net/url_request/url_request_job_manager.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_job.cc
diff --git a/net/url_request/url_request_file_job.cc b/net/url_request/url_request_file_job.cc
index 3c8deae2f6385c7f51d83bce334c171a35144ada..0b64f749e36a2c7182c8dc14a73bfa9c3cae64ab 100644
--- a/net/url_request/url_request_file_job.cc
+++ b/net/url_request/url_request_file_job.cc
@@ -36,6 +36,7 @@
#include "net/base/net_util.h"
#include "net/http/http_util.h"
#include "net/url_request/url_request.h"
+#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_error_job.h"
#include "net/url_request/url_request_file_dir_job.h"
@@ -94,15 +95,12 @@ URLRequestFileJob::URLRequestFileJob(URLRequest* request,
// static
URLRequestJob* URLRequestFileJob::Factory(URLRequest* request,
const std::string& scheme) {
-
FilePath file_path;
const bool is_file = FileURLToFilePath(request->url(), &file_path);
-#if defined(OS_CHROMEOS)
- // Check file access.
- if (AccessDisabled(file_path))
+ // Check file access permissions.
+ if (!IsFileAccessAllowed(*request, file_path))
return new URLRequestErrorJob(request, ERR_ACCESS_DENIED);
-#endif
// We need to decide whether to create URLRequestFileJob for file access or
// URLRequestFileDirJob for directory access. To avoid accessing the
@@ -120,35 +118,6 @@ URLRequestJob* URLRequestFileJob::Factory(URLRequest* request,
return new URLRequestFileJob(request, file_path);
}
-#if defined(OS_CHROMEOS)
-static const char* const kLocalAccessWhiteList[] = {
- "/home/chronos/user/Downloads",
- "/home/chronos/user/log",
- "/media",
- "/opt/oem",
- "/usr/share/chromeos-assets",
- "/tmp",
- "/var/log",
-};
-
-// static
-bool URLRequestFileJob::AccessDisabled(const FilePath& file_path) {
- if (URLRequest::IsFileAccessAllowed()) { // for tests.
- return false;
- }
-
- for (size_t i = 0; i < arraysize(kLocalAccessWhiteList); ++i) {
- const FilePath white_listed_path(kLocalAccessWhiteList[i]);
- // FilePath::operator== should probably handle trailing seperators.
- if (white_listed_path == file_path.StripTrailingSeparators() ||
- white_listed_path.IsParent(file_path)) {
- return false;
- }
- }
- return true;
-}
-#endif // OS_CHROMEOS
-
void URLRequestFileJob::Start() {
DCHECK(!async_resolver_);
async_resolver_ = new AsyncResolver(this);
@@ -281,6 +250,18 @@ void URLRequestFileJob::SetExtraRequestHeaders(
}
}
+// static
+bool URLRequestFileJob::IsFileAccessAllowed(const URLRequest& request,
+ const FilePath& path) {
+ const URLRequestContext* context = request.context();
+ if (!context)
+ return false;
+ const NetworkDelegate* delegate = 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') | net/url_request/url_request_job_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698