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_EXTENSIONS_EXTENSION_BOOKMARKS_MODULE_H_ | 5 #ifndef CHROME_BROWSER_BOOKMARKS_BOOKMARK_EXTENSION_API_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_BOOKMARKS_MODULE_H_ | 6 #define CHROME_BROWSER_BOOKMARKS_BOOKMARK_EXTENSION_API_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <list> | 9 #include <list> |
10 #include <set> | 10 #include <set> |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "chrome/browser/bookmarks/bookmark_model_observer.h" | 15 #include "chrome/browser/bookmarks/bookmark_model_observer.h" |
16 #include "chrome/browser/extensions/extension_function.h" | 16 #include "chrome/browser/extensions/extension_function.h" |
17 #include "chrome/browser/ui/shell_dialogs.h" | 17 #include "chrome/browser/ui/shell_dialogs.h" |
18 #include "content/public/browser/notification_observer.h" | 18 #include "content/public/browser/notification_observer.h" |
19 #include "content/public/browser/notification_registrar.h" | 19 #include "content/public/browser/notification_registrar.h" |
20 | 20 |
21 class FilePath; | 21 class FilePath; |
22 | 22 |
23 namespace base { | 23 namespace base { |
24 class ListValue; | 24 class ListValue; |
25 } | 25 } |
26 | 26 |
27 // Observes BookmarkModel and then routes the notifications as events to | 27 // Observes BookmarkModel and then routes the notifications as events to |
28 // the extension system. | 28 // the extension system. |
29 class ExtensionBookmarkEventRouter : public BookmarkModelObserver { | 29 class BookmarkExtensionEventRouter : public BookmarkModelObserver { |
30 public: | 30 public: |
31 explicit ExtensionBookmarkEventRouter(BookmarkModel* model); | 31 explicit BookmarkExtensionEventRouter(BookmarkModel* model); |
32 virtual ~ExtensionBookmarkEventRouter(); | 32 virtual ~BookmarkExtensionEventRouter(); |
33 | 33 |
34 void Init(); | 34 void Init(); |
35 | 35 |
36 // BookmarkModelObserver: | 36 // BookmarkModelObserver: |
37 virtual void Loaded(BookmarkModel* model, bool ids_reassigned) OVERRIDE; | 37 virtual void Loaded(BookmarkModel* model, bool ids_reassigned) OVERRIDE; |
38 virtual void BookmarkModelBeingDeleted(BookmarkModel* model) OVERRIDE; | 38 virtual void BookmarkModelBeingDeleted(BookmarkModel* model) OVERRIDE; |
39 virtual void BookmarkNodeMoved(BookmarkModel* model, | 39 virtual void BookmarkNodeMoved(BookmarkModel* model, |
40 const BookmarkNode* old_parent, | 40 const BookmarkNode* old_parent, |
41 int old_index, | 41 int old_index, |
42 const BookmarkNode* new_parent, | 42 const BookmarkNode* new_parent, |
(...skipping 15 matching lines...) Expand all Loading... |
58 virtual void BookmarkImportEnding(BookmarkModel* model) OVERRIDE; | 58 virtual void BookmarkImportEnding(BookmarkModel* model) OVERRIDE; |
59 | 59 |
60 private: | 60 private: |
61 // Helper to actually dispatch an event to extension listeners. | 61 // Helper to actually dispatch an event to extension listeners. |
62 void DispatchEvent(Profile* profile, | 62 void DispatchEvent(Profile* profile, |
63 const char* event_name, | 63 const char* event_name, |
64 const std::string& json_args); | 64 const std::string& json_args); |
65 | 65 |
66 BookmarkModel* model_; | 66 BookmarkModel* model_; |
67 | 67 |
68 DISALLOW_COPY_AND_ASSIGN(ExtensionBookmarkEventRouter); | 68 DISALLOW_COPY_AND_ASSIGN(BookmarkExtensionEventRouter); |
69 }; | 69 }; |
70 | 70 |
71 class BookmarksFunction : public AsyncExtensionFunction, | 71 class BookmarksFunction : public AsyncExtensionFunction, |
72 public content::NotificationObserver { | 72 public content::NotificationObserver { |
73 public: | 73 public: |
74 // AsyncExtensionFunction: | 74 // AsyncExtensionFunction: |
75 virtual void Run() OVERRIDE; | 75 virtual void Run() OVERRIDE; |
76 | 76 |
77 virtual bool RunImpl() = 0; | 77 virtual bool RunImpl() = 0; |
78 | 78 |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 public: | 234 public: |
235 // BookmarkManagerIOFunction: | 235 // BookmarkManagerIOFunction: |
236 virtual bool RunImpl() OVERRIDE; | 236 virtual bool RunImpl() OVERRIDE; |
237 virtual void FileSelected(const FilePath& path, int index, void* params) | 237 virtual void FileSelected(const FilePath& path, int index, void* params) |
238 OVERRIDE; | 238 OVERRIDE; |
239 | 239 |
240 private: | 240 private: |
241 DECLARE_EXTENSION_FUNCTION_NAME("bookmarks.export"); | 241 DECLARE_EXTENSION_FUNCTION_NAME("bookmarks.export"); |
242 }; | 242 }; |
243 | 243 |
244 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_BOOKMARKS_MODULE_H_ | 244 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_EXTENSION_API_H_ |
OLD | NEW |