Home | History | Annotate | Download | only in extensions
      1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_BOOKMARK_MANAGER_API_H_
      6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_BOOKMARK_MANAGER_API_H_
      7 #pragma once
      8 
      9 #include "chrome/browser/bookmarks/bookmark_node_data.h"
     10 #include "chrome/browser/extensions/extension_bookmarks_module.h"
     11 #include "chrome/browser/extensions/extension_function.h"
     12 #include "content/browser/renderer_host/render_view_host_delegate.h"
     13 
     14 struct BookmarkNodeData;
     15 class ListValue;
     16 class Profile;
     17 class TabContents;
     18 
     19 // Class that handles the chrome.experimental.bookmarkManager events.
     20 class ExtensionBookmarkManagerEventRouter
     21     : public RenderViewHostDelegate::BookmarkDrag {
     22  public:
     23   ExtensionBookmarkManagerEventRouter(Profile* profile,
     24                                       TabContents* tab_contents);
     25   virtual ~ExtensionBookmarkManagerEventRouter();
     26 
     27   // RenderViewHostDelegate::BookmarkDrag interface
     28   virtual void OnDragEnter(const BookmarkNodeData& data);
     29   virtual void OnDragOver(const BookmarkNodeData& data);
     30   virtual void OnDragLeave(const BookmarkNodeData& data);
     31   virtual void OnDrop(const BookmarkNodeData& data);
     32 
     33   // The bookmark drag and drop data. This gets set after a drop was done on
     34   // the page. This returns NULL if no data is available.
     35   const BookmarkNodeData* GetBookmarkNodeData();
     36 
     37   // Clears the drag and drop data.
     38   void ClearBookmarkNodeData();
     39 
     40  private:
     41   // Helper to actually dispatch an event to extension listeners.
     42   void DispatchEvent(const char* event_name, const ListValue* args);
     43 
     44   void DispatchDragEvent(const BookmarkNodeData& data, const char* event_name);
     45 
     46   Profile* profile_;
     47   TabContents* tab_contents_;
     48   BookmarkNodeData bookmark_drag_data_;
     49 
     50   DISALLOW_COPY_AND_ASSIGN(ExtensionBookmarkManagerEventRouter);
     51 };
     52 
     53 class ClipboardBookmarkManagerFunction : public BookmarksFunction {
     54  protected:
     55   bool CopyOrCut(bool cut);
     56 };
     57 
     58 class CopyBookmarkManagerFunction : public ClipboardBookmarkManagerFunction {
     59  public:
     60   // Override ClipboardBookmarkManagerFunction.
     61   virtual bool RunImpl();
     62 
     63  private:
     64   DECLARE_EXTENSION_FUNCTION_NAME("experimental.bookmarkManager.copy");
     65 };
     66 
     67 class CutBookmarkManagerFunction : public ClipboardBookmarkManagerFunction {
     68  public:
     69   // Override ClipboardBookmarkManagerFunction.
     70   virtual bool RunImpl();
     71 
     72  private:
     73   DECLARE_EXTENSION_FUNCTION_NAME("experimental.bookmarkManager.cut");
     74 };
     75 
     76 class PasteBookmarkManagerFunction : public BookmarksFunction {
     77  public:
     78   // Override BookmarksFunction.
     79   virtual bool RunImpl();
     80 
     81  private:
     82   DECLARE_EXTENSION_FUNCTION_NAME("experimental.bookmarkManager.paste");
     83 };
     84 
     85 class CanPasteBookmarkManagerFunction
     86     : public BookmarksFunction {
     87  public:
     88   // Override BookmarksFunction.
     89   virtual bool RunImpl();
     90 
     91  private:
     92   DECLARE_EXTENSION_FUNCTION_NAME("experimental.bookmarkManager.canPaste");
     93 };
     94 
     95 class SortChildrenBookmarkManagerFunction
     96     : public BookmarksFunction {
     97  public:
     98   // Override BookmarksFunction.
     99   virtual bool RunImpl();
    100 
    101  private:
    102   DECLARE_EXTENSION_FUNCTION_NAME(
    103       "experimental.bookmarkManager.sortChildren");
    104 };
    105 
    106 class BookmarkManagerGetStringsFunction : public AsyncExtensionFunction {
    107  public:
    108   // Override AsyncExtensionFunction.
    109   virtual bool RunImpl();
    110 
    111  private:
    112   DECLARE_EXTENSION_FUNCTION_NAME("experimental.bookmarkManager.getStrings");
    113 };
    114 
    115 class StartDragBookmarkManagerFunction
    116     : public BookmarksFunction {
    117  public:
    118   // Override BookmarksFunction.
    119   virtual bool RunImpl();
    120 
    121  private:
    122   DECLARE_EXTENSION_FUNCTION_NAME("experimental.bookmarkManager.startDrag");
    123 };
    124 
    125 class DropBookmarkManagerFunction : public BookmarksFunction {
    126  public:
    127   virtual bool RunImpl();
    128 
    129  private:
    130   DECLARE_EXTENSION_FUNCTION_NAME("experimental.bookmarkManager.drop");
    131 };
    132 
    133 
    134 class GetSubtreeBookmarkManagerFunction : public BookmarksFunction {
    135  public:
    136   // Override BookmarksFunction
    137   virtual bool RunImpl();
    138 
    139  private:
    140   DECLARE_EXTENSION_FUNCTION_NAME("experimental.bookmarkManager.getSubtree");
    141 };
    142 
    143 #endif  // CHROME_BROWSER_EXTENSIONS_EXTENSION_BOOKMARK_MANAGER_API_H_
    144