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

Unified Diff: chrome/browser/chromeos/fileapi/external_file_url_request_job.cc

Issue 589473002: Files.app: Enable externalfile: protocol for MTP volumes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed. Created 6 years, 3 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: chrome/browser/chromeos/fileapi/external_file_url_request_job.cc
diff --git a/chrome/browser/chromeos/fileapi/external_file_url_request_job.cc b/chrome/browser/chromeos/fileapi/external_file_url_request_job.cc
index ff54aff2d083e46c3d8922bda72a1a8df7e561b6..0d1a01ed28bc094d6e0880666b8f26cc8a188048 100644
--- a/chrome/browser/chromeos/fileapi/external_file_url_request_job.cc
+++ b/chrome/browser/chromeos/fileapi/external_file_url_request_job.cc
@@ -37,26 +37,6 @@ namespace {
const char kMimeTypeForRFC822[] = "message/rfc822";
const char kMimeTypeForMHTML[] = "multipart/related";
-// Check if the |url| points a valid location or not.
-bool IsValidURL(const storage::FileSystemURL& url) {
- switch (url.type()) {
- case storage::kFileSystemTypeDrive: {
- const base::FilePath my_drive_path =
- drive::util::GetDriveMyDriveRootPath();
- const base::FilePath drive_other_path =
- drive::util::GetDriveGrandRootPath().Append(
- drive::util::kDriveOtherDirName);
- const base::FilePath url_drive_path =
- drive::util::ExtractDrivePathFromFileSystemUrl(url);
- return my_drive_path == url_drive_path ||
- my_drive_path.IsParent(url_drive_path) ||
- drive_other_path.IsParent(url_drive_path);
- }
- default:
- return false;
- }
-}
-
// Helper for obtaining FileSystemContext, FileSystemURL, and mime type on the
// UI thread.
class URLHelper {
@@ -96,30 +76,18 @@ class URLHelper {
DCHECK(context.get());
// Obtain the absolute path in the file system.
- base::FilePath path = drive::util::GetDriveMountPointPath(profile);
- drive::util::GetDriveGrandRootPath().AppendRelativePath(
- ExternalFileURLToFilePath(url_), &path);
-
- storage::ExternalFileSystemBackend* const backend =
- context->external_backend();
- DCHECK(backend);
-
- // Obtain the virtual path.
- base::FilePath virtual_path;
- if (!backend->GetVirtualPath(path, &virtual_path)) {
- ReplyResult(net::ERR_FILE_NOT_FOUND);
- return;
- }
+ const base::FilePath virtual_path = ExternalFileURLToVirtualPath(url_);
// Obtain the file system URL.
// TODO(hirono): After removing MHTML support, stop to use the special
-
// drive: scheme and use filesystem: URL directly. crbug.com/415455
file_system_url_ = context->CreateCrackedFileSystemURL(
GURL(std::string(chrome::kExternalFileScheme) + ":"),
storage::kFileSystemTypeExternal,
virtual_path);
- if (!IsValidURL(file_system_url_)) {
+
+ // Check if the obtained path providing external file URL or not.
+ if (FileSystemURLToExternalFileURL(file_system_url_).is_empty()) {
ReplyResult(net::ERR_INVALID_URL);
return;
}

Powered by Google App Engine
This is Rietveld 408576698