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

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

Issue 1141843004: NTP Zombie Code Slayer II: Suggestions Page (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: and remove urls Created 5 years, 7 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
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
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_SUGGESTIONS_PAGE_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_NTP_SUGGESTIONS_PAGE_HANDLER_H_
7
8 #include <string>
9
10 #include "base/scoped_observer.h"
11 #include "chrome/browser/ui/webui/ntp/suggestions_combiner.h"
12 #include "components/history/core/browser/history_types.h"
13 #include "components/history/core/browser/top_sites_observer.h"
14 #include "content/public/browser/web_ui_message_handler.h"
15
16 class GURL;
17
18 namespace base {
19 class ListValue;
20 class Value;
21 }
22
23 namespace user_prefs {
24 class PrefRegistrySyncable;
25 }
26
27 // The handler for Javascript messages related to the "suggestions" 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 SuggestionsHandler : public content::WebUIMessageHandler,
34 public SuggestionsCombiner::Delegate,
35 public history::TopSitesObserver {
36 public:
37 SuggestionsHandler();
38 ~SuggestionsHandler() override;
39
40 // WebUIMessageHandler override and implementation.
41 void RegisterMessages() override;
42
43 // Callback for the "getSuggestions" message.
44 void HandleGetSuggestions(const base::ListValue* args);
45
46 // Callback for the "blacklistURLFromSuggestions" message.
47 void HandleBlacklistURL(const base::ListValue* args);
48
49 // Callback for the "removeURLsFromSuggestionsBlacklist" message.
50 void HandleRemoveURLsFromBlacklist(const base::ListValue* args);
51
52 // Callback for the "clearSuggestionsURLsBlacklist" message.
53 void HandleClearBlacklist(const base::ListValue* args);
54
55 // Callback for the "suggestedSitesAction" message.
56 void HandleSuggestedSitesAction(const base::ListValue* args);
57
58 // Callback for the "suggestedSitesSelected" message.
59 void HandleSuggestedSitesSelected(const base::ListValue* args);
60
61 // history::TopSitesObserver implementation.
62 void TopSitesLoaded(history::TopSites* top_sites) override;
63 void TopSitesChanged(history::TopSites* top_sites) override;
64
65 // SuggestionsCombiner::Delegate implementation.
66 void OnSuggestionsReady() override;
67
68 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
69
70 private:
71 // Puts the passed URL in the blacklist (so it does not show as a thumbnail).
72 void BlacklistURL(const GURL& url);
73
74 // Returns the key used in url_blacklist_ for the passed |url|.
75 std::string GetDictionaryKeyForURL(const std::string& url);
76
77 // Sends pages_value_ to the javascript side to and resets page_value_.
78 void SendPagesValue();
79
80 // Scoped observer to help with TopSitesObserver registration.
81 ScopedObserver<history::TopSites, history::TopSitesObserver> scoped_observer_;
82
83 // We pre-fetch the first set of result pages. This variable is false until
84 // we get the first getSuggestions() call.
85 bool got_first_suggestions_request_;
86
87 // Used to combine suggestions from various sources.
88 scoped_ptr<SuggestionsCombiner> suggestions_combiner_;
89
90 // Whether the user has viewed the 'suggested' pane.
91 bool suggestions_viewed_;
92
93 // Whether the user has performed a "tracked" action to leave the page or not.
94 bool user_action_logged_;
95
96 DISALLOW_COPY_AND_ASSIGN(SuggestionsHandler);
97 };
98
99 #endif // CHROME_BROWSER_UI_WEBUI_NTP_SUGGESTIONS_PAGE_HANDLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/ntp/suggestions_combiner_unittest.cc ('k') | chrome/browser/ui/webui/ntp/suggestions_page_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698