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

Unified Diff: chrome/browser/chromeos/extensions/file_handler_util.cc

Issue 10823273: Integrate external mount points to IsolatedContext (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cros test fix 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: chrome/browser/chromeos/extensions/file_handler_util.cc
diff --git a/chrome/browser/chromeos/extensions/file_handler_util.cc b/chrome/browser/chromeos/extensions/file_handler_util.cc
index 396b5e9b836cd8b98e6e975bd3d9688826f87c00..1d2983f62ca4c01a914d01cf8a350461bc37b4b4 100644
--- a/chrome/browser/chromeos/extensions/file_handler_util.cc
+++ b/chrome/browser/chromeos/extensions/file_handler_util.cc
@@ -36,6 +36,7 @@
#include "net/base/escape.h"
#include "webkit/fileapi/file_system_context.h"
#include "webkit/fileapi/file_system_mount_point_provider.h"
+#include "webkit/fileapi/file_system_url.h"
#include "webkit/fileapi/file_system_util.h"
using content::BrowserContext;
@@ -566,15 +567,11 @@ class ExtensionTaskExecutor::ExecuteTasksFileSystemCallbackDispatcher {
if (handler_pid_ == 0)
return false;
- GURL file_origin_url;
- FilePath virtual_path;
- fileapi::FileSystemType type;
- if (!CrackFileSystemURL(origin_file_url, &file_origin_url, &type,
- &virtual_path)) {
+ fileapi::FileSystemURL url(origin_file_url);
+ if (!url.is_valid())
return false;
- }
- if (type != fileapi::kFileSystemTypeExternal)
+ if (!fileapi::IsCrosManagedFileSystemType(url.type()))
return false;
fileapi::ExternalFileSystemMountPointProvider* external_provider =
@@ -582,37 +579,31 @@ class ExtensionTaskExecutor::ExecuteTasksFileSystemCallbackDispatcher {
if (!external_provider)
return false;
- if (!external_provider->IsAccessAllowed(file_origin_url,
- type,
- virtual_path)) {
+ if (!external_provider->IsAccessAllowed(url.origin(),
+ url.type(),
+ url.virtual_path())) {
return false;
}
// Make sure this url really being used by the right caller extension.
- if (source_url_.GetOrigin() != file_origin_url) {
+ if (source_url_.GetOrigin() != url.origin()) {
DidFail(base::PLATFORM_FILE_ERROR_SECURITY);
return false;
}
- FilePath root_path =
- external_provider->GetFileSystemRootPathOnFileThread(
- file_origin_url,
- fileapi::kFileSystemTypeExternal,
- virtual_path,
- false); // create
- FilePath final_file_path = root_path.Append(virtual_path);
-
// Check if this file system entry exists first.
base::PlatformFileInfo file_info;
- bool is_gdata_file = gdata::util::IsUnderGDataMountPoint(final_file_path);
+ bool is_gdata_file = url.type() == fileapi::kFileSystemTypeGData;
satorux1 2012/08/20 03:30:23 is_gdata_file -> is_drive_file kFileSystemTypeGDa
kinuko 2012/08/20 08:54:35 Done.
+
+ DCHECK(!is_gdata_file || gdata::util::IsUnderGDataMountPoint(url.path()));
// If the file is under gdata mount point, there is no actual file to be
- // found on the final_file_path.
+ // found on the url.path().
if (!is_gdata_file) {
- if (!file_util::PathExists(final_file_path) ||
- file_util::IsLink(final_file_path) ||
- !file_util::GetFileInfo(final_file_path, &file_info)) {
+ if (!file_util::PathExists(url.path()) ||
kmadhusu 2012/08/14 18:01:13 nit: url.path() and url.virtual_path() are called
kinuko 2012/08/20 08:54:35 Done.
+ file_util::IsLink(url.path()) ||
+ !file_util::GetFileInfo(url.path(), &file_info)) {
return false;
}
}
@@ -621,17 +612,17 @@ class ExtensionTaskExecutor::ExecuteTasksFileSystemCallbackDispatcher {
// ensure that the target extension can access only this FS entry and
// prevent from traversing FS hierarchy upward.
external_provider->GrantFileAccessToExtension(handler_extension_->id(),
- virtual_path);
+ url.virtual_path());
// Output values.
GURL target_origin_url(Extension::GetBaseURLFromExtensionId(
handler_extension_->id()));
GURL base_url = fileapi::GetFileSystemRootURI(target_origin_url,
fileapi::kFileSystemTypeExternal);
- file->target_file_url = GURL(base_url.spec() + virtual_path.value());
- file->virtual_path = virtual_path;
+ file->target_file_url = GURL(base_url.spec() + url.virtual_path().value());
+ file->virtual_path = url.virtual_path();
file->is_directory = file_info.is_directory;
- file->absolute_path = final_file_path;
+ file->absolute_path = url.path();
return true;
}

Powered by Google App Engine
This is Rietveld 408576698