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

Side by Side Diff: chrome/browser/resources/bookmark_manager/js/main.js

Issue 14064018: Check that result of bmm.loadSubtree is still the selected item before applying disabled state to c… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 (function() { 5 (function() {
6 /** @const */ var BookmarkList = bmm.BookmarkList; 6 /** @const */ var BookmarkList = bmm.BookmarkList;
7 /** @const */ var BookmarkTree = bmm.BookmarkTree; 7 /** @const */ var BookmarkTree = bmm.BookmarkTree;
8 /** @const */ var Command = cr.ui.Command; 8 /** @const */ var Command = cr.ui.Command;
9 /** @const */ var CommandBinding = cr.ui.CommandBinding; 9 /** @const */ var CommandBinding = cr.ui.CommandBinding;
10 /** @const */ var LinkKind = cr.LinkKind; 10 /** @const */ var LinkKind = cr.LinkKind;
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 // Not available withn incognito is disabled. 359 // Not available withn incognito is disabled.
360 commandDisabled = incognitoModeAvailability == 'disabled'; 360 commandDisabled = incognitoModeAvailability == 'disabled';
361 break; 361 break;
362 } 362 }
363 e.canExecute = selectedItems.length > 0 && !commandDisabled; 363 e.canExecute = selectedItems.length > 0 && !commandDisabled;
364 if (isFolder && e.canExecute) { 364 if (isFolder && e.canExecute) {
365 // We need to get all the bookmark items in this tree. If the tree does not 365 // We need to get all the bookmark items in this tree. If the tree does not
366 // contain any non-folders, we need to disable the command. 366 // contain any non-folders, we need to disable the command.
367 var p = bmm.loadSubtree(selectedItems[0].id); 367 var p = bmm.loadSubtree(selectedItems[0].id);
368 p.addListener(function(node) { 368 p.addListener(function(node) {
369 var selectedItems = getBookmarkNodesForOpenCommands(e.target);
370 if (node.id != selectedItems[0].id)
371 return;
369 command.disabled = !node || !hasBookmarks(node); 372 command.disabled = !node || !hasBookmarks(node);
370 }); 373 });
371 } 374 }
372 } 375 }
373 376
374 /** 377 /**
375 * Calls the backend to figure out if we can paste the clipboard into the active 378 * Calls the backend to figure out if we can paste the clipboard into the active
376 * folder. 379 * folder.
377 * @param {Function=} opt_f Function to call after the state has been updated. 380 * @param {Function=} opt_f Function to call after the state has been updated.
378 */ 381 */
(...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after
1277 }); 1280 });
1278 1281
1279 initializeSplitter(); 1282 initializeSplitter();
1280 bmm.addBookmarkModelListeners(); 1283 bmm.addBookmarkModelListeners();
1281 dnd.init(selectItemsAfterUserAction); 1284 dnd.init(selectItemsAfterUserAction);
1282 tree.reload(); 1285 tree.reload();
1283 } 1286 }
1284 1287
1285 initializeBookmarkManager(); 1288 initializeBookmarkManager();
1286 })(); 1289 })();
OLDNEW
« 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