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

Unified Diff: chrome/browser/chromeos/file_manager/fileapi_util.cc

Issue 147993003: Clarify and separate the concept of "Drive path" and "Filesystem relative path". (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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 | « chrome/browser/chromeos/file_manager/fileapi_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/file_manager/fileapi_util.cc
diff --git a/chrome/browser/chromeos/file_manager/fileapi_util.cc b/chrome/browser/chromeos/file_manager/fileapi_util.cc
index 0a74354d5865364e920055556c47b644a8497108..edad4fb050d54282c82f69addbd1221679a1c80a 100644
--- a/chrome/browser/chromeos/file_manager/fileapi_util.cc
+++ b/chrome/browser/chromeos/file_manager/fileapi_util.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/chromeos/file_manager/fileapi_util.h"
#include "base/files/file_path.h"
+#include "chrome/browser/chromeos/drive/file_system_util.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/profiles/profile.h"
@@ -20,6 +21,20 @@
namespace file_manager {
namespace util {
+namespace {
+
+GURL ConvertRelativeFilePathToFileSystemUrl(const base::FilePath& relative_path,
+ const std::string& extension_id) {
+ GURL base_url = fileapi::GetFileSystemRootURI(
+ extensions::Extension::GetBaseURLFromExtensionId(extension_id),
+ fileapi::kFileSystemTypeExternal);
+ return GURL(base_url.spec() +
+ net::EscapeUrlEncodedData(relative_path.AsUTF8Unsafe(),
+ false)); // Space to %20 instead of +.
+}
+
+} // namespace
+
fileapi::FileSystemContext* GetFileSystemContextForExtensionId(
Profile* profile,
const std::string& extension_id) {
@@ -37,27 +52,33 @@ fileapi::FileSystemContext* GetFileSystemContextForRenderViewHost(
GetFileSystemContext();
}
-GURL ConvertRelativeFilePathToFileSystemUrl(const base::FilePath& relative_path,
- const std::string& extension_id) {
- GURL base_url = fileapi::GetFileSystemRootURI(
- extensions::Extension::GetBaseURLFromExtensionId(extension_id),
- fileapi::kFileSystemTypeExternal);
- return GURL(base_url.spec() +
- net::EscapeUrlEncodedData(relative_path.AsUTF8Unsafe(),
- false)); // Space to %20 instead of +.
+base::FilePath ConvertDrivePathToRelativeFileSystemPath(
+ Profile* profile,
+ const base::FilePath& drive_path) {
+ // "drive-xxx"
+ base::FilePath path = drive::util::GetDriveMountPointPath(profile).BaseName();
+ // appended with (|drive_path| - "drive").
+ drive::util::GetDriveGrandRootPath().AppendRelativePath(drive_path, &path);
+ return path;
}
-bool ConvertAbsoluteFilePathToFileSystemUrl(
- Profile* profile,
- const base::FilePath& absolute_path,
- const std::string& extension_id,
- GURL* url) {
+GURL ConvertDrivePathToFileSystemUrl(Profile* profile,
+ const base::FilePath& drive_path,
+ const std::string& extension_id) {
+ const base::FilePath relative_path =
+ ConvertDrivePathToRelativeFileSystemPath(profile, drive_path);
+ return ConvertRelativeFilePathToFileSystemUrl(drive_path, extension_id);
+}
+
+bool ConvertAbsoluteFilePathToFileSystemUrl(Profile* profile,
+ const base::FilePath& absolute_path,
+ const std::string& extension_id,
+ GURL* url) {
base::FilePath relative_path;
- if (!ConvertAbsoluteFilePathToRelativeFileSystemPath(
- profile,
- extension_id,
- absolute_path,
- &relative_path)) {
+ if (!ConvertAbsoluteFilePathToRelativeFileSystemPath(profile,
+ extension_id,
+ absolute_path,
+ &relative_path)) {
return false;
}
*url = ConvertRelativeFilePathToFileSystemUrl(relative_path, extension_id);
« no previous file with comments | « chrome/browser/chromeos/file_manager/fileapi_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698