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

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: Fixed comment. 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..7d47eb9cca380554d94051579638a80d18bc705c 100644
--- a/chrome/browser/chromeos/file_manager/file_tasks.cc
+++ b/chrome/browser/chromeos/file_manager/file_tasks.cc
@@ -127,17 +127,25 @@ bool IsFallbackFileHandler(const file_tasks::TaskDescriptor& task) {
return false;
}
+bool IsGenericFileHandler(const extensions::FileHandlerInfo& fileHandlerInfo) {
satorux1 2014/10/30 08:17:21 file_handler_info http://google-styleguide.google
yawano 2014/10/31 01:26:30 Done.
+ return fileHandlerInfo.extensions.count("*") > 0 ||
+ fileHandlerInfo.types.count("*") > 0 ||
+ fileHandlerInfo.types.count("*/*") > 0;
+}
satorux1 2014/10/30 08:17:21 Please move this out of the anonymous namespace an
yawano 2014/10/31 01:26:29 Done.
+
} // namespace
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,7 +361,8 @@ void FindDriveAppTasks(
FullTaskDescriptor(descriptor,
app_info.app_name,
icon_url,
- false /* is_default */));
+ false /* is_default */,
+ false /* is_generic_file_handler */));
}
}
@@ -366,6 +375,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 +401,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 +430,8 @@ void FindFileHandlerTasks(
file_handler->id),
extension->name(),
best_icon,
- false /* is_default */));
+ false /* is_default */,
+ IsGenericFileHandler(*file_handler)));
}
}
@@ -451,7 +473,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