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

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

Issue 244623003: [fsp] [recommit] Add FileSystemURLParser to the file system provider. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Created 6 years, 8 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 c535bdb4fa286b1ed9111eb84ccedaa84c9c5655..ed7016d4223c922af0049e98349bc76cf1e42956 100644
--- a/chrome/browser/chromeos/file_system_provider/mount_path_util.cc
+++ b/chrome/browser/chromeos/file_system_provider/mount_path_util.cc
@@ -4,11 +4,18 @@
#include "chrome/browser/chromeos/file_system_provider/mount_path_util.h"
-#include "base/files/file_path.h"
+#include <vector>
+
#include "base/stl_util.h"
#include "base/strings/string_number_conversions.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"
#include "chrome/browser/chromeos/login/user.h"
#include "chrome/browser/chromeos/login/user_manager.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/profiles/profile_manager.h"
namespace chromeos {
namespace file_system_provider {
@@ -22,9 +29,9 @@ const base::FilePath::CharType kProvidedMountPointRoot[] =
} // namespace
-base::FilePath GetMountPointPath(Profile* profile,
- std::string extension_id,
- int file_system_id) {
+base::FilePath GetMountPath(Profile* profile,
+ std::string extension_id,
+ int file_system_id) {
chromeos::User* const user =
chromeos::UserManager::IsInitialized()
? chromeos::UserManager::Get()->GetUserByProfile(
@@ -35,6 +42,57 @@ base::FilePath GetMountPointPath(Profile* profile,
extension_id + "-" + base::IntToString(file_system_id) + user_suffix);
}
+FileSystemURLParser::FileSystemURLParser(const fileapi::FileSystemURL& url)
+ : url_(url), file_system_(NULL) {
+}
+
+FileSystemURLParser::~FileSystemURLParser() {
+}
+
+bool FileSystemURLParser::Parse() {
+ if (url_.type() != fileapi::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();
+
+ 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;
+ }
+
+ Service* service = Service::Get(original_profile);
+ if (!service)
+ continue;
+
+ ProvidedFileSystemInterface* file_system =
+ service->GetProvidedFileSystem(url_.filesystem_id());
+ if (!file_system)
+ continue;
+
+ // Strip the mount point name from the virtual path, to extract the file
+ // path within the provided file system.
+ file_system_ = file_system;
+ std::vector<base::FilePath::StringType> components;
+ url_.virtual_path().GetComponents(&components);
+ DCHECK_LT(0u, components.size());
+ file_path_ = base::FilePath();
+ for (size_t i = 1; i < components.size(); ++i) {
+ // TODO(mtomasz): This could be optimized, to avoid unnecessary copies.
+ file_path_ = file_path_.Append(components[i]);
+ }
+
+ return true;
+ }
+
+ // Nothing has been found.
+ return false;
+}
+
} // namespace util
} // namespace file_system_provider
} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698