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

Unified Diff: ui/file_manager/file_manager/foreground/js/file_tasks.js

Issue 2833413003: Reuse FileTasks when entries are not changed. (Closed)
Patch Set: Created 3 years, 8 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: ui/file_manager/file_manager/foreground/js/file_tasks.js
diff --git a/ui/file_manager/file_manager/foreground/js/file_tasks.js b/ui/file_manager/file_manager/foreground/js/file_tasks.js
index d40eb3366139c3ff831053a90e7370620c9946e6..d4d21471d7f537a6276fb65b76f7f4583176516e 100644
--- a/ui/file_manager/file_manager/foreground/js/file_tasks.js
+++ b/ui/file_manager/file_manager/foreground/js/file_tasks.js
@@ -799,6 +799,33 @@ FileTasks.prototype.showTaskPicker = function(taskDialog, title, message,
};
/**
+ * Compares if the given file entry set and the file entry set for this
fukino 2017/04/25 09:06:10 You compare two entry lists as sets, but if previo
tetsui2 2017/04/26 01:58:04 Done.
+ * FileTasks are same.
+ *
+ * @param {!Array<!Entry>} newEntries
+ * @return {boolean} return true if they are same.
+ */
+FileTasks.prototype.areEntriesSame =
fukino 2017/04/25 09:06:10 nit: "are" is not common for boolean getters. If
tetsui2 2017/04/26 01:58:04 Done.
+ function(newEntries) {
+ // If the length of the entries is different, they are not same.
+ if (this.entries_.length !== newEntries.length) {
+ return false;
+ }
+ // Create set of new entry URLs.
+ var newEntryUrlSet = {};
+ for (var i = 0; i < newEntries.length; i++) {
+ newEntryUrlSet[newEntries[i].toURL()] = true;
+ }
+ // False if one of previous entries is not in the new set.
+ for (var i = 0; i < this.entries_.length; i++) {
+ if (!(this.entries_[i].toURL() in newEntryUrlSet)) {
+ return false;
+ }
+ }
+ return true;
+};
+
+/**
* Gets the default task from tasks. In case there is no such task (i.e. all
* tasks are generic file handlers), then return opt_taskToUseIfNoDefault or
* null.

Powered by Google App Engine
This is Rietveld 408576698