Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(668)

Unified Diff: chrome/browser/chromeos/file_manager/open_util.cc

Issue 910613002: Do not open a downloaded file with generic file handler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use auto and for-range loop. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 de05b8b7c39c07a9983d9acfe069d6a204b9daa6..9cbc3a072708a49f3f30b844fbbe6604df4dbae8 100644
--- a/chrome/browser/chromeos/file_manager/open_util.cc
+++ b/chrome/browser/chromeos/file_manager/open_util.cc
@@ -103,21 +103,23 @@ void OpenFileWithMimeType(Profile* profile,
file_urls,
&tasks);
- if (tasks.empty()) {
- callback.Run(false);
- return;
- }
-
- const file_tasks::FullTaskDescriptor* chosen_task = &tasks[0];
- for (size_t i = 0; i < tasks.size(); ++i) {
- if (tasks[i].is_default()) {
- chosen_task = &tasks[i];
- break;
+ // Select a default handler. If a default handler is not available, select
+ // a non-generic file handler.
+ const file_tasks::FullTaskDescriptor* chosen_task = nullptr;
+ for (const auto& task : tasks) {
+ if (!task.is_generic_file_handler()) {
+ chosen_task = &task;
+ if (task.is_default())
+ break;
}
}
- ExecuteFileTaskForUrl(profile, chosen_task->task_descriptor(), url);
- callback.Run(true);
+ if (chosen_task != nullptr) {
+ ExecuteFileTaskForUrl(profile, chosen_task->task_descriptor(), url);
+ callback.Run(true);
+ } else {
+ callback.Run(false);
+ }
}
// Opens the file specified by |url| by finding and executing a file task for
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698