| 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_EXTENSIONS_API_BOOKMARK_MANAGER_PRIVATE_BOOKMARK_MANAGER_
PRIVATE_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_BOOKMARK_MANAGER_PRIVATE_BOOKMARK_MANAGER_
PRIVATE_API_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_BOOKMARK_MANAGER_PRIVATE_BOOKMARK_MANAGER_
PRIVATE_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_BOOKMARK_MANAGER_PRIVATE_BOOKMARK_MANAGER_
PRIVATE_API_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "chrome/browser/extensions/api/bookmarks/bookmarks_api.h" | 12 #include "chrome/browser/extensions/api/bookmarks/bookmarks_api.h" |
| 13 #include "chrome/browser/extensions/chrome_extension_function.h" | 13 #include "chrome/browser/extensions/chrome_extension_function.h" |
| 14 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" | 14 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" |
| 15 #include "chrome/browser/undo/bookmark_undo_service_factory.h" | 15 #include "chrome/browser/undo/bookmark_undo_service_factory.h" |
| 16 #include "components/bookmarks/browser/base_bookmark_model_observer.h" | 16 #include "components/bookmarks/browser/base_bookmark_model_observer.h" |
| 17 #include "components/bookmarks/browser/bookmark_node_data.h" | 17 #include "components/bookmarks/browser/bookmark_node_data.h" |
| 18 #include "components/undo/bookmark_undo_service.h" | 18 #include "components/undo/bookmark_undo_service.h" |
| 19 #include "content/public/browser/web_contents_user_data.h" |
| 19 #include "extensions/browser/browser_context_keyed_api_factory.h" | 20 #include "extensions/browser/browser_context_keyed_api_factory.h" |
| 20 #include "extensions/browser/event_router.h" | 21 #include "extensions/browser/event_router.h" |
| 21 | 22 |
| 22 class Profile; | 23 class Profile; |
| 23 | 24 |
| 24 namespace bookmarks { | 25 namespace bookmarks { |
| 25 struct BookmarkNodeData; | 26 struct BookmarkNodeData; |
| 26 } | 27 } |
| 27 | 28 |
| 28 namespace content { | 29 namespace content { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 | 87 |
| 87 content::BrowserContext* browser_context_; | 88 content::BrowserContext* browser_context_; |
| 88 | 89 |
| 89 // Created lazily upon OnListenerAdded. | 90 // Created lazily upon OnListenerAdded. |
| 90 std::unique_ptr<BookmarkManagerPrivateEventRouter> event_router_; | 91 std::unique_ptr<BookmarkManagerPrivateEventRouter> event_router_; |
| 91 }; | 92 }; |
| 92 | 93 |
| 93 // Class that handles the drag and drop related chrome.bookmarkManagerPrivate | 94 // Class that handles the drag and drop related chrome.bookmarkManagerPrivate |
| 94 // events. This class has one instance per bookmark manager tab. | 95 // events. This class has one instance per bookmark manager tab. |
| 95 class BookmarkManagerPrivateDragEventRouter | 96 class BookmarkManagerPrivateDragEventRouter |
| 96 : public BookmarkTabHelper::BookmarkDrag { | 97 : public BookmarkTabHelper::BookmarkDrag, |
| 98 public content::WebContentsUserData< |
| 99 BookmarkManagerPrivateDragEventRouter> { |
| 97 public: | 100 public: |
| 98 BookmarkManagerPrivateDragEventRouter(Profile* profile, | 101 explicit BookmarkManagerPrivateDragEventRouter( |
| 99 content::WebContents* web_contents); | 102 content::WebContents* web_contents); |
| 100 ~BookmarkManagerPrivateDragEventRouter() override; | 103 ~BookmarkManagerPrivateDragEventRouter() override; |
| 101 | 104 |
| 105 static void MaybeCreateForWebContents(content::WebContents* web_contents); |
| 106 |
| 102 // BookmarkTabHelper::BookmarkDrag interface | 107 // BookmarkTabHelper::BookmarkDrag interface |
| 103 void OnDragEnter(const bookmarks::BookmarkNodeData& data) override; | 108 void OnDragEnter(const bookmarks::BookmarkNodeData& data) override; |
| 104 void OnDragOver(const bookmarks::BookmarkNodeData& data) override; | 109 void OnDragOver(const bookmarks::BookmarkNodeData& data) override; |
| 105 void OnDragLeave(const bookmarks::BookmarkNodeData& data) override; | 110 void OnDragLeave(const bookmarks::BookmarkNodeData& data) override; |
| 106 void OnDrop(const bookmarks::BookmarkNodeData& data) override; | 111 void OnDrop(const bookmarks::BookmarkNodeData& data) override; |
| 107 | 112 |
| 108 // The bookmark drag and drop data. This gets set after a drop was done on | 113 // The bookmark drag and drop data. This gets set after a drop was done on |
| 109 // the page. This returns NULL if no data is available. | 114 // the page. This returns NULL if no data is available. |
| 110 const bookmarks::BookmarkNodeData* GetBookmarkNodeData(); | 115 const bookmarks::BookmarkNodeData* GetBookmarkNodeData(); |
| 111 | 116 |
| 112 // Clears the drag and drop data. | 117 // Clears the drag and drop data. |
| 113 void ClearBookmarkNodeData(); | 118 void ClearBookmarkNodeData(); |
| 114 | 119 |
| 115 private: | 120 private: |
| 116 // Helper to actually dispatch an event to extension listeners. | 121 // Helper to actually dispatch an event to extension listeners. |
| 117 void DispatchEvent(events::HistogramValue histogram_value, | 122 void DispatchEvent(events::HistogramValue histogram_value, |
| 118 const std::string& event_name, | 123 const std::string& event_name, |
| 119 std::unique_ptr<base::ListValue> args); | 124 std::unique_ptr<base::ListValue> args); |
| 120 | 125 |
| 126 content::WebContents* web_contents_; |
| 121 Profile* profile_; | 127 Profile* profile_; |
| 122 content::WebContents* web_contents_; | |
| 123 bookmarks::BookmarkNodeData bookmark_drag_data_; | 128 bookmarks::BookmarkNodeData bookmark_drag_data_; |
| 124 | 129 |
| 125 DISALLOW_COPY_AND_ASSIGN(BookmarkManagerPrivateDragEventRouter); | 130 DISALLOW_COPY_AND_ASSIGN(BookmarkManagerPrivateDragEventRouter); |
| 126 }; | 131 }; |
| 127 | 132 |
| 128 class ClipboardBookmarkManagerFunction : public extensions::BookmarksFunction { | 133 class ClipboardBookmarkManagerFunction : public extensions::BookmarksFunction { |
| 129 protected: | 134 protected: |
| 130 ~ClipboardBookmarkManagerFunction() override {} | 135 ~ClipboardBookmarkManagerFunction() override {} |
| 131 | 136 |
| 132 bool CopyOrCut(bool cut, const std::vector<std::string>& id_list); | 137 bool CopyOrCut(bool cut, const std::vector<std::string>& id_list); |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 protected: | 406 protected: |
| 402 ~BookmarkManagerPrivateGetRedoInfoFunction() override {} | 407 ~BookmarkManagerPrivateGetRedoInfoFunction() override {} |
| 403 | 408 |
| 404 // ExtensionFunction: | 409 // ExtensionFunction: |
| 405 bool RunOnReady() override; | 410 bool RunOnReady() override; |
| 406 }; | 411 }; |
| 407 | 412 |
| 408 } // namespace extensions | 413 } // namespace extensions |
| 409 | 414 |
| 410 #endif // CHROME_BROWSER_EXTENSIONS_API_BOOKMARK_MANAGER_PRIVATE_BOOKMARK_MANAG
ER_PRIVATE_API_H_ | 415 #endif // CHROME_BROWSER_EXTENSIONS_API_BOOKMARK_MANAGER_PRIVATE_BOOKMARK_MANAG
ER_PRIVATE_API_H_ |
| OLD | NEW |