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

Side by Side Diff: chrome/browser/resources/md_bookmarks/actions.js

Issue 2813503002: MD Bookmarks: Prevent navigating to invalid folders (Closed)
Patch Set: handleAction -> dispatch Created 3 years, 7 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 | chrome/browser/resources/md_bookmarks/api_listener.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 /** 5 /**
6 * @fileoverview Module for functions which produce action objects. These are 6 * @fileoverview Module for functions which produce action objects. These are
7 * listed in one place to document available actions and their parameters. 7 * listed in one place to document available actions and their parameters.
8 */ 8 */
9 9
10 cr.define('bookmarks.actions', function() { 10 cr.define('bookmarks.actions', function() {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 */ 90 */
91 function refreshNodes(nodeMap) { 91 function refreshNodes(nodeMap) {
92 return { 92 return {
93 name: 'refresh-nodes', 93 name: 'refresh-nodes',
94 nodes: nodeMap, 94 nodes: nodeMap,
95 }; 95 };
96 }; 96 };
97 97
98 /** 98 /**
99 * @param {string} id 99 * @param {string} id
100 * @return {!Action} 100 * @param {NodeMap} nodes Current node state. Can be ommitted in tests.
101 * @return {?Action}
101 */ 102 */
102 function selectFolder(id) { 103 function selectFolder(id, nodes) {
103 assert(id != '0', 'Cannot select root folder'); 104 if (nodes && (id == ROOT_NODE_ID || !nodes[id] || nodes[id].url)) {
105 console.warn('Tried to select invalid folder: ' + id);
106 return null;
107 }
108
104 return { 109 return {
105 name: 'select-folder', 110 name: 'select-folder',
106 id: id, 111 id: id,
107 }; 112 };
108 } 113 }
109 114
110 /** 115 /**
111 * @param {string} id 116 * @param {string} id
112 * @param {boolean} open 117 * @param {boolean} open
113 * @return {!Action} 118 * @return {!Action}
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 moveBookmark: moveBookmark, 211 moveBookmark: moveBookmark,
207 refreshNodes: refreshNodes, 212 refreshNodes: refreshNodes,
208 removeBookmark: removeBookmark, 213 removeBookmark: removeBookmark,
209 reorderChildren: reorderChildren, 214 reorderChildren: reorderChildren,
210 selectFolder: selectFolder, 215 selectFolder: selectFolder,
211 selectItem: selectItem, 216 selectItem: selectItem,
212 setSearchResults: setSearchResults, 217 setSearchResults: setSearchResults,
213 setSearchTerm: setSearchTerm, 218 setSearchTerm: setSearchTerm,
214 }; 219 };
215 }); 220 });
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/md_bookmarks/api_listener.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698