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

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

Issue 2740863003: MD Bookmarks: Implement search and selection in new data flow system (Closed)
Patch Set: Review round 2 Created 3 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 unified diff | Download patch
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 Utility functions for the Bookmarks page. 6 * @fileoverview Utility functions for the Bookmarks page.
7 */ 7 */
8 8
9 cr.define('bookmarks.util', function() { 9 cr.define('bookmarks.util', function() {
10 /** 10 /**
11 * @param {!BookmarksPageState} state 11 * @param {!BookmarksPageState} state
12 * @return {!Array<string>} 12 * @return {!Array<string>}
13 */ 13 */
14 function getDisplayedList(state) { 14 function getDisplayedList(state) {
15 return assert(state.nodes[assert(state.selectedFolder)].children); 15 if (state.selectedFolder)
16 return assert(state.nodes[state.selectedFolder].children);
17
18 return state.search.results;
16 } 19 }
17 20
18 /** 21 /**
19 * @param {BookmarkTreeNode} rootNode 22 * @param {BookmarkTreeNode} rootNode
20 * @return {NodeList} 23 * @return {NodeList}
21 */ 24 */
22 function normalizeNodes(rootNode) { 25 function normalizeNodes(rootNode) {
23 /** @type {NodeList} */ 26 /** @type {NodeList} */
24 var nodeList = {}; 27 var nodeList = {};
25 var stack = []; 28 var stack = [];
(...skipping 19 matching lines...) Expand all
45 48
46 return nodeList; 49 return nodeList;
47 } 50 }
48 51
49 /** @return {!BookmarksPageState} */ 52 /** @return {!BookmarksPageState} */
50 function createEmptyState() { 53 function createEmptyState() {
51 return { 54 return {
52 nodes: {}, 55 nodes: {},
53 selectedFolder: '0', 56 selectedFolder: '0',
54 closedFolders: {}, 57 closedFolders: {},
58 search: {
59 term: '',
60 inProgress: false,
61 results: [],
62 },
55 }; 63 };
56 } 64 }
57 65
58 return { 66 return {
59 createEmptyState: createEmptyState, 67 createEmptyState: createEmptyState,
60 getDisplayedList: getDisplayedList, 68 getDisplayedList: getDisplayedList,
61 normalizeNodes: normalizeNodes, 69 normalizeNodes: normalizeNodes,
62 }; 70 };
63 }); 71 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/md_bookmarks/types.js ('k') | chrome/test/data/webui/md_bookmarks/item_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698