#ifndef CHROME_BROWSER_EXTENSIONS_API_BOOKMARK_MANAGER_PRIVATE_BOOKMARK_MANAGER_PRIVATE_API_H_
#define CHROME_BROWSER_EXTENSIONS_API_BOOKMARK_MANAGER_PRIVATE_BOOKMARK_MANAGER_PRIVATE_API_H_
#include "base/memory/scoped_ptr.h"
#include "base/values.h"
#include "chrome/browser/bookmarks/base_bookmark_model_observer.h"
#include "chrome/browser/bookmarks/bookmark_node_data.h"
#include "chrome/browser/extensions/api/bookmarks/bookmarks_api.h"
#include "chrome/browser/extensions/chrome_extension_function.h"
#include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h"
#include "chrome/browser/undo/bookmark_undo_service.h"
#include "chrome/browser/undo/bookmark_undo_service_factory.h"
#include "extensions/browser/browser_context_keyed_api_factory.h"
#include "extensions/browser/event_router.h"
struct BookmarkNodeData;
class Profile;
namespace content {
class BrowserContext;
class WebContents;
}
namespace extensions {
class BookmarkManagerPrivateEventRouter : public BaseBookmarkModelObserver {
public:
BookmarkManagerPrivateEventRouter(content::BrowserContext* browser_context,
BookmarkModel* bookmark_model);
virtual ~BookmarkManagerPrivateEventRouter();
virtual void BookmarkModelChanged() OVERRIDE;
virtual void BookmarkModelBeingDeleted(BookmarkModel* model) OVERRIDE;
virtual void BookmarkMetaInfoChanged(BookmarkModel* model,
const BookmarkNode* node) OVERRIDE;
private:
void DispatchEvent(const std::string& event_name,
scoped_ptr<base::ListValue> event_args);
content::BrowserContext* browser_context_;
BookmarkModel* bookmark_model_;
};
class BookmarkManagerPrivateAPI : public BrowserContextKeyedAPI,
public EventRouter::Observer {
public:
explicit BookmarkManagerPrivateAPI(content::BrowserContext* browser_context);
virtual ~BookmarkManagerPrivateAPI();
virtual void Shutdown() OVERRIDE;
static BrowserContextKeyedAPIFactory<BookmarkManagerPrivateAPI>*
GetFactoryInstance();
virtual void OnListenerAdded(const EventListenerInfo& details) OVERRIDE;
private:
friend class BrowserContextKeyedAPIFactory<BookmarkManagerPrivateAPI>;
static const char* service_name() { return "BookmarkManagerPrivateAPI"; }
static const bool kServiceIsNULLWhileTesting = true;
content::BrowserContext* browser_context_;
scoped_ptr<BookmarkManagerPrivateEventRouter> event_router_;
};
class BookmarkManagerPrivateDragEventRouter
: public BookmarkTabHelper::BookmarkDrag {
public:
BookmarkManagerPrivateDragEventRouter(Profile* profile,
content::WebContents* web_contents);
virtual ~BookmarkManagerPrivateDragEventRouter();
virtual void OnDragEnter(const BookmarkNodeData& data) OVERRIDE;
virtual void OnDragOver(const BookmarkNodeData& data) OVERRIDE;
virtual void OnDragLeave(const BookmarkNodeData& data) OVERRIDE;
virtual void OnDrop(const BookmarkNodeData& data) OVERRIDE;
const BookmarkNodeData* GetBookmarkNodeData();
void ClearBookmarkNodeData();
private:
void DispatchEvent(const std::string& event_name,
scoped_ptr<base::ListValue> args);
Profile* profile_;
content::WebContents* web_contents_;
BookmarkNodeData bookmark_drag_data_;
DISALLOW_COPY_AND_ASSIGN(BookmarkManagerPrivateDragEventRouter);
};
class ClipboardBookmarkManagerFunction : public extensions::BookmarksFunction {
protected:
virtual ~ClipboardBookmarkManagerFunction() {}
bool CopyOrCut(bool cut, const std::vector<std::string>& id_list);
};
class BookmarkManagerPrivateCopyFunction
: public ClipboardBookmarkManagerFunction {
public:
DECLARE_EXTENSION_FUNCTION("bookmarkManagerPrivate.copy",
BOOKMARKMANAGERPRIVATE_COPY)
protected:
virtual ~BookmarkManagerPrivateCopyFunction() {}
virtual bool RunImpl() OVERRIDE;
};
class BookmarkManagerPrivateCutFunction
: public ClipboardBookmarkManagerFunction {
public:
DECLARE_EXTENSION_FUNCTION("bookmarkManagerPrivate.cut",
BOOKMARKMANAGERPRIVATE_CUT)
protected:
virtual ~BookmarkManagerPrivateCutFunction() {}
virtual bool RunImpl() OVERRIDE;
};
class BookmarkManagerPrivatePasteFunction
: public extensions::BookmarksFunction {
public:
DECLARE_EXTENSION_FUNCTION("bookmarkManagerPrivate.paste",
BOOKMARKMANAGERPRIVATE_PASTE)
protected:
virtual ~BookmarkManagerPrivatePasteFunction() {}
virtual bool RunImpl() OVERRIDE;
};
class BookmarkManagerPrivateCanPasteFunction
: public extensions::BookmarksFunction {
public:
DECLARE_EXTENSION_FUNCTION("bookmarkManagerPrivate.canPaste",
BOOKMARKMANAGERPRIVATE_CANPASTE)
protected:
virtual ~BookmarkManagerPrivateCanPasteFunction() {}
virtual bool RunImpl() OVERRIDE;
};
class BookmarkManagerPrivateSortChildrenFunction
: public extensions::BookmarksFunction {
public:
DECLARE_EXTENSION_FUNCTION("bookmarkManagerPrivate.sortChildren",
BOOKMARKMANAGERPRIVATE_SORTCHILDREN)
protected:
virtual ~BookmarkManagerPrivateSortChildrenFunction() {}
virtual bool RunImpl() OVERRIDE;
};
class BookmarkManagerPrivateGetStringsFunction : public AsyncExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("bookmarkManagerPrivate.getStrings",
BOOKMARKMANAGERPRIVATE_GETSTRINGS)
protected:
virtual ~BookmarkManagerPrivateGetStringsFunction() {}
virtual bool RunImpl() OVERRIDE;
};
class BookmarkManagerPrivateStartDragFunction
: public extensions::BookmarksFunction {
public:
DECLARE_EXTENSION_FUNCTION("bookmarkManagerPrivate.startDrag",
BOOKMARKMANAGERPRIVATE_STARTDRAG)
protected:
virtual ~BookmarkManagerPrivateStartDragFunction() {}
virtual bool RunImpl() OVERRIDE;
};
class BookmarkManagerPrivateDropFunction
: public extensions::BookmarksFunction {
public:
DECLARE_EXTENSION_FUNCTION("bookmarkManagerPrivate.drop",
BOOKMARKMANAGERPRIVATE_DROP)
protected:
virtual ~BookmarkManagerPrivateDropFunction() {}
virtual bool RunImpl() OVERRIDE;
};
class BookmarkManagerPrivateGetSubtreeFunction
: public extensions::BookmarksFunction {
public:
DECLARE_EXTENSION_FUNCTION("bookmarkManagerPrivate.getSubtree",
BOOKMARKMANAGERPRIVATE_GETSUBTREE)
protected:
virtual ~BookmarkManagerPrivateGetSubtreeFunction() {}
virtual bool RunImpl() OVERRIDE;
};
class BookmarkManagerPrivateCanEditFunction
: public extensions::BookmarksFunction {
public:
DECLARE_EXTENSION_FUNCTION("bookmarkManagerPrivate.canEdit",
BOOKMARKMANAGERPRIVATE_CANEDIT)
protected:
virtual ~BookmarkManagerPrivateCanEditFunction() {}
virtual bool RunImpl() OVERRIDE;
};
class BookmarkManagerPrivateRecordLaunchFunction
: public extensions::BookmarksFunction {
public:
DECLARE_EXTENSION_FUNCTION("bookmarkManagerPrivate.recordLaunch",
BOOKMARKMANAGERPRIVATE_RECORDLAUNCH)
protected:
virtual ~BookmarkManagerPrivateRecordLaunchFunction() {}
virtual bool RunImpl() OVERRIDE;
};
class BookmarkManagerPrivateGetMetaInfoFunction
: public extensions::BookmarksFunction {
public:
DECLARE_EXTENSION_FUNCTION("bookmarkManagerPrivate.getMetaInfo",
BOOKMARKMANAGERPRIVATE_GETMETAINFO)
protected:
virtual ~BookmarkManagerPrivateGetMetaInfoFunction() {}
virtual bool RunImpl() OVERRIDE;
};
class BookmarkManagerPrivateSetMetaInfoFunction
: public extensions::BookmarksFunction {
public:
DECLARE_EXTENSION_FUNCTION("bookmarkManagerPrivate.setMetaInfo",
BOOKMARKMANAGERPRIVATE_SETMETAINFO)
protected:
virtual ~BookmarkManagerPrivateSetMetaInfoFunction() {}
virtual bool RunImpl() OVERRIDE;
};
class BookmarkManagerPrivateCanOpenNewWindowsFunction
: public extensions::BookmarksFunction {
public:
DECLARE_EXTENSION_FUNCTION("bookmarkManagerPrivate.canOpenNewWindows",
BOOKMARKMANAGERPRIVATE_CANOPENNEWWINDOWS)
protected:
virtual ~BookmarkManagerPrivateCanOpenNewWindowsFunction() {}
virtual bool RunImpl() OVERRIDE;
};
class BookmarkManagerPrivateRemoveTreesFunction
: public extensions::BookmarksFunction {
public:
DECLARE_EXTENSION_FUNCTION("bookmarkManagerPrivate.removeTrees",
BOOKMARKMANAGERPRIVATE_REMOVETREES)
protected:
virtual ~BookmarkManagerPrivateRemoveTreesFunction() {}
virtual bool RunImpl() OVERRIDE;
};
class BookmarkManagerPrivateUndoFunction
: public extensions::BookmarksFunction {
public:
DECLARE_EXTENSION_FUNCTION("bookmarkManagerPrivate.undo",
BOOKMARKMANAGERPRIVATE_UNDO)
protected:
virtual ~BookmarkManagerPrivateUndoFunction() {}
virtual bool RunImpl() OVERRIDE;
};
class BookmarkManagerPrivateRedoFunction
: public extensions::BookmarksFunction {
public:
DECLARE_EXTENSION_FUNCTION("bookmarkManagerPrivate.redo",
BOOKMARKMANAGERPRIVATE_REDO)
protected:
virtual ~BookmarkManagerPrivateRedoFunction() {}
virtual bool RunImpl() OVERRIDE;
};
class BookmarkManagerPrivateGetUndoInfoFunction
: public extensions::BookmarksFunction {
public:
DECLARE_EXTENSION_FUNCTION("bookmarkManagerPrivate.getUndoInfo",
BOOKMARKMANAGERPRIVATE_UNDOINFO)
protected:
virtual ~BookmarkManagerPrivateGetUndoInfoFunction() {}
virtual bool RunImpl() OVERRIDE;
};
class BookmarkManagerPrivateGetRedoInfoFunction
: public extensions::BookmarksFunction {
public:
DECLARE_EXTENSION_FUNCTION("bookmarkManagerPrivate.getRedoInfo",
BOOKMARKMANAGERPRIVATE_REDOINFO)
protected:
virtual ~BookmarkManagerPrivateGetRedoInfoFunction() {}
virtual bool RunImpl() OVERRIDE;
};
}
#endif