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

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

Issue 2722643003: [Bookmark Manager] Add first meaningful paint metric to bookmark manager. (Closed)
Patch Set: 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
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('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 (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 'use strict'; 6 'use strict';
7 7
8 /** @const */ var BookmarkList = bmm.BookmarkList; 8 /** @const */ var BookmarkList = bmm.BookmarkList;
9 /** @const */ var BookmarkTree = bmm.BookmarkTree; 9 /** @const */ var BookmarkTree = bmm.BookmarkTree;
10 /** @const */ var Command = cr.ui.Command; 10 /** @const */ var Command = cr.ui.Command;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 64
65 /** 65 /**
66 * @type {TreeItem} 66 * @type {TreeItem}
67 * @const 67 * @const
68 */ 68 */
69 var searchTreeItem = new TreeItem({ 69 var searchTreeItem = new TreeItem({
70 bookmarkId: 'q=' 70 bookmarkId: 'q='
71 }); 71 });
72 72
73 /** 73 /**
74 * @type {boolean}
75 */
76 var firstLoad = true;
77
78 /**
74 * Command shortcut mapping. 79 * Command shortcut mapping.
75 * @const 80 * @const
76 */ 81 */
77 var commandShortcutMap = cr.isMac ? { 82 var commandShortcutMap = cr.isMac ? {
78 'edit': 'Enter', 83 'edit': 'Enter',
79 // On Mac we also allow Meta+Backspace. 84 // On Mac we also allow Meta+Backspace.
80 'delete': 'Delete Backspace Meta|Backspace', 85 'delete': 'Delete Backspace Meta|Backspace',
81 'open-in-background-tab': 'Meta|Enter', 86 'open-in-background-tab': 'Meta|Enter',
82 'open-in-new-tab': 'Shift|Meta|Enter', 87 'open-in-new-tab': 'Shift|Meta|Enter',
83 'open-in-same-window': 'Meta|Down', 88 'open-in-same-window': 'Meta|Down',
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 bmm.list.parentId = id; 189 bmm.list.parentId = id;
185 190
186 // When tree.selectedItem changed, tree view calls navigatTo() then it 191 // When tree.selectedItem changed, tree view calls navigatTo() then it
187 // calls updateHash() when list view displayed specified folder. 192 // calls updateHash() when list view displayed specified folder.
188 bmm.tree.selectedItem = bmm.treeLookup[id] || bmm.tree.selectedItem; 193 bmm.tree.selectedItem = bmm.treeLookup[id] || bmm.tree.selectedItem;
189 } 194 }
190 195
191 // Process the location hash. This is called by onhashchange and when the page 196 // Process the location hash. This is called by onhashchange and when the page
192 // is first loaded. 197 // is first loaded.
193 function processHash() { 198 function processHash() {
199 var wasFirstLoad = firstLoad;
200 firstLoad = false;
194 var id = window.location.hash.slice(1); 201 var id = window.location.hash.slice(1);
195 if (!id) { 202 if (!id) {
196 // If we do not have a hash, select first item in the tree. 203 // If we do not have a hash, select first item in the tree.
197 id = bmm.tree.items[0].bookmarkId; 204 id = bmm.tree.items[0].bookmarkId;
198 } 205 }
199 206
200 var valid = false; 207 var valid = false;
201 if (/^e=/.test(id)) { 208 if (/^e=/.test(id)) {
202 id = id.slice(2); 209 id = id.slice(2);
203 210
(...skipping 29 matching lines...) Expand all
233 } 240 }
234 241
235 // Navigate to bookmark 'id' (which may be a query of the form q=query). 242 // Navigate to bookmark 'id' (which may be a query of the form q=query).
236 if (valid) { 243 if (valid) {
237 updateParentId(id); 244 updateParentId(id);
238 } else { 245 } else {
239 // We need to verify that this is a correct ID. 246 // We need to verify that this is a correct ID.
240 chrome.bookmarks.get(id, function(items) { 247 chrome.bookmarks.get(id, function(items) {
241 if (items && items.length == 1) 248 if (items && items.length == 1)
242 updateParentId(id); 249 updateParentId(id);
250
251 if (wasFirstLoad) {
252 setTimeout(function() {
253 chrome.metricsPrivate.recordTime(
254 'BookmarkManager.ResultsRenderedTime',
255 Math.floor(window.performance.now()));
256 });
257 }
243 }); 258 });
244 } 259 }
245 } 260 }
246 261
247 // Activate is handled by the open-in-same-window-command. 262 // Activate is handled by the open-in-same-window-command.
248 function handleDoubleClickForList(e) { 263 function handleDoubleClickForList(e) {
249 if (e.button == 0) 264 if (e.button == 0)
250 $('open-in-same-window-command').execute(); 265 $('open-in-same-window-command').execute();
251 } 266 }
252 267
(...skipping 1274 matching lines...) Expand 10 before | Expand all | Expand 10 after
1527 1542
1528 cr.ui.FocusOutlineManager.forDocument(document); 1543 cr.ui.FocusOutlineManager.forDocument(document);
1529 initializeSplitter(); 1544 initializeSplitter();
1530 bmm.addBookmarkModelListeners(); 1545 bmm.addBookmarkModelListeners();
1531 dnd.init(selectItemsAfterUserAction); 1546 dnd.init(selectItemsAfterUserAction);
1532 bmm.tree.reload(); 1547 bmm.tree.reload();
1533 } 1548 }
1534 1549
1535 initializeBookmarkManager(); 1550 initializeBookmarkManager();
1536 })(); 1551 })();
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698