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_MOST_VISITED_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_MOST_VISITED_HANDLER_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_MOST_VISITED_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_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 DictionaryValue; | |
19 class GURL; | 18 class GURL; |
20 class ListValue; | 19 class ListValue; |
21 class PageUsageData; | 20 class PageUsageData; |
22 class PrefService; | 21 class PrefService; |
23 class Value; | 22 class Value; |
24 | 23 |
25 // The handler for Javascript messages related to the "most visited" view. | 24 // The handler for Javascript messages related to the "most visited" view. |
| 25 // |
| 26 // This class manages two preferences: |
| 27 // - 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 |
| 29 // string). |
| 30 // - 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 |
| 32 // the URL and the value is a dictionary with title, url and index. This is |
| 33 // owned by the PrefService. |
26 class MostVisitedHandler : public WebUIMessageHandler, | 34 class MostVisitedHandler : public WebUIMessageHandler, |
27 public NotificationObserver { | 35 public NotificationObserver { |
28 public: | 36 public: |
29 | 37 |
30 MostVisitedHandler(); | 38 MostVisitedHandler(); |
31 virtual ~MostVisitedHandler(); | 39 virtual ~MostVisitedHandler(); |
32 | 40 |
33 // WebUIMessageHandler override and implementation. | 41 // WebUIMessageHandler override and implementation. |
34 virtual WebUIMessageHandler* Attach(WebUI* web_ui); | 42 virtual WebUIMessageHandler* Attach(WebUI* web_ui); |
35 virtual void RegisterMessages(); | 43 virtual void RegisterMessages(); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 | 113 |
106 // Our consumer for the history service. | 114 // Our consumer for the history service. |
107 CancelableRequestConsumerTSimple<PageUsageData*> cancelable_consumer_; | 115 CancelableRequestConsumerTSimple<PageUsageData*> cancelable_consumer_; |
108 CancelableRequestConsumer topsites_consumer_; | 116 CancelableRequestConsumer topsites_consumer_; |
109 | 117 |
110 // The most visited URLs, in priority order. | 118 // The most visited URLs, in priority order. |
111 // Only used for matching up clicks on the page to which most visited entry | 119 // Only used for matching up clicks on the page to which most visited entry |
112 // was clicked on for metrics purposes. | 120 // was clicked on for metrics purposes. |
113 std::vector<GURL> most_visited_urls_; | 121 std::vector<GURL> most_visited_urls_; |
114 | 122 |
115 // The URL blacklist: URLs we do not want to show in the thumbnails list. It | |
116 // is a dictionary for quick access (it associates a dummy boolean to the URL | |
117 // string). This is owned by the PrefService. | |
118 DictionaryValue* url_blacklist_; | |
119 | |
120 // This is a dictionary for the pinned URLs for the the most visited part of | |
121 // the new tab page. The key of the dictionary is a hash of the URL and the | |
122 // value is a dictionary with title, url and index. This is owned by the | |
123 // PrefService. | |
124 DictionaryValue* pinned_urls_; | |
125 | |
126 // We pre-fetch the first set of result pages. This variable is false until | 123 // We pre-fetch the first set of result pages. This variable is false until |
127 // we get the first getMostVisited() call. | 124 // we get the first getMostVisited() call. |
128 bool got_first_most_visited_request_; | 125 bool got_first_most_visited_request_; |
129 | 126 |
130 // Keep the results of the db query here. | 127 // Keep the results of the db query here. |
131 scoped_ptr<ListValue> pages_value_; | 128 scoped_ptr<ListValue> pages_value_; |
132 | 129 |
133 DISALLOW_COPY_AND_ASSIGN(MostVisitedHandler); | 130 DISALLOW_COPY_AND_ASSIGN(MostVisitedHandler); |
134 }; | 131 }; |
135 | 132 |
136 #endif // CHROME_BROWSER_UI_WEBUI_MOST_VISITED_HANDLER_H_ | 133 #endif // CHROME_BROWSER_UI_WEBUI_MOST_VISITED_HANDLER_H_ |
OLD | NEW |