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..28892a5f35f6e33b300e2d38ae8d102b6140c938 100644 |
--- a/chrome/browser/chromeos/file_manager/open_util.cc |
+++ b/chrome/browser/chromeos/file_manager/open_util.cc |
@@ -87,11 +87,23 @@ 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) { |
hashimoto
2014/09/29 05:34:13
nit: indent.
asanka
2014/09/29 16:17:53
Done.
|
+ int message; |
hashimoto
2014/09/29 05:34:13
nit: While you are here, could you fix this line n
asanka
2014/09/29 16:17:52
Done.
|
+ 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); |
+} |
+ |
+// 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 +120,7 @@ void OpenFileWithMimeType(Profile* profile, |
&tasks); |
if (tasks.empty()) { |
- callback.Run(false); |
+ WarnOnOpenFileFailure(profile, path); |
return; |
} |
@@ -121,56 +133,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 +172,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 +194,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) { |