| 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_MOST_VISITED_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_NTP_MOST_VISITED_HANDLER_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_NTP_MOST_VISITED_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_NTP_MOST_VISITED_HANDLER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "chrome/browser/history/history_types.h" | 12 #include "chrome/browser/history/history_types.h" |
| 13 #include "content/browser/cancelable_request.h" | 13 #include "content/browser/cancelable_request.h" |
| 14 #include "content/browser/webui/web_ui.h" | 14 #include "content/browser/webui/web_ui.h" |
| 15 #include "content/common/notification_observer.h" | 15 #include "content/common/notification_observer.h" |
| 16 #include "content/common/notification_registrar.h" | 16 #include "content/common/notification_registrar.h" |
| 17 | 17 |
| 18 class GURL; | 18 class GURL; |
| 19 class ListValue; | |
| 20 class PageUsageData; | 19 class PageUsageData; |
| 21 class PrefService; | 20 class PrefService; |
| 21 |
| 22 namespace base { |
| 23 class ListValue; |
| 22 class Value; | 24 class Value; |
| 25 } |
| 23 | 26 |
| 24 // The handler for Javascript messages related to the "most visited" view. | 27 // The handler for Javascript messages related to the "most visited" view. |
| 25 // | 28 // |
| 26 // This class manages two preferences: | 29 // This class manages two preferences: |
| 27 // - The URL blacklist: URLs we do not want to show in the thumbnails list. It | 30 // - The URL blacklist: URLs we do not want to show in the thumbnails list. It |
| 28 // is a dictionary for quick access (it associates a dummy boolean to the URL | 31 // is a dictionary for quick access (it associates a dummy boolean to the URL |
| 29 // string). | 32 // string). |
| 30 // - Pinned URLs: This is a dictionary for the pinned URLs for the the most | 33 // - Pinned URLs: This is a dictionary for the pinned URLs for the the most |
| 31 // visited part of the new tab page. The key of the dictionary is a hash of | 34 // visited part of the new tab page. The key of the dictionary is a hash of |
| 32 // the URL and the value is a dictionary with title, url and index. This is | 35 // the URL and the value is a dictionary with title, url and index. This is |
| 33 // owned by the PrefService. | 36 // owned by the PrefService. |
| 34 class MostVisitedHandler : public WebUIMessageHandler, | 37 class MostVisitedHandler : public WebUIMessageHandler, |
| 35 public NotificationObserver { | 38 public NotificationObserver { |
| 36 public: | 39 public: |
| 37 | 40 |
| 38 MostVisitedHandler(); | 41 MostVisitedHandler(); |
| 39 virtual ~MostVisitedHandler(); | 42 virtual ~MostVisitedHandler(); |
| 40 | 43 |
| 41 // WebUIMessageHandler override and implementation. | 44 // WebUIMessageHandler override and implementation. |
| 42 virtual WebUIMessageHandler* Attach(WebUI* web_ui); | 45 virtual WebUIMessageHandler* Attach(WebUI* web_ui); |
| 43 virtual void RegisterMessages(); | 46 virtual void RegisterMessages(); |
| 44 | 47 |
| 45 // Callback for the "getMostVisited" message. | 48 // Callback for the "getMostVisited" message. |
| 46 void HandleGetMostVisited(const ListValue* args); | 49 void HandleGetMostVisited(const base::ListValue* args); |
| 47 | 50 |
| 48 // Callback for the "blacklistURLFromMostVisited" message. | 51 // Callback for the "blacklistURLFromMostVisited" message. |
| 49 void HandleBlacklistURL(const ListValue* args); | 52 void HandleBlacklistURL(const base::ListValue* args); |
| 50 | 53 |
| 51 // Callback for the "removeURLsFromMostVisitedBlacklist" message. | 54 // Callback for the "removeURLsFromMostVisitedBlacklist" message. |
| 52 void HandleRemoveURLsFromBlacklist(const ListValue* args); | 55 void HandleRemoveURLsFromBlacklist(const base::ListValue* args); |
| 53 | 56 |
| 54 // Callback for the "clearMostVisitedURLsBlacklist" message. | 57 // Callback for the "clearMostVisitedURLsBlacklist" message. |
| 55 void HandleClearBlacklist(const ListValue* args); | 58 void HandleClearBlacklist(const base::ListValue* args); |
| 56 | 59 |
| 57 // Callback for the "addPinnedURL" message. | 60 // Callback for the "addPinnedURL" message. |
| 58 void HandleAddPinnedURL(const ListValue* args); | 61 void HandleAddPinnedURL(const base::ListValue* args); |
| 59 | 62 |
| 60 // Callback for the "removePinnedURL" message. | 63 // Callback for the "removePinnedURL" message. |
| 61 void HandleRemovePinnedURL(const ListValue* args); | 64 void HandleRemovePinnedURL(const base::ListValue* args); |
| 62 | 65 |
| 63 // NotificationObserver implementation. | 66 // NotificationObserver implementation. |
| 64 virtual void Observe(int type, | 67 virtual void Observe(int type, |
| 65 const NotificationSource& source, | 68 const NotificationSource& source, |
| 66 const NotificationDetails& details); | 69 const NotificationDetails& details); |
| 67 | 70 |
| 68 const std::vector<GURL>& most_visited_urls() const { | 71 const std::vector<GURL>& most_visited_urls() const { |
| 69 return most_visited_urls_; | 72 return most_visited_urls_; |
| 70 } | 73 } |
| 71 | 74 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 // The most visited URLs, in priority order. | 121 // The most visited URLs, in priority order. |
| 119 // Only used for matching up clicks on the page to which most visited entry | 122 // Only used for matching up clicks on the page to which most visited entry |
| 120 // was clicked on for metrics purposes. | 123 // was clicked on for metrics purposes. |
| 121 std::vector<GURL> most_visited_urls_; | 124 std::vector<GURL> most_visited_urls_; |
| 122 | 125 |
| 123 // We pre-fetch the first set of result pages. This variable is false until | 126 // We pre-fetch the first set of result pages. This variable is false until |
| 124 // we get the first getMostVisited() call. | 127 // we get the first getMostVisited() call. |
| 125 bool got_first_most_visited_request_; | 128 bool got_first_most_visited_request_; |
| 126 | 129 |
| 127 // Keep the results of the db query here. | 130 // Keep the results of the db query here. |
| 128 scoped_ptr<ListValue> pages_value_; | 131 scoped_ptr<base::ListValue> pages_value_; |
| 129 | 132 |
| 130 DISALLOW_COPY_AND_ASSIGN(MostVisitedHandler); | 133 DISALLOW_COPY_AND_ASSIGN(MostVisitedHandler); |
| 131 }; | 134 }; |
| 132 | 135 |
| 133 #endif // CHROME_BROWSER_UI_WEBUI_NTP_MOST_VISITED_HANDLER_H_ | 136 #endif // CHROME_BROWSER_UI_WEBUI_NTP_MOST_VISITED_HANDLER_H_ |
| OLD | NEW |