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/common/cancelable_request.h" | 10 #include "chrome/browser/common/cancelable_request.h" |
11 #include "chrome/browser/history/history_types.h" | 11 #include "chrome/browser/history/history_types.h" |
12 #include "chrome/browser/ui/webui/ntp/suggestions_combiner.h" | 12 #include "chrome/browser/ui/webui/ntp/suggestions_combiner.h" |
13 #include "content/public/browser/notification_observer.h" | 13 #include "content/public/browser/notification_observer.h" |
14 #include "content/public/browser/notification_registrar.h" | 14 #include "content/public/browser/notification_registrar.h" |
15 #include "content/public/browser/web_ui_message_handler.h" | 15 #include "content/public/browser/web_ui_message_handler.h" |
16 | 16 |
17 class GURL; | 17 class GURL; |
18 class PageUsageData; | 18 class PageUsageData; |
19 class PrefRegistrySyncable; | |
20 | 19 |
21 namespace base { | 20 namespace base { |
22 class ListValue; | 21 class ListValue; |
23 class Value; | 22 class Value; |
24 } | 23 } |
25 | 24 |
| 25 namespace user_prefs { |
| 26 class PrefRegistrySyncable; |
| 27 } |
| 28 |
26 // The handler for Javascript messages related to the "suggestions" view. | 29 // The handler for Javascript messages related to the "suggestions" view. |
27 // | 30 // |
28 // This class manages one preference: | 31 // This class manages one preference: |
29 // - The URL blacklist: URLs we do not want to show in the thumbnails list. It | 32 // - The URL blacklist: URLs we do not want to show in the thumbnails list. It |
30 // is a dictionary for quick access (it associates a dummy boolean to the URL | 33 // is a dictionary for quick access (it associates a dummy boolean to the URL |
31 // string). | 34 // string). |
32 class SuggestionsHandler : public content::WebUIMessageHandler, | 35 class SuggestionsHandler : public content::WebUIMessageHandler, |
33 public content::NotificationObserver, | 36 public content::NotificationObserver, |
34 public SuggestionsCombiner::Delegate { | 37 public SuggestionsCombiner::Delegate { |
35 public: | 38 public: |
(...skipping 22 matching lines...) Expand all Loading... |
58 void HandleSuggestedSitesSelected(const base::ListValue* args); | 61 void HandleSuggestedSitesSelected(const base::ListValue* args); |
59 | 62 |
60 // content::NotificationObserver implementation. | 63 // content::NotificationObserver implementation. |
61 virtual void Observe(int type, | 64 virtual void Observe(int type, |
62 const content::NotificationSource& source, | 65 const content::NotificationSource& source, |
63 const content::NotificationDetails& details) OVERRIDE; | 66 const content::NotificationDetails& details) OVERRIDE; |
64 | 67 |
65 // SuggestionsCombiner::Delegate implementation. | 68 // SuggestionsCombiner::Delegate implementation. |
66 virtual void OnSuggestionsReady() OVERRIDE; | 69 virtual void OnSuggestionsReady() OVERRIDE; |
67 | 70 |
68 static void RegisterUserPrefs(PrefRegistrySyncable* registry); | 71 static void RegisterUserPrefs(user_prefs::PrefRegistrySyncable* registry); |
69 | 72 |
70 private: | 73 private: |
71 // Puts the passed URL in the blacklist (so it does not show as a thumbnail). | 74 // Puts the passed URL in the blacklist (so it does not show as a thumbnail). |
72 void BlacklistURL(const GURL& url); | 75 void BlacklistURL(const GURL& url); |
73 | 76 |
74 // Returns the key used in url_blacklist_ for the passed |url|. | 77 // Returns the key used in url_blacklist_ for the passed |url|. |
75 std::string GetDictionaryKeyForURL(const std::string& url); | 78 std::string GetDictionaryKeyForURL(const std::string& url); |
76 | 79 |
77 // Sends pages_value_ to the javascript side to and resets page_value_. | 80 // Sends pages_value_ to the javascript side to and resets page_value_. |
78 void SendPagesValue(); | 81 void SendPagesValue(); |
(...skipping 10 matching lines...) Expand all Loading... |
89 // Whether the user has viewed the 'suggested' pane. | 92 // Whether the user has viewed the 'suggested' pane. |
90 bool suggestions_viewed_; | 93 bool suggestions_viewed_; |
91 | 94 |
92 // Whether the user has performed a "tracked" action to leave the page or not. | 95 // Whether the user has performed a "tracked" action to leave the page or not. |
93 bool user_action_logged_; | 96 bool user_action_logged_; |
94 | 97 |
95 DISALLOW_COPY_AND_ASSIGN(SuggestionsHandler); | 98 DISALLOW_COPY_AND_ASSIGN(SuggestionsHandler); |
96 }; | 99 }; |
97 | 100 |
98 #endif // CHROME_BROWSER_UI_WEBUI_NTP_SUGGESTIONS_PAGE_HANDLER_H_ | 101 #endif // CHROME_BROWSER_UI_WEBUI_NTP_SUGGESTIONS_PAGE_HANDLER_H_ |
OLD | NEW |