Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(387)

Side by Side Diff: chrome/browser/ui/webui/ntp/suggested_page_handler.h

Issue 9358031: Added new adaptive "Suggest" tab on the New Tab Page, behing the flag, for the experiments. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove extra line Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
Dan Beam 2012/02/09 01:43:06 2012
GeorgeY 2012/02/10 00:00:36 Done.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_UI_WEBUI_NTP_SUGGESTED_PAGE_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_NTP_SUGGESTED_PAGE_HANDLER_H_
7 #pragma once
8
9 #include <string>
10 #include <vector>
11
12 #include "chrome/browser/cancelable_request.h"
13 #include "chrome/browser/history/history_types.h"
14 #include "content/public/browser/notification_observer.h"
15 #include "content/public/browser/notification_registrar.h"
16 #include "content/public/browser/web_ui_message_handler.h"
17
18 class GURL;
19 class PageUsageData;
20 class PrefService;
21
22 namespace base {
23 class ListValue;
24 class Value;
25 }
26
27 // The handler for Javascript messages related to the "most visited" view.
28 //
29 // This class manages one preference:
30 // - The URL blacklist: URLs we do not want to show in the thumbnails list. It
31 // is a dictionary for quick access (it associates a dummy boolean to the URL
32 // string).
33 class SuggestedHandler : public content::WebUIMessageHandler,
34 public content::NotificationObserver {
35 public:
36
37 SuggestedHandler();
38 virtual ~SuggestedHandler();
39
40 // WebUIMessageHandler override and implementation.
41 virtual void RegisterMessages() OVERRIDE;
42
43 // Callback for the "getSuggested" message.
44 void HandleGetSuggested(const base::ListValue* args);
45
46 // Callback for the "blacklistURLFromSuggested" message.
47 void HandleBlacklistURL(const base::ListValue* args);
48
49 // Callback for the "removeURLsFromSuggestedBlacklist" message.
50 void HandleRemoveURLsFromBlacklist(const base::ListValue* args);
51
52 // Callback for the "clearSuggestedURLsBlacklist" message.
53 void HandleClearBlacklist(const base::ListValue* args);
54
55 // content::NotificationObserver implementation.
56 virtual void Observe(int type,
57 const content::NotificationSource& source,
58 const content::NotificationDetails& details) OVERRIDE;
59
60 const std::vector<GURL>& most_visited_urls() const {
61 return most_visited_urls_;
62 }
63
64 static void RegisterUserPrefs(PrefService* prefs);
65
66 private:
67 struct SuggestedPage;
68
69 // Send a request to the HistoryService to get the most visited pages.
70 void StartQueryForSuggested();
71
72 // Sets pages_value_ from a format produced by TopSites.
73 void SetPagesValueFromTopSites(const history::MostVisitedURLList& data);
74
75 // Callback for TopSites.
76 void OnSuggestedURLsAvailable(const history::MostVisitedURLList& data);
77
78 // Puts the passed URL in the blacklist (so it does not show as a thumbnail).
79 void BlacklistURL(const GURL& url);
80
81 // Returns the key used in url_blacklist_ for the passed |url|.
82 std::string GetDictionaryKeyForURL(const std::string& url);
83
84 // Sends pages_value_ to the javascript side to and resets page_value_.
85 void SendPagesValue();
86
87 content::NotificationRegistrar registrar_;
88
89 // Our consumer for the history service.
90 CancelableRequestConsumerTSimple<PageUsageData*> cancelable_consumer_;
91 CancelableRequestConsumer topsites_consumer_;
92
93 // The most visited URLs, in priority order.
94 // Only used for matching up clicks on the page to which most visited entry
95 // was clicked on for metrics purposes.
96 std::vector<GURL> most_visited_urls_;
97
98 // We pre-fetch the first set of result pages. This variable is false until
99 // we get the first getSuggested() call.
100 bool got_first_suggested_request_;
101
102 // Keep the results of the db query here.
103 scoped_ptr<base::ListValue> pages_value_;
104
105 DISALLOW_COPY_AND_ASSIGN(SuggestedHandler);
106 };
107
108 #endif // CHROME_BROWSER_UI_WEBUI_NTP_SUGGESTED_PAGE_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698