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

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

Issue 1058873004: Revert of Add button to add new FSP services to Files app. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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/navigation_list_model.js
diff --git a/ui/file_manager/file_manager/foreground/js/navigation_list_model.js b/ui/file_manager/file_manager/foreground/js/navigation_list_model.js
index 38f26719112b1f04bd4d113cecb97c7826ffd934..5195f867673925289f87e0910dd6c6e74efd891c 100644
--- a/ui/file_manager/file_manager/foreground/js/navigation_list_model.js
+++ b/ui/file_manager/file_manager/foreground/js/navigation_list_model.js
@@ -11,14 +11,24 @@
this.label_ = label;
}
-NavigationModelItem.Type = {
- SHORTCUT: 'shortcut',
- VOLUME: 'volume',
- COMMAND: 'command'
-};
-
NavigationModelItem.prototype = {
get label() { return this.label_; }
+};
+
+/**
+ * Check whether given two model items are same.
+ * @param {NavigationModelItem} item1 The first item to be compared.
+ * @param {NavigationModelItem} item2 The second item to be compared.
+ * @return {boolean} True if given two model items are same.
+ */
+NavigationModelItem.isSame = function(item1, item2) {
+ if (item1.isVolume != item2.isVolume)
+ return false;
+
+ if (item1.isVolume)
+ return item1.volumeInfo === item2.volumeInfo;
+ else
+ return util.isSameEntry(item1.entry, item2.entry);
};
/**
@@ -28,17 +38,18 @@
* @param {!DirectoryEntry} entry Entry. Cannot be null.
* @constructor
* @extends {NavigationModelItem}
- * @struct
*/
function NavigationModelShortcutItem(label, entry) {
NavigationModelItem.call(this, label);
this.entry_ = entry;
+ Object.freeze(this);
}
NavigationModelShortcutItem.prototype = {
__proto__: NavigationModelItem.prototype,
get entry() { return this.entry_; },
- get type() { return NavigationModelItem.Type.SHORTCUT; }
+ get isVolume() { return false; },
+ get isShortcut() { return true; }
};
/**
@@ -48,7 +59,6 @@
* @param {!VolumeInfo} volumeInfo Volume info for the volume. Cannot be null.
* @constructor
* @extends {NavigationModelItem}
- * @struct
*/
function NavigationModelVolumeItem(label, volumeInfo) {
NavigationModelItem.call(this, label);
@@ -57,49 +67,29 @@
// for determining executability of commands.
this.volumeInfo_.resolveDisplayRoot(
function() {}, function() {});
+ Object.freeze(this);
}
NavigationModelVolumeItem.prototype = {
__proto__: NavigationModelItem.prototype,
get volumeInfo() { return this.volumeInfo_; },
- get type() { return NavigationModelItem.Type.VOLUME; }
-};
-
-/**
- * Item of NavigationListModel for commands.
- *
- * @param {cr.ui.Command} command
- * @constructor
- * @extends {NavigationModelItem}
- * @struct
- */
-function NavigationModelCommandItem(command) {
- NavigationModelItem.call(this, command.label);
- this.command_ = command;
-}
-
-NavigationModelCommandItem.prototype = {
- __proto__: NavigationModelItem.prototype,
- get command() { return this.command_; },
- get type() { return NavigationModelItem.Type.COMMAND; }
-};
-
-/**
- * A navigation list model. This model combines multiple models.
+ get isVolume() { return true; },
+ get isShortcut() { return false; }
+};
+
+/**
+ * A navigation list model. This model combines the 2 lists.
* @param {VolumeManagerWrapper} volumeManager VolumeManagerWrapper instance.
* @param {(cr.ui.ArrayDataModel|FolderShortcutsDataModel)} shortcutListModel
* The list of folder shortcut.
- * @param {NavigationModelCommandItem} commandModel, Command button at the
- * end of the list.
* @constructor
* @extends {cr.EventTarget}
*/
-function NavigationListModel(volumeManager, shortcutListModel, commandModel) {
+function NavigationListModel(volumeManager, shortcutListModel) {
cr.EventTarget.call(this);
this.volumeManager_ = volumeManager;
this.shortcutListModel_ = shortcutListModel;
- this.commandModel_ = commandModel;
var volumeInfoToModelItem = function(volumeInfo) {
return new NavigationModelVolumeItem(
@@ -252,12 +242,10 @@
* @return {NavigationModelItem} The item at the given index.
*/
NavigationListModel.prototype.item = function(index) {
- if (index < this.volumeList_.length)
+ var offset = this.volumeList_.length;
+ if (index < offset)
return this.volumeList_[index];
- if (index < this.volumeList_.length + this.shortcutList_.length)
- return this.shortcutList_[index - this.volumeList_.length];
- if (index === this.length_() - 1)
- return this.commandModel_;
+ return this.shortcutList_[index - offset];
};
/**
@@ -266,8 +254,7 @@
* @private
*/
NavigationListModel.prototype.length_ = function() {
- return this.volumeList_.length + this.shortcutList_.length +
- (this.commandModel_ ? 1 : 0);
+ return this.volumeList_.length + this.shortcutList_.length;
};
/**
@@ -290,6 +277,12 @@
* @param {NavigationModelItem} modelItem The entry which is not found.
*/
NavigationListModel.prototype.onItemNotFoundError = function(modelItem) {
- if (modelItem.type === NavigationModelItem.Type.SHORTCUT)
+ if (modelItem.isVolume) {
+ // TODO(mtomasz, yoshiki): Implement when needed.
+ return;
+ }
+ if (modelItem.isShortcut) {
+ // For shortcuts, lets the shortcut model handle this situation.
this.shortcutListModel_.onItemNotFoundError(modelItem.entry);
-};
+ }
+};

Powered by Google App Engine
This is Rietveld 408576698