| Index: chrome/browser/chromeos/fileapi/external_file_url_util.cc
|
| diff --git a/chrome/browser/chromeos/fileapi/external_file_url_util.cc b/chrome/browser/chromeos/fileapi/external_file_url_util.cc
|
| index add21ed504ce31252406ae134c2ca9ab11c86fa2..90b4a0c0db91379f4c302334fb1803c05320007d 100644
|
| --- a/chrome/browser/chromeos/fileapi/external_file_url_util.cc
|
| +++ b/chrome/browser/chromeos/fileapi/external_file_url_util.cc
|
| @@ -5,44 +5,73 @@
|
| #include "chrome/browser/chromeos/fileapi/external_file_url_util.h"
|
|
|
| #include <string>
|
| +#include <vector>
|
|
|
| +#include "base/strings/string_util.h"
|
| #include "base/strings/stringprintf.h"
|
| -#include "chrome/browser/chromeos/drive/file_system_util.h"
|
| +#include "chrome/browser/chromeos/file_manager/app_id.h"
|
| +#include "chrome/browser/chromeos/file_manager/fileapi_util.h"
|
| +#include "chrome/browser/extensions/extension_util.h"
|
| +#include "chrome/browser/profiles/profile.h"
|
| #include "chrome/common/url_constants.h"
|
| +#include "content/public/browser/browser_context.h"
|
| #include "content/public/browser/browser_thread.h"
|
| +#include "content/public/browser/storage_partition.h"
|
| #include "net/base/escape.h"
|
| +#include "storage/browser/fileapi/file_system_url.h"
|
|
|
| using content::BrowserThread;
|
|
|
| namespace chromeos {
|
|
|
| -GURL FilePathToExternalFileURL(const base::FilePath& path) {
|
| - std::string url(base::StringPrintf(
|
| - "%s:%s", chrome::kExternalFileScheme, path.AsUTF8Unsafe().c_str()));
|
| - return GURL(url);
|
| +GURL FileSystemURLToExternalFileURL(
|
| + const storage::FileSystemURL& file_system_url) {
|
| + if (file_system_url.mount_type() != storage::kFileSystemTypeExternal)
|
| + return GURL();
|
| +
|
| + switch (file_system_url.type()) {
|
| + case storage::kFileSystemTypeDrive:
|
| + case storage::kFileSystemTypeDeviceMediaAsFileStorage:
|
| + case storage::kFileSystemTypeProvided:
|
| + return GURL(base::StringPrintf(
|
| + "%s:%s",
|
| + chrome::kExternalFileScheme,
|
| + file_system_url.virtual_path().AsUTF8Unsafe().c_str()));
|
| +
|
| + default:
|
| + return GURL();
|
| + }
|
| }
|
|
|
| -base::FilePath ExternalFileURLToFilePath(const GURL& url) {
|
| +base::FilePath ExternalFileURLToVirtualPath(const GURL& url) {
|
| if (!url.is_valid() || url.scheme() != chrome::kExternalFileScheme)
|
| return base::FilePath();
|
| - std::string path_string =
|
| + const std::string path_string =
|
| net::UnescapeURLComponent(url.GetContent(), net::UnescapeRule::NORMAL);
|
| return base::FilePath::FromUTF8Unsafe(path_string);
|
| }
|
|
|
| GURL CreateExternalFileURLFromPath(Profile* profile,
|
| const base::FilePath& path) {
|
| - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| + DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
|
|
| - if (!drive::util::IsUnderDriveMountPoint(path))
|
| + GURL raw_file_system_url;
|
| + if (!file_manager::util::ConvertAbsoluteFilePathToFileSystemUrl(
|
| + profile,
|
| + path,
|
| + file_manager::kFileManagerAppId,
|
| + &raw_file_system_url)) {
|
| return GURL();
|
| + }
|
|
|
| - drive::FileSystemInterface* file_system =
|
| - drive::util::GetFileSystemByProfile(profile);
|
| - if (!file_system)
|
| + const storage::FileSystemURL file_system_url =
|
| + file_manager::util::GetFileSystemContextForExtensionId(
|
| + profile, file_manager::kFileManagerAppId)
|
| + ->CrackURL(raw_file_system_url);
|
| + if (!file_system_url.is_valid())
|
| return GURL();
|
|
|
| - return FilePathToExternalFileURL(drive::util::ExtractDrivePath(path));
|
| + return FileSystemURLToExternalFileURL(file_system_url);
|
| }
|
|
|
| } // namespace chromeos
|
|
|