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 22a1aa107e9dc106a50e6e9571ecbb1dd3ff60d8..820d5bdccbc48736d5221c273340ac9a1fef5137 100644 |
--- a/chrome/browser/chromeos/file_system_provider/mount_path_util.cc |
+++ b/chrome/browser/chromeos/file_system_provider/mount_path_util.cc |
@@ -11,6 +11,7 @@ |
#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" |
+#include "chrome/browser/chromeos/file_system_provider/file_system_plugin/plugin_service.h" |
#include "chrome/browser/chromeos/profiles/profile_helper.h" |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/browser/profiles/profile_manager.h" |
@@ -29,7 +30,8 @@ namespace { |
// Root mount path for all of the provided file systems. |
const base::FilePath::CharType kProvidedMountPointRoot[] = |
FILE_PATH_LITERAL("/provided"); |
- |
+const base::FilePath::CharType kPluginProvidedPointRoot[] = |
+ FILE_PATH_LITERAL("/plugin_provided"); |
} // namespace |
// Escapes the file system id so it can be used as a file/directory name. |
@@ -61,6 +63,20 @@ base::FilePath GetMountPath(Profile* profile, |
extension_id + ":" + safe_file_system_id + ":" + username_suffix); |
} |
+base::FilePath GetPluginMountPath(Profile* profile, |
+ const std::string& source_id, |
+ const std::string& file_system_id) { |
+ const user_manager::User* const user = |
+ user_manager::UserManager::IsInitialized() |
+ ? chromeos::ProfileHelper::Get()->GetUserByProfile( |
+ profile->GetOriginalProfile()) |
+ : NULL; |
+ const std::string safe_file_system_id = EscapeFileSystemId(file_system_id); |
+ const std::string username_suffix = user ? user->username_hash() : ""; |
+ return base::FilePath(kPluginProvidedPointRoot).AppendASCII( |
+ source_id + ":" + safe_file_system_id + ":" + username_suffix); |
+} |
+ |
bool IsFileSystemProviderLocalPath(const base::FilePath& local_path) { |
std::vector<base::FilePath::StringType> components; |
local_path.GetComponents(&components); |
@@ -71,7 +87,8 @@ bool IsFileSystemProviderLocalPath(const base::FilePath& local_path) { |
if (components[0] != FILE_PATH_LITERAL("/")) |
return false; |
- if (components[1] != kProvidedMountPointRoot + 1 /* no leading slash */) |
+ if (components[1] != kProvidedMountPointRoot + 1 ||/* no leading slash */ |
+ components[0] != kPluginProvidedPointRoot + 1) |
return false; |
return true; |
@@ -87,9 +104,18 @@ FileSystemURLParser::~FileSystemURLParser() { |
bool FileSystemURLParser::Parse() { |
DCHECK_CURRENTLY_ON(BrowserThread::UI); |
+ if (url_.type() == storage::kFileSystemTypeProvided) |
+ return ParseExtensionProvided(); |
+ if (url_.type() == storage::kFileSystemTypePluginProvided) |
+ return ParsePluginProvided(); |
+ return false; |
+} |
+ |
+bool FileSystemURLParser::ParseExtensionProvided() { |
+ DCHECK_CURRENTLY_ON(BrowserThread::UI); |
+ |
if (url_.type() != storage::kFileSystemTypeProvided) |
return false; |
- |
// First, find the service handling the mount point of the URL. |
const std::vector<Profile*>& profiles = |
g_browser_process->profile_manager()->GetLoadedProfiles(); |
@@ -132,6 +158,52 @@ bool FileSystemURLParser::Parse() { |
return false; |
} |
+bool FileSystemURLParser::ParsePluginProvided() { |
+ DCHECK_CURRENTLY_ON(BrowserThread::UI); |
+ |
+ if (url_.type() != storage::kFileSystemTypePluginProvided) |
+ return false; |
+ // First, find the service handling the mount point of the URL. |
+ const std::vector<Profile*>& profiles = |
+ g_browser_process->profile_manager()->GetLoadedProfiles(); |
+ |
+ for (size_t i = 0; i < profiles.size(); ++i) { |
+ Profile* original_profile = profiles[i]->GetOriginalProfile(); |
+ |
+ if (original_profile != profiles[i] || |
+ chromeos::ProfileHelper::IsSigninProfile(original_profile)) { |
+ continue; |
+ } |
+ |
+ PluginService* const service = PluginService::Get(original_profile); |
+ if (!service) |
+ continue; |
+ |
+ ProvidedFileSystemInterface* const file_system = |
+ service->GetProvidedFileSystem(url_.filesystem_id()); |
+ if (!file_system) |
+ continue; |
+ |
+ // Strip the mount path name from the local path, to extract the file path |
+ // within the provided file system. |
+ file_system_ = file_system; |
+ std::vector<base::FilePath::StringType> components; |
+ url_.path().GetComponents(&components); |
+ if (components.size() < 3) |
+ return false; |
+ |
+ file_path_ = base::FilePath(FILE_PATH_LITERAL("/")); |
+ for (size_t i = 3; i < components.size(); ++i) { |
+ file_path_ = file_path_.Append(components[i]); |
+ } |
+ |
+ return true; |
+ } |
+ |
+ // Nothing has been found. |
+ return false; |
+} |
+ |
LocalPathParser::LocalPathParser(Profile* profile, |
const base::FilePath& local_path) |
: profile_(profile), local_path_(local_path), file_system_(NULL) { |