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

Unified Diff: chrome/browser/resources/file_manager/foreground/js/photo/gallery.js

Issue 124923002: Fix selecting when opening an image from the download shelf. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed a comment. Created 6 years, 11 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/resources/file_manager/foreground/js/photo/gallery.js
diff --git a/chrome/browser/resources/file_manager/foreground/js/photo/gallery.js b/chrome/browser/resources/file_manager/foreground/js/photo/gallery.js
index 91171b6d3f14595f374c8af904ddc5da5f4a0ea6..69fbcacfe16bb61194cb5256ada36a873ec39279 100644
--- a/chrome/browser/resources/file_manager/foreground/js/photo/gallery.js
+++ b/chrome/browser/resources/file_manager/foreground/js/photo/gallery.js
@@ -274,8 +274,7 @@ Gallery.prototype.createToolbarButton_ = function(className, title) {
* Loads the content.
*
* @param {Array.<Entry>} entries Array of entries.
- * @param {Array.<Entry>} selectedEntries Array of selected entries. Must be a
- * subset of {@code entries}.
+ * @param {Array.<Entry>} selectedEntries Array of selected entries.
*/
Gallery.prototype.load = function(entries, selectedEntries) {
var items = [];
@@ -286,9 +285,15 @@ Gallery.prototype.load = function(entries, selectedEntries) {
this.selectionModel_.adjustLength(this.dataModel_.length);
+ // Comparing Entries by reference is not safe. Therefore we have to use URLs.
+ var entryIndexesByURLs = {};
+ for (var index = 0; index < entries.length; index++) {
+ entryIndexesByURLs[entries[index].toURL()] = index;
+ }
+
for (var i = 0; i !== selectedEntries.length; i++) {
- var selectedIndex = entries.indexOf(selectedEntries[i]);
- if (selectedIndex >= 0)
+ var selectedIndex = entryIndexesByURLs[selectedEntries[i].toURL()];
+ if (selectedIndex !== undefined)
this.selectionModel_.setIndexSelected(selectedIndex, true);
else
console.error('Cannot select ' + selectedEntries[i]);
« 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