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

Unified Diff: chrome/browser/extensions/extension_bookmarks_module.h

Issue 102009: more extensions bookmarks changes:... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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 | « no previous file | chrome/browser/extensions/extension_bookmarks_module.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_bookmarks_module.h
===================================================================
--- chrome/browser/extensions/extension_bookmarks_module.h (revision 14841)
+++ chrome/browser/extensions/extension_bookmarks_module.h (working copy)
@@ -2,34 +2,105 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_BOOKMARKS_MODULE_H__
-#define CHROME_BROWSER_EXTENSIONS_EXTENSION_BOOKMARKS_MODULE_H__
+#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_BOOKMARKS_MODULE_H_
+#define CHROME_BROWSER_EXTENSIONS_EXTENSION_BOOKMARKS_MODULE_H_
+#include <string>
+#include <vector>
+
+#include "base/singleton.h"
+#include "chrome/browser/bookmarks/bookmark_model.h"
#include "chrome/browser/extensions/extension_function.h"
-class GetBookmarksFunction : public SyncExtensionFunction {
+// Observes BookmarkModel and then routes the notifications as events to
+// the extension system.
+class ExtensionBookmarkEventRouter : public BookmarkModelObserver {
+ public:
+ static ExtensionBookmarkEventRouter* GetSingleton();
+ virtual ~ExtensionBookmarkEventRouter();
+
+ // Call this for each model to observe. Safe to call multiple times per
+ // model.
+ void Observe(BookmarkModel* model);
+
+ // BookmarkModelObserver
+ virtual void Loaded(BookmarkModel* model);
+ virtual void BookmarkModelBeingDeleted(BookmarkModel* model) { }
+ virtual void BookmarkNodeMoved(BookmarkModel* model,
+ BookmarkNode* old_parent,
+ int old_index,
+ BookmarkNode* new_parent,
+ int new_index);
+ virtual void BookmarkNodeAdded(BookmarkModel* model,
+ BookmarkNode* parent,
+ int index);
+ virtual void BookmarkNodeRemoved(BookmarkModel* model,
+ BookmarkNode* parent,
+ int index);
+ virtual void BookmarkNodeRemoved(BookmarkModel* model,
+ BookmarkNode* parent,
+ int old_index,
+ BookmarkNode* node) {
+ BookmarkNodeRemoved(model, parent, old_index);
+ }
+ virtual void BookmarkNodeChanged(BookmarkModel* model,
+ BookmarkNode* node);
+ virtual void BookmarkNodeFavIconLoaded(BookmarkModel* model,
+ BookmarkNode* node);
+ virtual void BookmarkNodeChildrenReordered(BookmarkModel* model,
+ BookmarkNode* node);
+
+ private:
+ ExtensionBookmarkEventRouter();
+ friend struct DefaultSingletonTraits<ExtensionBookmarkEventRouter>;
+
+ // Helper to actually dispatch an event to extension listeners.
+ void DispatchEvent(Profile* profile,
+ const char* event_name,
+ const std::string json_args);
+
+ // These are stored so that Observe can be called multiple times safely.
+ // This way the caller doesn't have to know whether it's already observing
+ // a particular model or not. The pointers are not owned by this object.
+ std::set<BookmarkModel*> models_;
+
+ DISALLOW_COPY_AND_ASSIGN(ExtensionBookmarkEventRouter);
+};
+
+class BookmarksFunction : public SyncExtensionFunction {
+ virtual void Run();
+};
+
+class GetBookmarksFunction : public BookmarksFunction {
virtual bool RunImpl();
};
-class SearchBookmarksFunction : public SyncExtensionFunction {
+class GetBookmarkChildrenFunction : public BookmarksFunction {
virtual bool RunImpl();
};
-class RemoveBookmarkFunction : public SyncExtensionFunction {
+class GetBookmarkTreeFunction : public BookmarksFunction {
virtual bool RunImpl();
};
-class CreateBookmarkFunction : public SyncExtensionFunction {
+class SearchBookmarksFunction : public BookmarksFunction {
virtual bool RunImpl();
};
-class MoveBookmarkFunction : public SyncExtensionFunction {
+class RemoveBookmarkFunction : public BookmarksFunction {
virtual bool RunImpl();
};
-class SetBookmarkTitleFunction : public SyncExtensionFunction {
+class CreateBookmarkFunction : public BookmarksFunction {
virtual bool RunImpl();
};
-#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_BOOKMARKS_MODULE_H__
+class MoveBookmarkFunction : public BookmarksFunction {
+ virtual bool RunImpl();
+};
+class SetBookmarkTitleFunction : public BookmarksFunction {
+ virtual bool RunImpl();
+};
+
+#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_BOOKMARKS_MODULE_H_
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_bookmarks_module.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698