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