| 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> |
| 9 |
| 8 #include "base/macros.h" | 10 #include "base/macros.h" |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "base/values.h" | 11 #include "base/values.h" |
| 11 #include "chrome/browser/extensions/api/bookmarks/bookmarks_api.h" | 12 #include "chrome/browser/extensions/api/bookmarks/bookmarks_api.h" |
| 12 #include "chrome/browser/extensions/chrome_extension_function.h" | 13 #include "chrome/browser/extensions/chrome_extension_function.h" |
| 13 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" | 14 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" |
| 14 #include "chrome/browser/undo/bookmark_undo_service_factory.h" | 15 #include "chrome/browser/undo/bookmark_undo_service_factory.h" |
| 15 #include "components/bookmarks/browser/base_bookmark_model_observer.h" | 16 #include "components/bookmarks/browser/base_bookmark_model_observer.h" |
| 16 #include "components/bookmarks/browser/bookmark_node_data.h" | 17 #include "components/bookmarks/browser/bookmark_node_data.h" |
| 17 #include "components/undo/bookmark_undo_service.h" | 18 #include "components/undo/bookmark_undo_service.h" |
| 18 #include "extensions/browser/browser_context_keyed_api_factory.h" | 19 #include "extensions/browser/browser_context_keyed_api_factory.h" |
| 19 #include "extensions/browser/event_router.h" | 20 #include "extensions/browser/event_router.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 44 void OnWillChangeBookmarkMetaInfo( | 45 void OnWillChangeBookmarkMetaInfo( |
| 45 bookmarks::BookmarkModel* model, | 46 bookmarks::BookmarkModel* model, |
| 46 const bookmarks::BookmarkNode* node) override; | 47 const bookmarks::BookmarkNode* node) override; |
| 47 void BookmarkMetaInfoChanged(bookmarks::BookmarkModel* model, | 48 void BookmarkMetaInfoChanged(bookmarks::BookmarkModel* model, |
| 48 const bookmarks::BookmarkNode* node) override; | 49 const bookmarks::BookmarkNode* node) override; |
| 49 | 50 |
| 50 private: | 51 private: |
| 51 // Helper to actually dispatch an event to extension listeners. | 52 // Helper to actually dispatch an event to extension listeners. |
| 52 void DispatchEvent(events::HistogramValue histogram_value, | 53 void DispatchEvent(events::HistogramValue histogram_value, |
| 53 const std::string& event_name, | 54 const std::string& event_name, |
| 54 scoped_ptr<base::ListValue> event_args); | 55 std::unique_ptr<base::ListValue> event_args); |
| 55 | 56 |
| 56 // Remembers the previous meta info of a node before it was changed. | 57 // Remembers the previous meta info of a node before it was changed. |
| 57 bookmarks::BookmarkNode::MetaInfoMap prev_meta_info_; | 58 bookmarks::BookmarkNode::MetaInfoMap prev_meta_info_; |
| 58 | 59 |
| 59 content::BrowserContext* browser_context_; | 60 content::BrowserContext* browser_context_; |
| 60 bookmarks::BookmarkModel* bookmark_model_; | 61 bookmarks::BookmarkModel* bookmark_model_; |
| 61 }; | 62 }; |
| 62 | 63 |
| 63 class BookmarkManagerPrivateAPI : public BrowserContextKeyedAPI, | 64 class BookmarkManagerPrivateAPI : public BrowserContextKeyedAPI, |
| 64 public EventRouter::Observer { | 65 public EventRouter::Observer { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 79 private: | 80 private: |
| 80 friend class BrowserContextKeyedAPIFactory<BookmarkManagerPrivateAPI>; | 81 friend class BrowserContextKeyedAPIFactory<BookmarkManagerPrivateAPI>; |
| 81 | 82 |
| 82 // BrowserContextKeyedAPI implementation. | 83 // BrowserContextKeyedAPI implementation. |
| 83 static const char* service_name() { return "BookmarkManagerPrivateAPI"; } | 84 static const char* service_name() { return "BookmarkManagerPrivateAPI"; } |
| 84 static const bool kServiceIsNULLWhileTesting = true; | 85 static const bool kServiceIsNULLWhileTesting = true; |
| 85 | 86 |
| 86 content::BrowserContext* browser_context_; | 87 content::BrowserContext* browser_context_; |
| 87 | 88 |
| 88 // Created lazily upon OnListenerAdded. | 89 // Created lazily upon OnListenerAdded. |
| 89 scoped_ptr<BookmarkManagerPrivateEventRouter> event_router_; | 90 std::unique_ptr<BookmarkManagerPrivateEventRouter> event_router_; |
| 90 }; | 91 }; |
| 91 | 92 |
| 92 // Class that handles the drag and drop related chrome.bookmarkManagerPrivate | 93 // Class that handles the drag and drop related chrome.bookmarkManagerPrivate |
| 93 // events. This class has one instance per bookmark manager tab. | 94 // events. This class has one instance per bookmark manager tab. |
| 94 class BookmarkManagerPrivateDragEventRouter | 95 class BookmarkManagerPrivateDragEventRouter |
| 95 : public BookmarkTabHelper::BookmarkDrag { | 96 : public BookmarkTabHelper::BookmarkDrag { |
| 96 public: | 97 public: |
| 97 BookmarkManagerPrivateDragEventRouter(Profile* profile, | 98 BookmarkManagerPrivateDragEventRouter(Profile* profile, |
| 98 content::WebContents* web_contents); | 99 content::WebContents* web_contents); |
| 99 ~BookmarkManagerPrivateDragEventRouter() override; | 100 ~BookmarkManagerPrivateDragEventRouter() override; |
| 100 | 101 |
| 101 // BookmarkTabHelper::BookmarkDrag interface | 102 // BookmarkTabHelper::BookmarkDrag interface |
| 102 void OnDragEnter(const bookmarks::BookmarkNodeData& data) override; | 103 void OnDragEnter(const bookmarks::BookmarkNodeData& data) override; |
| 103 void OnDragOver(const bookmarks::BookmarkNodeData& data) override; | 104 void OnDragOver(const bookmarks::BookmarkNodeData& data) override; |
| 104 void OnDragLeave(const bookmarks::BookmarkNodeData& data) override; | 105 void OnDragLeave(const bookmarks::BookmarkNodeData& data) override; |
| 105 void OnDrop(const bookmarks::BookmarkNodeData& data) override; | 106 void OnDrop(const bookmarks::BookmarkNodeData& data) override; |
| 106 | 107 |
| 107 // The bookmark drag and drop data. This gets set after a drop was done on | 108 // The bookmark drag and drop data. This gets set after a drop was done on |
| 108 // the page. This returns NULL if no data is available. | 109 // the page. This returns NULL if no data is available. |
| 109 const bookmarks::BookmarkNodeData* GetBookmarkNodeData(); | 110 const bookmarks::BookmarkNodeData* GetBookmarkNodeData(); |
| 110 | 111 |
| 111 // Clears the drag and drop data. | 112 // Clears the drag and drop data. |
| 112 void ClearBookmarkNodeData(); | 113 void ClearBookmarkNodeData(); |
| 113 | 114 |
| 114 private: | 115 private: |
| 115 // Helper to actually dispatch an event to extension listeners. | 116 // Helper to actually dispatch an event to extension listeners. |
| 116 void DispatchEvent(events::HistogramValue histogram_value, | 117 void DispatchEvent(events::HistogramValue histogram_value, |
| 117 const std::string& event_name, | 118 const std::string& event_name, |
| 118 scoped_ptr<base::ListValue> args); | 119 std::unique_ptr<base::ListValue> args); |
| 119 | 120 |
| 120 Profile* profile_; | 121 Profile* profile_; |
| 121 content::WebContents* web_contents_; | 122 content::WebContents* web_contents_; |
| 122 bookmarks::BookmarkNodeData bookmark_drag_data_; | 123 bookmarks::BookmarkNodeData bookmark_drag_data_; |
| 123 | 124 |
| 124 DISALLOW_COPY_AND_ASSIGN(BookmarkManagerPrivateDragEventRouter); | 125 DISALLOW_COPY_AND_ASSIGN(BookmarkManagerPrivateDragEventRouter); |
| 125 }; | 126 }; |
| 126 | 127 |
| 127 class ClipboardBookmarkManagerFunction : public extensions::BookmarksFunction { | 128 class ClipboardBookmarkManagerFunction : public extensions::BookmarksFunction { |
| 128 protected: | 129 protected: |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 protected: | 400 protected: |
| 400 ~BookmarkManagerPrivateGetRedoInfoFunction() override {} | 401 ~BookmarkManagerPrivateGetRedoInfoFunction() override {} |
| 401 | 402 |
| 402 // ExtensionFunction: | 403 // ExtensionFunction: |
| 403 bool RunOnReady() override; | 404 bool RunOnReady() override; |
| 404 }; | 405 }; |
| 405 | 406 |
| 406 } // namespace extensions | 407 } // namespace extensions |
| 407 | 408 |
| 408 #endif // CHROME_BROWSER_EXTENSIONS_API_BOOKMARK_MANAGER_PRIVATE_BOOKMARK_MANAG
ER_PRIVATE_API_H_ | 409 #endif // CHROME_BROWSER_EXTENSIONS_API_BOOKMARK_MANAGER_PRIVATE_BOOKMARK_MANAG
ER_PRIVATE_API_H_ |
| OLD | NEW |