summaryrefslogtreecommitdiffstats
path: root/chrome/browser/bookmarks
diff options
context:
space:
mode:
authorfeldstein@chromium.org <feldstein@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-28 00:04:56 +0000
committerfeldstein@chromium.org <feldstein@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-28 00:04:56 +0000
commitcb6cf79cacd881bcbc4f00bb449d7044619aeced (patch)
tree1b265453e2ad2a33beda3d6630444e76da3321a0 /chrome/browser/bookmarks
parent69b3f1eab57725dd68502c19f4eed1fa9c7f401f (diff)
downloadchromium_src-cb6cf79cacd881bcbc4f00bb449d7044619aeced.zip
chromium_src-cb6cf79cacd881bcbc4f00bb449d7044619aeced.tar.gz
chromium_src-cb6cf79cacd881bcbc4f00bb449d7044619aeced.tar.bz2
Add import/export extension apis
This is a duplicate of 543094. That code review seems to have gotten corrupted as i can no longer publish anything from their web UI. It was LGTM'd+nits by arv, which i've fixed here. BUG=32194 TEST=Import and export bookmarks from the extension Review URL: http://codereview.chromium.org/548167 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37351 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/bookmarks')
-rw-r--r--chrome/browser/bookmarks/bookmark_model.cc10
-rw-r--r--chrome/browser/bookmarks/bookmark_model.h6
-rw-r--r--chrome/browser/bookmarks/bookmark_model_observer.h11
3 files changed, 27 insertions, 0 deletions
diff --git a/chrome/browser/bookmarks/bookmark_model.cc b/chrome/browser/bookmarks/bookmark_model.cc
index 434fde0..5385810 100644
--- a/chrome/browser/bookmarks/bookmark_model.cc
+++ b/chrome/browser/bookmarks/bookmark_model.cc
@@ -609,6 +609,16 @@ void BookmarkModel::RemoveAndDeleteNode(BookmarkNode* delete_me) {
Details<history::URLsStarredDetails>(&details));
}
+void BookmarkModel::BeginImportMode() {
+ FOR_EACH_OBSERVER(BookmarkModelObserver, observers_,
+ BookmarkImportBeginning(this));
+}
+
+void BookmarkModel::EndImportMode() {
+ FOR_EACH_OBSERVER(BookmarkModelObserver, observers_,
+ BookmarkImportEnding(this));
+}
+
BookmarkNode* BookmarkModel::AddNode(BookmarkNode* parent,
int index,
BookmarkNode* node,
diff --git a/chrome/browser/bookmarks/bookmark_model.h b/chrome/browser/bookmarks/bookmark_model.h
index fcea7c7..1ffdcbe 100644
--- a/chrome/browser/bookmarks/bookmark_model.h
+++ b/chrome/browser/bookmarks/bookmark_model.h
@@ -205,6 +205,12 @@ class BookmarkModel : public NotificationObserver, public BookmarkService {
observers_.RemoveObserver(observer);
}
+ // Notify the observes that an import is about to happen, so they can
+ // delay any expensive UI updates until it is finished.
+ void BeginImportMode();
+ void EndImportMode();
+
+
// Unstars or deletes the specified entry. Removing a group entry recursively
// unstars all nodes. Observers are notified immediately.
void Remove(const BookmarkNode* parent, int index);
diff --git a/chrome/browser/bookmarks/bookmark_model_observer.h b/chrome/browser/bookmarks/bookmark_model_observer.h
index e850cb3..2136475 100644
--- a/chrome/browser/bookmarks/bookmark_model_observer.h
+++ b/chrome/browser/bookmarks/bookmark_model_observer.h
@@ -52,6 +52,17 @@ class BookmarkModelObserver {
virtual void BookmarkNodeChildrenReordered(BookmarkModel* model,
const BookmarkNode* node) = 0;
+ // Invoked before a batch import begins. This tells UI intensive observers
+ // to wait until the updates finish to update themselves.
+ // These methods should only be used for imports. Observers should still
+ // respond to BookmarkNodeRemoved immediately, to avoid holding onto
+ // stale node pointers.
+ virtual void BookmarkImportBeginning(BookmarkModel* model) {}
+
+ // Invoked after a batch import finishes. This tells observers to update
+ // themselves if they were waiting for the update to finish.
+ virtual void BookmarkImportEnding(BookmarkModel* model) {}
+
protected:
virtual ~BookmarkModelObserver() {}
};