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

Unified Diff: chrome/browser/chromeos/file_system_provider/mount_path_util.cc

Issue 294073007: [fsp] Let extensions decide about the file system id. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Created 6 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
Index: chrome/browser/chromeos/file_system_provider/mount_path_util.cc
diff --git a/chrome/browser/chromeos/file_system_provider/mount_path_util.cc b/chrome/browser/chromeos/file_system_provider/mount_path_util.cc
index 9a6c804f510d3cb3fde42cf5ab919144f72e095e..40eff7c5d02c09dedc284d706fe16f242eca96f4 100644
--- a/chrome/browser/chromeos/file_system_provider/mount_path_util.cc
+++ b/chrome/browser/chromeos/file_system_provider/mount_path_util.cc
@@ -7,7 +7,7 @@
#include <vector>
#include "base/stl_util.h"
-#include "base/strings/string_number_conversions.h"
+#include "base/strings/stringprintf.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/file_system_provider/provided_file_system.h"
#include "chrome/browser/chromeos/file_system_provider/service.h"
@@ -32,17 +32,33 @@ const base::FilePath::CharType kProvidedMountPointRoot[] =
} // namespace
+// Escapes the file system id so it can be used as a file/directory name.
+// This is based on net/base/escape.cc: net::(anonymous namespace)::Escape
+std::string EscapeFileSystemId(const std::string& file_system_id) {
+ std::string escaped;
+ for (size_t i = 0; i < file_system_id.size(); ++i) {
+ const char c = file_system_id[i];
+ if (c == '%' || c == '.' || c == '/') {
+ base::StringAppendF(&escaped, "%%%02X", c);
+ } else {
+ escaped.push_back(c);
+ }
+ }
+ return escaped;
+}
+
base::FilePath GetMountPath(Profile* profile,
- std::string extension_id,
- int file_system_id) {
+ const std::string& extension_id,
+ const std::string& file_system_id) {
chromeos::User* const user =
chromeos::UserManager::IsInitialized()
? chromeos::UserManager::Get()->GetUserByProfile(
profile->GetOriginalProfile())
: NULL;
- const std::string user_suffix = user ? "-" + user->username_hash() : "";
+ const std::string safe_file_system_id = EscapeFileSystemId(file_system_id);
+ const std::string username_suffix = user ? user->username_hash() : "";
return base::FilePath(kProvidedMountPointRoot).AppendASCII(
- extension_id + "-" + base::IntToString(file_system_id) + user_suffix);
+ extension_id + ":" + safe_file_system_id + ":" + username_suffix);
}
FileSystemURLParser::FileSystemURLParser(const fileapi::FileSystemURL& url)

Powered by Google App Engine
This is Rietveld 408576698