From 3f4a1f51cb21fc48e455586f91a6d295cd8172ef Mon Sep 17 00:00:00 2001 From: "gspencer@chromium.org" Date: Tue, 24 Jul 2012 22:56:24 +0000 Subject: Merge 146147 - Open/save dialog assumes the defaultPath parameter without '/' as a default file name. MERGE NOTE: Had to manually merge this change due to conflicts. Passed unit and browser tests for file dialog. BUG=134578 TEST=Manual test. TBR=satorux@chromium.org Review URL: https://chromiumcodereview.appspot.com/10795099 git-svn-id: svn://svn.chromium.org/chrome/branches/1180/src@148237 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/resources/file_manager/js/file_manager.js | 9 ++++----- chrome/browser/ui/views/select_file_dialog_extension.cc | 4 +++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/chrome/browser/resources/file_manager/js/file_manager.js b/chrome/browser/resources/file_manager/js/file_manager.js index d20e231..4243b89 100644 --- a/chrome/browser/resources/file_manager/js/file_manager.js +++ b/chrome/browser/resources/file_manager/js/file_manager.js @@ -19,9 +19,6 @@ function FileManager(dialogDom) { this.params_ = location.search ? JSON.parse(decodeURIComponent(location.search.substr(1))) : {}; - if (this.params_.defaultPath && this.params_.defaultPath.indexOf('/') != 0) - this.params_.defaultPath = '/' + this.params_.defaultPath; - this.listType_ = null; this.showDelayTimeout_ = null; @@ -1483,8 +1480,10 @@ FileManager.prototype = { return; if (!path) { - this.directoryModel_.setupDefaultPath(); - return; + path = this.directoryModel_.getDefaultDirectory(); + } else if (path.indexOf('/') == -1) { + // Path is a file name. + path = this.directoryModel_.getDefaultDirectory() + '/' + path; } // In the FULL_PAGE mode if the hash path points to a file we might have diff --git a/chrome/browser/ui/views/select_file_dialog_extension.cc b/chrome/browser/ui/views/select_file_dialog_extension.cc index b8e3d26..2d61760 100644 --- a/chrome/browser/ui/views/select_file_dialog_extension.cc +++ b/chrome/browser/ui/views/select_file_dialog_extension.cc @@ -266,8 +266,10 @@ void SelectFileDialogExtension::SelectFileImpl( } FilePath virtual_path; - if (!file_manager_util::ConvertFileToRelativeFileSystemPath( + if (file_manager_util::ConvertFileToRelativeFileSystemPath( owner_browser_->profile(), default_path, &virtual_path)) { + virtual_path = FilePath("/").Append(virtual_path); + } else { virtual_path = default_path.BaseName(); } -- cgit v1.1