OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_BOOKMARKS_BOOKMARK_MANAGER_EXTENSION_API_H_ |
6 #define CHROME_BROWSER_BOOKMARKS_BOOKMARK_MANAGER_EXTENSION_API_H_ | 6 #define CHROME_BROWSER_BOOKMARKS_BOOKMARK_MANAGER_EXTENSION_API_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "chrome/browser/bookmarks/bookmark_extension_api.h" | 9 #include "chrome/browser/bookmarks/bookmark_extension_api.h" |
10 #include "chrome/browser/bookmarks/bookmark_node_data.h" | 10 #include "chrome/browser/bookmarks/bookmark_node_data.h" |
11 #include "chrome/browser/extensions/extension_function.h" | 11 #include "chrome/browser/extensions/extension_function.h" |
12 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" | 12 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" |
13 | 13 |
14 struct BookmarkNodeData; | 14 struct BookmarkNodeData; |
15 class Profile; | 15 class Profile; |
16 class TabContentsWrapper; | 16 class TabContentsWrapper; |
17 | 17 |
18 namespace base { | 18 namespace base { |
19 class ListValue; | 19 class ListValue; |
20 } | 20 } |
21 | 21 |
22 // Class that handles the chrome.experimental.bookmarkManager events. | 22 // Class that handles the chrome.experimental.bookmarkManager events. |
23 // TODO(aa): Rename this | 23 class BookmarkManagerExtensionEventRouter |
24 class ExtensionBookmarkManagerEventRouter | |
25 : public BookmarkTabHelper::BookmarkDrag { | 24 : public BookmarkTabHelper::BookmarkDrag { |
26 public: | 25 public: |
27 ExtensionBookmarkManagerEventRouter(Profile* profile, | 26 BookmarkManagerExtensionEventRouter(Profile* profile, |
28 TabContentsWrapper* tab); | 27 TabContentsWrapper* tab); |
29 virtual ~ExtensionBookmarkManagerEventRouter(); | 28 virtual ~BookmarkManagerExtensionEventRouter(); |
30 | 29 |
31 // RenderViewHostDelegate::BookmarkDrag interface | 30 // RenderViewHostDelegate::BookmarkDrag interface |
32 virtual void OnDragEnter(const BookmarkNodeData& data); | 31 virtual void OnDragEnter(const BookmarkNodeData& data); |
33 virtual void OnDragOver(const BookmarkNodeData& data); | 32 virtual void OnDragOver(const BookmarkNodeData& data); |
34 virtual void OnDragLeave(const BookmarkNodeData& data); | 33 virtual void OnDragLeave(const BookmarkNodeData& data); |
35 virtual void OnDrop(const BookmarkNodeData& data); | 34 virtual void OnDrop(const BookmarkNodeData& data); |
36 | 35 |
37 // The bookmark drag and drop data. This gets set after a drop was done on | 36 // 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. | 37 // the page. This returns NULL if no data is available. |
39 const BookmarkNodeData* GetBookmarkNodeData(); | 38 const BookmarkNodeData* GetBookmarkNodeData(); |
40 | 39 |
41 // Clears the drag and drop data. | 40 // Clears the drag and drop data. |
42 void ClearBookmarkNodeData(); | 41 void ClearBookmarkNodeData(); |
43 | 42 |
44 private: | 43 private: |
45 // Helper to actually dispatch an event to extension listeners. | 44 // Helper to actually dispatch an event to extension listeners. |
46 void DispatchEvent(const char* event_name, const base::ListValue* args); | 45 void DispatchEvent(const char* event_name, const base::ListValue* args); |
47 | 46 |
48 void DispatchDragEvent(const BookmarkNodeData& data, const char* event_name); | 47 void DispatchDragEvent(const BookmarkNodeData& data, const char* event_name); |
49 | 48 |
50 Profile* profile_; | 49 Profile* profile_; |
51 TabContentsWrapper* tab_; | 50 TabContentsWrapper* tab_; |
52 BookmarkNodeData bookmark_drag_data_; | 51 BookmarkNodeData bookmark_drag_data_; |
53 | 52 |
54 DISALLOW_COPY_AND_ASSIGN(ExtensionBookmarkManagerEventRouter); | 53 DISALLOW_COPY_AND_ASSIGN(BookmarkManagerExtensionEventRouter); |
55 }; | 54 }; |
56 | 55 |
57 class ClipboardBookmarkManagerFunction : public BookmarksFunction { | 56 class ClipboardBookmarkManagerFunction : public BookmarksFunction { |
58 protected: | 57 protected: |
59 bool CopyOrCut(bool cut); | 58 bool CopyOrCut(bool cut); |
60 }; | 59 }; |
61 | 60 |
62 class CopyBookmarkManagerFunction : public ClipboardBookmarkManagerFunction { | 61 class CopyBookmarkManagerFunction : public ClipboardBookmarkManagerFunction { |
63 public: | 62 public: |
64 virtual bool RunImpl() OVERRIDE; | 63 virtual bool RunImpl() OVERRIDE; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 | 140 |
142 class RecordLaunchBookmarkFunction : public BookmarksFunction { | 141 class RecordLaunchBookmarkFunction : public BookmarksFunction { |
143 public: | 142 public: |
144 virtual bool RunImpl() OVERRIDE; | 143 virtual bool RunImpl() OVERRIDE; |
145 | 144 |
146 private: | 145 private: |
147 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bookmarkManager.recordLaunch") | 146 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bookmarkManager.recordLaunch") |
148 }; | 147 }; |
149 | 148 |
150 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_MANAGER_EXTENSION_API_H_ | 149 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_MANAGER_EXTENSION_API_H_ |
OLD | NEW |