| Index: chrome/browser/chromeos/file_manager/open_util.cc
|
| diff --git a/chrome/browser/chromeos/file_manager/open_util.cc b/chrome/browser/chromeos/file_manager/open_util.cc
|
| index dad853242d6b4dd7ad68aacec4cdd91ebf68d9c0..a1ba486b528643c939eeec16054cd8579e988cc4 100644
|
| --- a/chrome/browser/chromeos/file_manager/open_util.cc
|
| +++ b/chrome/browser/chromeos/file_manager/open_util.cc
|
| @@ -87,11 +87,20 @@ void OpenFileManagerWithInternalActionId(Profile* profile,
|
| ExecuteFileTaskForUrl(profile, task, url);
|
| }
|
|
|
| -// Opens the file with fetched MIME type and calls the callback.
|
| +void WarnOnOpenFileFailure(Profile* profile, const base::FilePath& file_path) {
|
| + int message = IDS_FILE_BROWSER_ERROR_VIEWING_FILE;
|
| + if (file_path.Extension() == FILE_PATH_LITERAL(".dmg"))
|
| + message = IDS_FILE_BROWSER_ERROR_VIEWING_FILE_FOR_DMG;
|
| + else if (file_path.Extension() == FILE_PATH_LITERAL(".exe") ||
|
| + file_path.Extension() == FILE_PATH_LITERAL(".msi"))
|
| + message = IDS_FILE_BROWSER_ERROR_VIEWING_FILE_FOR_EXECUTABLE;
|
| + ShowWarningMessageBox(profile, file_path, message);
|
| +}
|
| +
|
| +// Opens the file with fetched MIME type and warns the user on failure.
|
| void OpenFileWithMimeType(Profile* profile,
|
| const base::FilePath& path,
|
| const GURL& url,
|
| - const base::Callback<void(bool)>& callback,
|
| const std::string& mime_type) {
|
| extensions::app_file_handler_util::PathAndMimeTypeSet path_mime_set;
|
| path_mime_set.insert(std::make_pair(path, mime_type));
|
| @@ -108,7 +117,7 @@ void OpenFileWithMimeType(Profile* profile,
|
| &tasks);
|
|
|
| if (tasks.empty()) {
|
| - callback.Run(false);
|
| + WarnOnOpenFileFailure(profile, path);
|
| return;
|
| }
|
|
|
| @@ -121,56 +130,6 @@ void OpenFileWithMimeType(Profile* profile,
|
| }
|
|
|
| ExecuteFileTaskForUrl(profile, chosen_task->task_descriptor(), url);
|
| - callback.Run(true);
|
| -}
|
| -
|
| -// Opens the file specified by |url| by finding and executing a file task for
|
| -// the file. In case of success, calls |callback| with true. Otherwise the
|
| -// returned value is false.
|
| -void OpenFile(Profile* profile,
|
| - const base::FilePath& path,
|
| - const GURL& url,
|
| - const base::Callback<void(bool)>& callback) {
|
| - extensions::app_file_handler_util::GetMimeTypeForLocalPath(
|
| - profile,
|
| - path,
|
| - base::Bind(&OpenFileWithMimeType, profile, path, url, callback));
|
| -}
|
| -
|
| -// Called when execution of ContinueOpenItem() is completed.
|
| -void OnContinueOpenItemCompleted(Profile* profile,
|
| - const base::FilePath& file_path,
|
| - bool result) {
|
| - if (!result) {
|
| - int message;
|
| - if (file_path.Extension() == FILE_PATH_LITERAL(".dmg"))
|
| - message = IDS_FILE_BROWSER_ERROR_VIEWING_FILE_FOR_DMG;
|
| - else if (file_path.Extension() == FILE_PATH_LITERAL(".exe") ||
|
| - file_path.Extension() == FILE_PATH_LITERAL(".msi"))
|
| - message = IDS_FILE_BROWSER_ERROR_VIEWING_FILE_FOR_EXECUTABLE;
|
| - else
|
| - message = IDS_FILE_BROWSER_ERROR_VIEWING_FILE;
|
| - ShowWarningMessageBox(profile, file_path, message);
|
| - }
|
| -}
|
| -
|
| -// Used to implement OpenItem().
|
| -void ContinueOpenItem(Profile* profile,
|
| - const base::FilePath& file_path,
|
| - const GURL& url,
|
| - base::File::Error error) {
|
| - DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
| -
|
| - if (error == base::File::FILE_OK) {
|
| - // A directory exists at |url|. Open it with the file manager.
|
| - OpenFileManagerWithInternalActionId(profile, url, "open");
|
| - } else {
|
| - // |url| should be a file. Open it.
|
| - OpenFile(profile,
|
| - file_path,
|
| - url,
|
| - base::Bind(&OnContinueOpenItemCompleted, profile, file_path));
|
| - }
|
| }
|
|
|
| // Converts the |given_path| passed from external callers to the form that the
|
| @@ -210,7 +169,21 @@ void OpenRemovableDrive(Profile* profile, const base::FilePath& file_path) {
|
| OpenFileManagerWithInternalActionId(profile, url, "auto-open");
|
| }
|
|
|
| -void OpenItem(Profile* profile, const base::FilePath& file_path) {
|
| +void OpenFile(Profile* profile, const base::FilePath& file_path) {
|
| + DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
| +
|
| + base::FilePath converted_path;
|
| + GURL url;
|
| + if (!ConvertPath(profile, file_path, &converted_path, &url))
|
| + return;
|
| +
|
| + extensions::app_file_handler_util::GetMimeTypeForLocalPath(
|
| + profile,
|
| + converted_path,
|
| + base::Bind(&OpenFileWithMimeType, profile, converted_path, url));
|
| +}
|
| +
|
| +void OpenFolder(Profile* profile, const base::FilePath& file_path) {
|
| DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
|
|
| base::FilePath converted_path;
|
| @@ -218,10 +191,8 @@ void OpenItem(Profile* profile, const base::FilePath& file_path) {
|
| if (!ConvertPath(profile, file_path, &converted_path, &url))
|
| return;
|
|
|
| - CheckIfDirectoryExists(
|
| - GetFileSystemContextForExtensionId(profile, kFileManagerAppId),
|
| - url,
|
| - base::Bind(&ContinueOpenItem, profile, converted_path, url));
|
| + // This call will only open Files.app.
|
| + OpenFileManagerWithInternalActionId(profile, url, "open");
|
| }
|
|
|
| void ShowItemInFolder(Profile* profile, const base::FilePath& file_path) {
|
|
|