| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_BOOKMARKS_BOOKMARK_MANAGER_EXTENSION_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_BOOKMARK_MANAGER_PRIVATE_BOOKMARK_MANAGER_
PRIVATE_API_H_ |
| 6 #define CHROME_BROWSER_BOOKMARKS_BOOKMARK_MANAGER_EXTENSION_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_BOOKMARK_MANAGER_PRIVATE_BOOKMARK_MANAGER_
PRIVATE_API_H_ |
| 7 | 7 |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chrome/browser/bookmarks/bookmark_node_data.h" | 9 #include "chrome/browser/bookmarks/bookmark_node_data.h" |
| 10 // TODO (rdevlin.cronin): Move BookmarkManagerAPI to | |
| 11 // chrome/browser/extensions/api/bookmark so these two aren't interdependent. | |
| 12 #include "chrome/browser/extensions/api/bookmarks/bookmark_api.h" | 10 #include "chrome/browser/extensions/api/bookmarks/bookmark_api.h" |
| 13 #include "chrome/browser/extensions/extension_function.h" | 11 #include "chrome/browser/extensions/extension_function.h" |
| 14 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" | 12 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" |
| 15 | 13 |
| 16 struct BookmarkNodeData; | 14 struct BookmarkNodeData; |
| 17 class Profile; | 15 class Profile; |
| 18 | 16 |
| 19 namespace content { | 17 namespace content { |
| 20 class WebContents; | 18 class WebContents; |
| 21 } | 19 } |
| 22 | 20 |
| 21 namespace extensions { |
| 22 |
| 23 // Class that handles the chrome.bookmarkManagerPrivate events. | 23 // Class that handles the chrome.bookmarkManagerPrivate events. |
| 24 class BookmarkManagerExtensionEventRouter | 24 class BookmarkManagerPrivateEventRouter |
| 25 : public BookmarkTabHelper::BookmarkDrag { | 25 : public BookmarkTabHelper::BookmarkDrag { |
| 26 public: | 26 public: |
| 27 BookmarkManagerExtensionEventRouter(Profile* profile, | 27 BookmarkManagerPrivateEventRouter(Profile* profile, |
| 28 content::WebContents* web_contents); | 28 content::WebContents* web_contents); |
| 29 virtual ~BookmarkManagerExtensionEventRouter(); | 29 virtual ~BookmarkManagerPrivateEventRouter(); |
| 30 | 30 |
| 31 // BookmarkTabHelper::BookmarkDrag interface | 31 // BookmarkTabHelper::BookmarkDrag interface |
| 32 virtual void OnDragEnter(const BookmarkNodeData& data) OVERRIDE; | 32 virtual void OnDragEnter(const BookmarkNodeData& data) OVERRIDE; |
| 33 virtual void OnDragOver(const BookmarkNodeData& data) OVERRIDE; | 33 virtual void OnDragOver(const BookmarkNodeData& data) OVERRIDE; |
| 34 virtual void OnDragLeave(const BookmarkNodeData& data) OVERRIDE; | 34 virtual void OnDragLeave(const BookmarkNodeData& data) OVERRIDE; |
| 35 virtual void OnDrop(const BookmarkNodeData& data) OVERRIDE; | 35 virtual void OnDrop(const BookmarkNodeData& data) OVERRIDE; |
| 36 | 36 |
| 37 // The bookmark drag and drop data. This gets set after a drop was done on | 37 // The bookmark drag and drop data. This gets set after a drop was done on |
| 38 // the page. This returns NULL if no data is available. | 38 // the page. This returns NULL if no data is available. |
| 39 const BookmarkNodeData* GetBookmarkNodeData(); | 39 const BookmarkNodeData* GetBookmarkNodeData(); |
| 40 | 40 |
| 41 // Clears the drag and drop data. | 41 // Clears the drag and drop data. |
| 42 void ClearBookmarkNodeData(); | 42 void ClearBookmarkNodeData(); |
| 43 | 43 |
| 44 private: | 44 private: |
| 45 // Helper to actually dispatch an event to extension listeners. | 45 // Helper to actually dispatch an event to extension listeners. |
| 46 void DispatchEvent(const char* event_name, | 46 void DispatchEvent(const char* event_name, |
| 47 scoped_ptr<base::ListValue> args); | 47 scoped_ptr<base::ListValue> args); |
| 48 | 48 |
| 49 void DispatchDragEvent(const BookmarkNodeData& data, const char* event_name); | 49 void DispatchDragEvent(const BookmarkNodeData& data, const char* event_name); |
| 50 | 50 |
| 51 Profile* profile_; | 51 Profile* profile_; |
| 52 content::WebContents* web_contents_; | 52 content::WebContents* web_contents_; |
| 53 BookmarkNodeData bookmark_drag_data_; | 53 BookmarkNodeData bookmark_drag_data_; |
| 54 | 54 |
| 55 DISALLOW_COPY_AND_ASSIGN(BookmarkManagerExtensionEventRouter); | 55 DISALLOW_COPY_AND_ASSIGN(BookmarkManagerPrivateEventRouter); |
| 56 }; | 56 }; |
| 57 | 57 |
| 58 class ClipboardBookmarkManagerFunction : public extensions::BookmarksFunction { | 58 class ClipboardBookmarkManagerFunction : public extensions::BookmarksFunction { |
| 59 protected: | 59 protected: |
| 60 virtual ~ClipboardBookmarkManagerFunction() {} | 60 virtual ~ClipboardBookmarkManagerFunction() {} |
| 61 | 61 |
| 62 bool CopyOrCut(bool cut); | 62 bool CopyOrCut(bool cut); |
| 63 }; | 63 }; |
| 64 | 64 |
| 65 class CopyBookmarkManagerFunction : public ClipboardBookmarkManagerFunction { | 65 class CopyBookmarkManagerFunction : public ClipboardBookmarkManagerFunction { |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 public: | 188 public: |
| 189 DECLARE_EXTENSION_FUNCTION_NAME("bookmarkManagerPrivate.canOpenNewWindows"); | 189 DECLARE_EXTENSION_FUNCTION_NAME("bookmarkManagerPrivate.canOpenNewWindows"); |
| 190 | 190 |
| 191 protected: | 191 protected: |
| 192 virtual ~CanOpenNewWindowsBookmarkFunction() {} | 192 virtual ~CanOpenNewWindowsBookmarkFunction() {} |
| 193 | 193 |
| 194 // ExtensionFunction: | 194 // ExtensionFunction: |
| 195 virtual bool RunImpl() OVERRIDE; | 195 virtual bool RunImpl() OVERRIDE; |
| 196 }; | 196 }; |
| 197 | 197 |
| 198 } // namespace extensions |
| 198 | 199 |
| 199 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_MANAGER_EXTENSION_API_H_ | 200 #endif // CHROME_BROWSER_EXTENSIONS_API_BOOKMARK_MANAGER_PRIVATE_BOOKMARK_MANAG
ER_PRIVATE_API_H_ |
| OLD | NEW |