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

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

Issue 686393002: Add isGenericFileHandler property to FileTask. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added unitteset for IsGenericFileHandler. Created 6 years, 2 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
Index: chrome/browser/chromeos/file_manager/file_tasks.cc
diff --git a/chrome/browser/chromeos/file_manager/file_tasks.cc b/chrome/browser/chromeos/file_manager/file_tasks.cc
index 238a29eee0f59909d9e97c557d354d8497e98ef5..0a6395e7c0761744ea4f47d00342cf5eacfcacc8 100644
--- a/chrome/browser/chromeos/file_manager/file_tasks.cc
+++ b/chrome/browser/chromeos/file_manager/file_tasks.cc
@@ -133,11 +133,13 @@ FullTaskDescriptor::FullTaskDescriptor(
const TaskDescriptor& task_descriptor,
const std::string& task_title,
const GURL& icon_url,
- bool is_default)
+ bool is_default,
+ bool is_generic_file_handler)
: task_descriptor_(task_descriptor),
task_title_(task_title),
icon_url_(icon_url),
- is_default_(is_default) {
+ is_default_(is_default),
+ is_generic_file_handler_(is_generic_file_handler) {
}
void UpdateDefaultTask(PrefService* pref_service,
@@ -353,10 +355,18 @@ void FindDriveAppTasks(
FullTaskDescriptor(descriptor,
app_info.app_name,
icon_url,
- false /* is_default */));
+ false /* is_default */,
+ false /* is_generic_file_handler */));
}
}
+bool IsGenericFileHandler(
+ const extensions::FileHandlerInfo& file_handler_info) {
+ return file_handler_info.extensions.count("*") > 0 ||
+ file_handler_info.types.count("*") > 0 ||
+ file_handler_info.types.count("*/*") > 0;
+}
+
void FindFileHandlerTasks(
Profile* profile,
const PathAndMimeTypeSet& path_mime_set,
@@ -366,6 +376,7 @@ void FindFileHandlerTasks(
const extensions::ExtensionSet& enabled_extensions =
extensions::ExtensionRegistry::Get(profile)->enabled_extensions();
+
for (extensions::ExtensionSet::const_iterator iter =
enabled_extensions.begin();
iter != enabled_extensions.end();
@@ -391,8 +402,19 @@ void FindFileHandlerTasks(
if (file_handlers.empty())
continue;
- // Only show the first matching handler from each app.
- const extensions::FileHandlerInfo* file_handler = file_handlers.front();
+ // Show the first matching non-generic handler of each app. If there doesn't
+ // exist such handler, show the first matching handler of the app.
+ const extensions::FileHandlerInfo* file_handler = nullptr;
+ for (auto handler : file_handlers) {
+ if (!IsGenericFileHandler(*handler)) {
+ file_handler = handler;
+ break;
+ }
+ }
+ if (file_handler == nullptr) {
+ file_handler = file_handlers.front();
+ }
+
std::string task_id = file_tasks::MakeTaskID(
extension->id(), file_tasks::TASK_TYPE_FILE_HANDLER, file_handler->id);
@@ -409,7 +431,8 @@ void FindFileHandlerTasks(
file_handler->id),
extension->name(),
best_icon,
- false /* is_default */));
+ false /* is_default */,
+ IsGenericFileHandler(*file_handler)));
}
}
@@ -451,7 +474,8 @@ void FindFileBrowserHandlerTasks(
handler->id()),
handler->title(),
icon_url,
- false /* is_default */));
+ false /* is_default */,
+ false /* is_generic_file_handler */));
}
}

Powered by Google App Engine
This is Rietveld 408576698