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

Unified Diff: chrome/browser/resources/md_bookmarks/api_listener.js

Issue 2795623002: MD Bookmarks: Handle bookmark creation (Closed)
Patch Set: Update test Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/resources/md_bookmarks/actions.js ('k') | chrome/browser/resources/md_bookmarks/reducers.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/md_bookmarks/api_listener.js
diff --git a/chrome/browser/resources/md_bookmarks/api_listener.js b/chrome/browser/resources/md_bookmarks/api_listener.js
index 14cd4e97daecedd2ca038430193e0ab0180aa226..9d5aaa480d26be524d2e740deb5deae90c77e59b 100644
--- a/chrome/browser/resources/md_bookmarks/api_listener.js
+++ b/chrome/browser/resources/md_bookmarks/api_listener.js
@@ -23,6 +23,14 @@ cr.define('bookmarks.ApiListener', function() {
/**
* @param {string} id
+ * @param {BookmarkTreeNode} treeNode
+ */
+ function onBookmarkCreated(id, treeNode) {
+ dispatch(bookmarks.actions.createBookmark(id, treeNode));
+ }
+
+ /**
+ * @param {string} id
* @param {{parentId: string, index: number}} removeInfo
*/
function onBookmarkRemoved(id, removeInfo) {
@@ -45,8 +53,12 @@ cr.define('bookmarks.ApiListener', function() {
moveInfo.oldIndex));
}
+ /**
+ * Pauses the Created handler during an import. The imported nodes will all be
+ * loaded at once when the import is finished.
+ */
function onImportBegan() {
- // TODO(rongjie): pause onCreated once this event is used.
+ chrome.bookmarks.onCreated.removeListener(onBookmarkCreated);
}
function onImportEnded() {
@@ -54,10 +66,12 @@ cr.define('bookmarks.ApiListener', function() {
dispatch(bookmarks.actions.refreshNodes(
bookmarks.util.normalizeNodes(results[0])));
});
+ chrome.bookmarks.onCreated.addListener(onBookmarkCreated);
}
function init() {
chrome.bookmarks.onChanged.addListener(onBookmarkChanged);
+ chrome.bookmarks.onCreated.addListener(onBookmarkCreated);
chrome.bookmarks.onMoved.addListener(onBookmarkMoved);
chrome.bookmarks.onRemoved.addListener(onBookmarkRemoved);
chrome.bookmarks.onImportBegan.addListener(onImportBegan);
« no previous file with comments | « chrome/browser/resources/md_bookmarks/actions.js ('k') | chrome/browser/resources/md_bookmarks/reducers.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698