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_UI_WEBUI_NTP_BOOKMARKS_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_NTP_BOOKMARKS_HANDLER_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_NTP_BOOKMARKS_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_NTP_BOOKMARKS_HANDLER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
| 9 #include "chrome/browser/bookmarks/bookmark_model_observer.h" |
9 #include "content/browser/webui/web_ui.h" | 10 #include "content/browser/webui/web_ui.h" |
10 #include "content/common/notification_observer.h" | 11 #include "content/common/notification_observer.h" |
11 #include "content/common/notification_registrar.h" | 12 #include "content/common/notification_registrar.h" |
12 | 13 |
13 class PrefService; | 14 class PrefService; |
14 class Profile; | 15 class Profile; |
15 | 16 |
16 // The handler for Javascript messages related to the "bookmarks" view. | 17 // The handler for Javascript messages related to the "bookmarks" view. |
17 class BookmarksHandler : public WebUIMessageHandler, | 18 class BookmarksHandler : public WebUIMessageHandler, |
18 public NotificationObserver { | 19 public NotificationObserver, |
| 20 public BookmarkModelObserver { |
19 public: | 21 public: |
20 explicit BookmarksHandler(); | 22 explicit BookmarksHandler(); |
21 virtual ~BookmarksHandler(); | 23 virtual ~BookmarksHandler(); |
22 | 24 |
23 // WebUIMessageHandler implementation. | 25 // WebUIMessageHandler implementation. |
| 26 virtual WebUIMessageHandler* Attach(WebUI* web_ui) OVERRIDE; |
24 virtual void RegisterMessages() OVERRIDE; | 27 virtual void RegisterMessages() OVERRIDE; |
25 | 28 |
26 // NotificationObserver | 29 // NotificationObserver implementation. |
27 virtual void Observe(int type, | 30 virtual void Observe(int type, |
28 const NotificationSource& source, | 31 const NotificationSource& source, |
29 const NotificationDetails& details) OVERRIDE; | 32 const NotificationDetails& details) OVERRIDE; |
30 | 33 |
| 34 // BookmarkModelObserver implementation. |
| 35 virtual void Loaded(BookmarkModel* model, bool ids_reassigned) OVERRIDE; |
| 36 virtual void BookmarkModelBeingDeleted(BookmarkModel* model) OVERRIDE; |
| 37 virtual void BookmarkNodeMoved(BookmarkModel* model, |
| 38 const BookmarkNode* old_parent, |
| 39 int old_index, |
| 40 const BookmarkNode* new_parent, |
| 41 int new_index) OVERRIDE; |
| 42 virtual void BookmarkNodeAdded(BookmarkModel* model, |
| 43 const BookmarkNode* parent, |
| 44 int index) OVERRIDE; |
| 45 virtual void BookmarkNodeRemoved(BookmarkModel* model, |
| 46 const BookmarkNode* parent, |
| 47 int old_index, |
| 48 const BookmarkNode* node) OVERRIDE; |
| 49 virtual void BookmarkNodeChanged(BookmarkModel* model, |
| 50 const BookmarkNode* node) OVERRIDE; |
| 51 virtual void BookmarkNodeFaviconChanged(BookmarkModel* model, |
| 52 const BookmarkNode* node) OVERRIDE; |
| 53 virtual void BookmarkNodeChildrenReordered(BookmarkModel* model, |
| 54 const BookmarkNode* node) OVERRIDE; |
| 55 virtual void BookmarkImportBeginning(BookmarkModel* model) OVERRIDE; |
| 56 virtual void BookmarkImportEnding(BookmarkModel* model) OVERRIDE; |
| 57 |
31 // Callback for the "getBookmarksData" message. | 58 // Callback for the "getBookmarksData" message. |
32 void HandleGetBookmarksData(const base::ListValue* args); | 59 void HandleGetBookmarksData(const base::ListValue* args); |
33 | 60 |
34 // Register NTP preferences. | 61 // Register NTP preferences. |
35 static void RegisterUserPrefs(PrefService* prefs); | 62 static void RegisterUserPrefs(PrefService* prefs); |
36 | 63 |
37 private: | 64 private: |
| 65 BookmarkModel* model_; // weak |
38 NotificationRegistrar registrar_; | 66 NotificationRegistrar registrar_; |
39 | 67 |
40 DISALLOW_COPY_AND_ASSIGN(BookmarksHandler); | 68 DISALLOW_COPY_AND_ASSIGN(BookmarksHandler); |
41 }; | 69 }; |
42 | 70 |
43 #endif // CHROME_BROWSER_UI_WEBUI_NTP_BOOKMARKS_HANDLER_H_ | 71 #endif // CHROME_BROWSER_UI_WEBUI_NTP_BOOKMARKS_HANDLER_H_ |
OLD | NEW |