OLD | NEW |
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 LinkKind = cr.LinkKind; | 9 /** @const */ var LinkKind = cr.LinkKind; |
10 /** @const */ var ListItem = cr.ui.ListItem; | 10 /** @const */ var ListItem = cr.ui.ListItem; |
(...skipping 1241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1252 return filteredIds; | 1252 return filteredIds; |
1253 } | 1253 } |
1254 | 1254 |
1255 /** | 1255 /** |
1256 * Handler for the command event. This is used for context menu of list/tree | 1256 * Handler for the command event. This is used for context menu of list/tree |
1257 * and organized menu. | 1257 * and organized menu. |
1258 * @param {!Event} e The event object. | 1258 * @param {!Event} e The event object. |
1259 */ | 1259 */ |
1260 function handleCommand(e) { | 1260 function handleCommand(e) { |
1261 var command = e.command; | 1261 var command = e.command; |
1262 var target; | 1262 var target = assertInstanceof(e.target, HTMLElement); |
1263 switch (command.id) { | 1263 switch (command.id) { |
1264 case 'import-menu-command': | 1264 case 'import-menu-command': |
1265 recordUserAction('Import'); | 1265 recordUserAction('Import'); |
1266 chrome.bookmarks.import(); | 1266 chrome.bookmarks.import(); |
1267 break; | 1267 break; |
1268 | 1268 |
1269 case 'export-menu-command': | 1269 case 'export-menu-command': |
1270 recordUserAction('Export'); | 1270 recordUserAction('Export'); |
1271 chrome.bookmarks.export(); | 1271 chrome.bookmarks.export(); |
1272 break; | 1272 break; |
1273 | 1273 |
1274 case 'undo-command': | 1274 case 'undo-command': |
1275 if (performGlobalUndo) { | 1275 if (performGlobalUndo) { |
1276 recordUserAction('UndoGlobal'); | 1276 recordUserAction('UndoGlobal'); |
1277 performGlobalUndo(); | 1277 performGlobalUndo(); |
1278 } else { | 1278 } else { |
1279 recordUserAction('UndoNone'); | 1279 recordUserAction('UndoNone'); |
1280 } | 1280 } |
1281 break; | 1281 break; |
1282 | 1282 |
1283 case 'show-in-folder-command': | 1283 case 'show-in-folder-command': |
1284 recordUserAction('ShowInFolder'); | 1284 recordUserAction('ShowInFolder'); |
1285 showInFolder(); | 1285 showInFolder(); |
1286 break; | 1286 break; |
1287 | 1287 |
1288 case 'open-in-new-tab-command': | 1288 case 'open-in-new-tab-command': |
1289 case 'open-in-background-tab-command': | 1289 case 'open-in-background-tab-command': |
1290 recordUserAction('OpenInNewTab'); | 1290 recordUserAction('OpenInNewTab'); |
1291 openBookmarks(LinkKind.BACKGROUND_TAB, | 1291 openBookmarks(LinkKind.BACKGROUND_TAB, target); |
1292 assertInstanceof(e.target, HTMLElement)); | |
1293 break; | 1292 break; |
1294 | 1293 |
1295 case 'open-in-new-window-command': | 1294 case 'open-in-new-window-command': |
1296 recordUserAction('OpenInNewWindow'); | 1295 recordUserAction('OpenInNewWindow'); |
1297 openBookmarks(LinkKind.WINDOW, | 1296 openBookmarks(LinkKind.WINDOW, target); |
1298 assertInstanceof(e.target, HTMLElement)); | |
1299 break; | 1297 break; |
1300 | 1298 |
1301 case 'open-incognito-window-command': | 1299 case 'open-incognito-window-command': |
1302 recordUserAction('OpenIncognito'); | 1300 recordUserAction('OpenIncognito'); |
1303 openBookmarks(LinkKind.INCOGNITO, | 1301 openBookmarks(LinkKind.INCOGNITO, target); |
1304 assertInstanceof(e.target, HTMLElement)); | |
1305 break; | 1302 break; |
1306 | 1303 |
1307 case 'delete-from-folders-menu-command': | 1304 case 'delete-from-folders-menu-command': |
1308 target = bmm.tree; | 1305 target = bmm.tree; |
1309 case 'delete-command': | 1306 case 'delete-command': |
1310 recordUserAction('Delete'); | 1307 recordUserAction('Delete'); |
1311 deleteBookmarks(target || assertInstanceof(e.target, HTMLElement)); | 1308 deleteBookmarks(target); |
1312 break; | 1309 break; |
1313 | 1310 |
1314 case 'copy-from-folders-menu-command': | 1311 case 'copy-from-folders-menu-command': |
1315 target = bmm.tree; | 1312 target = bmm.tree; |
1316 case 'copy-command': | 1313 case 'copy-command': |
1317 recordUserAction('Copy'); | 1314 recordUserAction('Copy'); |
1318 chrome.bookmarkManagerPrivate.copy(getSelectedBookmarkIds(target), | 1315 chrome.bookmarkManagerPrivate.copy(getSelectedBookmarkIds(target), |
1319 updatePasteCommand); | 1316 updatePasteCommand); |
1320 break; | 1317 break; |
1321 | 1318 |
(...skipping 18 matching lines...) Expand all Loading... |
1340 | 1337 |
1341 case 'paste-from-context-menu-command': | 1338 case 'paste-from-context-menu-command': |
1342 pasteBookmark(getSelectedId()); | 1339 pasteBookmark(getSelectedId()); |
1343 break; | 1340 break; |
1344 | 1341 |
1345 case 'sort-command': | 1342 case 'sort-command': |
1346 recordUserAction('Sort'); | 1343 recordUserAction('Sort'); |
1347 chrome.bookmarkManagerPrivate.sortChildren(bmm.list.parentId); | 1344 chrome.bookmarkManagerPrivate.sortChildren(bmm.list.parentId); |
1348 break; | 1345 break; |
1349 | 1346 |
1350 case 'rename-folder-command': | |
1351 editItem(assertInstanceof(e.target, HTMLElement)); | |
1352 break; | |
1353 | 1347 |
1354 case 'rename-folder-from-folders-menu-command': | 1348 case 'rename-folder-from-folders-menu-command': |
1355 editItem(bmm.tree); | 1349 target = bmm.tree; |
| 1350 case 'rename-folder-command': |
| 1351 editItem(target); |
1356 break; | 1352 break; |
1357 | 1353 |
1358 case 'edit-command': | 1354 case 'edit-command': |
1359 recordUserAction('Edit'); | 1355 recordUserAction('Edit'); |
1360 editItem(); | 1356 editItem(); |
1361 break; | 1357 break; |
1362 | 1358 |
1363 case 'new-folder-from-folders-menu-command': | 1359 case 'new-folder-from-folders-menu-command': |
1364 target = bmm.tree; | 1360 target = bmm.tree; |
1365 case 'new-folder-command': | 1361 case 'new-folder-command': |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1519 | 1515 |
1520 cr.ui.FocusOutlineManager.forDocument(document); | 1516 cr.ui.FocusOutlineManager.forDocument(document); |
1521 initializeSplitter(); | 1517 initializeSplitter(); |
1522 bmm.addBookmarkModelListeners(); | 1518 bmm.addBookmarkModelListeners(); |
1523 dnd.init(selectItemsAfterUserAction); | 1519 dnd.init(selectItemsAfterUserAction); |
1524 bmm.tree.reload(); | 1520 bmm.tree.reload(); |
1525 } | 1521 } |
1526 | 1522 |
1527 initializeBookmarkManager(); | 1523 initializeBookmarkManager(); |
1528 })(); | 1524 })(); |
OLD | NEW |