diff options
author | serya@chromium.org <serya@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-01 13:48:45 +0000 |
---|---|---|
committer | serya@chromium.org <serya@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-01 13:48:45 +0000 |
commit | 802b42cf87cfecb77e5fd6c6bed63037e46f767a (patch) | |
tree | d4933274d7861e0c35136f526dfc16da6fbea9b5 | |
parent | 748e412f6ee73a0724cb4ce7afabe2c977c36a77 (diff) | |
download | chromium_src-802b42cf87cfecb77e5fd6c6bed63037e46f767a.zip chromium_src-802b42cf87cfecb77e5fd6c6bed63037e46f767a.tar.gz chromium_src-802b42cf87cfecb77e5fd6c6bed63037e46f767a.tar.bz2 |
Paths in File Browsers parameters are converted to virtual ones.
BUG=chromium-os:17412
TEST=None
Review URL: http://codereview.chromium.org/7497037
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@94897 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/extensions/file_manager_util.cc | 11 | ||||
-rw-r--r-- | chrome/browser/extensions/file_manager_util.h | 2 | ||||
-rw-r--r-- | chrome/browser/platform_util_chromeos.cc | 11 | ||||
-rw-r--r-- | chrome/browser/resources/file_manager/js/file_manager.js | 15 | ||||
-rw-r--r-- | chrome/browser/ui/views/file_manager_dialog.cc | 8 | ||||
-rw-r--r-- | webkit/chromeos/fileapi/cros_mount_point_provider.cc | 4 |
6 files changed, 34 insertions, 17 deletions
diff --git a/chrome/browser/extensions/file_manager_util.cc b/chrome/browser/extensions/file_manager_util.cc index a315757..678d803 100644 --- a/chrome/browser/extensions/file_manager_util.cc +++ b/chrome/browser/extensions/file_manager_util.cc @@ -125,12 +125,13 @@ bool FileManagerUtil::ConvertFileToRelativeFileSystemPath( GURL FileManagerUtil::GetFileBrowserUrlWithParams( SelectFileDialog::Type type, const string16& title, - const FilePath& default_path, + const FilePath& default_virtual_path, const SelectFileDialog::FileTypeInfo* file_types, int file_type_index, const FilePath::StringType& default_extension) { - std::string json = GetArgumentsJson(type, title, default_path, file_types, - file_type_index, default_extension); + std::string json = GetArgumentsJson(type, title, default_virtual_path, + file_types, file_type_index, + default_extension); return GURL(FileManagerUtil::GetFileBrowserUrl().spec() + "?" + EscapeUrlEncodedData(json, false)); @@ -199,7 +200,7 @@ void FileManagerUtil::ViewItem(const FilePath& full_path, bool enqueue) { std::string FileManagerUtil::GetArgumentsJson( SelectFileDialog::Type type, const string16& title, - const FilePath& default_path, + const FilePath& default_virtual_path, const SelectFileDialog::FileTypeInfo* file_types, int file_type_index, const FilePath::StringType& default_extension) { @@ -207,7 +208,7 @@ std::string FileManagerUtil::GetArgumentsJson( arg_value.SetString("type", GetDialogTypeAsString(type)); arg_value.SetString("title", title); // TODO(zelidrag): Convert local system path into virtual path for File API. - arg_value.SetString("defaultPath", default_path.value()); + arg_value.SetString("defaultPath", default_virtual_path.value()); arg_value.SetString("defaultExtension", default_extension); diff --git a/chrome/browser/extensions/file_manager_util.h b/chrome/browser/extensions/file_manager_util.h index 877eba8..76712ef 100644 --- a/chrome/browser/extensions/file_manager_util.h +++ b/chrome/browser/extensions/file_manager_util.h @@ -36,7 +36,7 @@ class FileManagerUtil { static GURL GetFileBrowserUrlWithParams( SelectFileDialog::Type type, const string16& title, - const FilePath& default_path, + const FilePath& default_virtual_path, const SelectFileDialog::FileTypeInfo* file_types, int file_type_index, const FilePath::StringType& default_extension); diff --git a/chrome/browser/platform_util_chromeos.cc b/chrome/browser/platform_util_chromeos.cc index 2b29de3..b747415 100644 --- a/chrome/browser/platform_util_chromeos.cc +++ b/chrome/browser/platform_util_chromeos.cc @@ -24,14 +24,23 @@ static const std::string kGmailComposeUrl = "https://mail.google.com/mail/?extsrc=mailto&url="; // Opens file browser on UI thread. +static void OpenFileBrowserOnUIThread(const FilePath& dir) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); Browser* browser = BrowserList::GetLastActive(); if (!browser) return; + + FilePath virtual_path; + if (!FileManagerUtil::ConvertFileToRelativeFileSystemPath(browser->profile(), + dir, + &virtual_path)) { + return; + } + GURL url = FileManagerUtil::GetFileBrowserUrlWithParams( - SelectFileDialog::SELECT_NONE, string16(), dir, NULL, 0, + SelectFileDialog::SELECT_NONE, string16(), virtual_path, NULL, 0, FilePath::StringType()); browser->ShowSingletonTab(url); } diff --git a/chrome/browser/resources/file_manager/js/file_manager.js b/chrome/browser/resources/file_manager/js/file_manager.js index f8dbe34..d287211 100644 --- a/chrome/browser/resources/file_manager/js/file_manager.js +++ b/chrome/browser/resources/file_manager/js/file_manager.js @@ -98,13 +98,6 @@ function FileManager(dialogDom, rootEntries, params) { // Optional list of file types. this.fileTypes_ = this.params_.typeList; - var ary = this.defaultPath_.match(/^\/home\/[^\/]+\/user\/Downloads(\/.*)?$/); - if (ary) { - // Chrome will probably suggest the full path to Downloads, but - // we're working with 'virtual paths', so we have to translate. - this.defaultPath_ = '/Downloads' + (ary[1] || ''); - } - this.showCheckboxes_ = (this.dialogType_ == FileManager.DialogType.FULL_PAGE || this.dialogType_ == FileManager.DialogType.SELECT_OPEN_MULTI_FILE); @@ -1094,8 +1087,12 @@ FileManager.prototype = { self.changeDirectory('/', CD_NO_HISTORY); } - this.filesystem_.root.getDirectory( - baseName, {create: false}, onBaseFound, onBaseError); + if (baseName) { + this.filesystem_.root.getDirectory( + baseName, {create: false}, onBaseFound, onBaseError); + } else { + onBaseFound(this.filesystem_.root); + } }; /** diff --git a/chrome/browser/ui/views/file_manager_dialog.cc b/chrome/browser/ui/views/file_manager_dialog.cc index a22757c..322ee87 100644 --- a/chrome/browser/ui/views/file_manager_dialog.cc +++ b/chrome/browser/ui/views/file_manager_dialog.cc @@ -176,8 +176,14 @@ void FileManagerDialog::SelectFileImpl( return; } + FilePath virtual_path; + if (!FileManagerUtil::ConvertFileToRelativeFileSystemPath( + owner_browser->profile(), default_path, &virtual_path)) { + virtual_path = FilePath(); + } + GURL file_browser_url = FileManagerUtil::GetFileBrowserUrlWithParams( - type, title, default_path, file_types, file_type_index, + type, title, virtual_path, file_types, file_type_index, default_extension); extension_dialog_ = ExtensionDialog::Show(file_browser_url, owner_browser, kFileManagerWidth, kFileManagerHeight, diff --git a/webkit/chromeos/fileapi/cros_mount_point_provider.cc b/webkit/chromeos/fileapi/cros_mount_point_provider.cc index e4b0eec..2aee434 100644 --- a/webkit/chromeos/fileapi/cros_mount_point_provider.cc +++ b/webkit/chromeos/fileapi/cros_mount_point_provider.cc @@ -191,6 +191,10 @@ bool CrosMountPointProvider::GetVirtualPath(const FilePath& filesystem_path, *virtual_path = FilePath(iter->first); if (mount_prefix.AppendRelativePath(filesystem_path, virtual_path)) { return true; + } else if (mount_prefix == filesystem_path) { + FilePath root = FilePath(FILE_PATH_LITERAL("/")); + *virtual_path = root.Append(iter->first); + return true; } } return false; |