| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_SUGGESTIONS_PAGE_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_NTP_SUGGESTIONS_PAGE_HANDLER_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_NTP_SUGGESTIONS_PAGE_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_NTP_SUGGESTIONS_PAGE_HANDLER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "chrome/browser/ui/webui/ntp/suggestions_combiner.h" | 10 #include "chrome/browser/ui/webui/ntp/suggestions_combiner.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 // | 29 // |
| 30 // This class manages one preference: | 30 // This class manages one preference: |
| 31 // - The URL blacklist: URLs we do not want to show in the thumbnails list. It | 31 // - The URL blacklist: URLs we do not want to show in the thumbnails list. It |
| 32 // is a dictionary for quick access (it associates a dummy boolean to the URL | 32 // is a dictionary for quick access (it associates a dummy boolean to the URL |
| 33 // string). | 33 // string). |
| 34 class SuggestionsHandler : public content::WebUIMessageHandler, | 34 class SuggestionsHandler : public content::WebUIMessageHandler, |
| 35 public content::NotificationObserver, | 35 public content::NotificationObserver, |
| 36 public SuggestionsCombiner::Delegate { | 36 public SuggestionsCombiner::Delegate { |
| 37 public: | 37 public: |
| 38 SuggestionsHandler(); | 38 SuggestionsHandler(); |
| 39 virtual ~SuggestionsHandler(); | 39 ~SuggestionsHandler() override; |
| 40 | 40 |
| 41 // WebUIMessageHandler override and implementation. | 41 // WebUIMessageHandler override and implementation. |
| 42 virtual void RegisterMessages() override; | 42 void RegisterMessages() override; |
| 43 | 43 |
| 44 // Callback for the "getSuggestions" message. | 44 // Callback for the "getSuggestions" message. |
| 45 void HandleGetSuggestions(const base::ListValue* args); | 45 void HandleGetSuggestions(const base::ListValue* args); |
| 46 | 46 |
| 47 // Callback for the "blacklistURLFromSuggestions" message. | 47 // Callback for the "blacklistURLFromSuggestions" message. |
| 48 void HandleBlacklistURL(const base::ListValue* args); | 48 void HandleBlacklistURL(const base::ListValue* args); |
| 49 | 49 |
| 50 // Callback for the "removeURLsFromSuggestionsBlacklist" message. | 50 // Callback for the "removeURLsFromSuggestionsBlacklist" message. |
| 51 void HandleRemoveURLsFromBlacklist(const base::ListValue* args); | 51 void HandleRemoveURLsFromBlacklist(const base::ListValue* args); |
| 52 | 52 |
| 53 // Callback for the "clearSuggestionsURLsBlacklist" message. | 53 // Callback for the "clearSuggestionsURLsBlacklist" message. |
| 54 void HandleClearBlacklist(const base::ListValue* args); | 54 void HandleClearBlacklist(const base::ListValue* args); |
| 55 | 55 |
| 56 // Callback for the "suggestedSitesAction" message. | 56 // Callback for the "suggestedSitesAction" message. |
| 57 void HandleSuggestedSitesAction(const base::ListValue* args); | 57 void HandleSuggestedSitesAction(const base::ListValue* args); |
| 58 | 58 |
| 59 // Callback for the "suggestedSitesSelected" message. | 59 // Callback for the "suggestedSitesSelected" message. |
| 60 void HandleSuggestedSitesSelected(const base::ListValue* args); | 60 void HandleSuggestedSitesSelected(const base::ListValue* args); |
| 61 | 61 |
| 62 // content::NotificationObserver implementation. | 62 // content::NotificationObserver implementation. |
| 63 virtual void Observe(int type, | 63 void Observe(int type, |
| 64 const content::NotificationSource& source, | 64 const content::NotificationSource& source, |
| 65 const content::NotificationDetails& details) override; | 65 const content::NotificationDetails& details) override; |
| 66 | 66 |
| 67 // SuggestionsCombiner::Delegate implementation. | 67 // SuggestionsCombiner::Delegate implementation. |
| 68 virtual void OnSuggestionsReady() override; | 68 void OnSuggestionsReady() override; |
| 69 | 69 |
| 70 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 70 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
| 71 | 71 |
| 72 private: | 72 private: |
| 73 // Puts the passed URL in the blacklist (so it does not show as a thumbnail). | 73 // Puts the passed URL in the blacklist (so it does not show as a thumbnail). |
| 74 void BlacklistURL(const GURL& url); | 74 void BlacklistURL(const GURL& url); |
| 75 | 75 |
| 76 // Returns the key used in url_blacklist_ for the passed |url|. | 76 // Returns the key used in url_blacklist_ for the passed |url|. |
| 77 std::string GetDictionaryKeyForURL(const std::string& url); | 77 std::string GetDictionaryKeyForURL(const std::string& url); |
| 78 | 78 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 91 // Whether the user has viewed the 'suggested' pane. | 91 // Whether the user has viewed the 'suggested' pane. |
| 92 bool suggestions_viewed_; | 92 bool suggestions_viewed_; |
| 93 | 93 |
| 94 // Whether the user has performed a "tracked" action to leave the page or not. | 94 // Whether the user has performed a "tracked" action to leave the page or not. |
| 95 bool user_action_logged_; | 95 bool user_action_logged_; |
| 96 | 96 |
| 97 DISALLOW_COPY_AND_ASSIGN(SuggestionsHandler); | 97 DISALLOW_COPY_AND_ASSIGN(SuggestionsHandler); |
| 98 }; | 98 }; |
| 99 | 99 |
| 100 #endif // CHROME_BROWSER_UI_WEBUI_NTP_SUGGESTIONS_PAGE_HANDLER_H_ | 100 #endif // CHROME_BROWSER_UI_WEBUI_NTP_SUGGESTIONS_PAGE_HANDLER_H_ |
| OLD | NEW |