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_NTP_NEW_TAB_PAGE_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_NTP_NEW_TAB_PAGE_HANDLER_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_NTP_NEW_TAB_PAGE_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_NTP_NEW_TAB_PAGE_HANDLER_H_ |
7 | 7 |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/common/chrome_notification_types.h" | 9 #include "chrome/common/chrome_notification_types.h" |
10 #include "content/browser/webui/web_ui.h" | 10 #include "content/browser/webui/web_ui.h" |
11 | 11 |
12 class PrefService; | 12 class PrefService; |
13 class Profile; | 13 class Profile; |
14 | 14 |
15 // Handler for general New Tab Page functionality that does not belong in a | 15 // Handler for general New Tab Page functionality that does not belong in a |
16 // more specialized handler. | 16 // more specialized handler. |
17 class NewTabPageHandler : public WebUIMessageHandler { | 17 class NewTabPageHandler : public WebUIMessageHandler { |
18 public: | 18 public: |
19 NewTabPageHandler() {} | 19 NewTabPageHandler(); |
20 virtual ~NewTabPageHandler() {} | 20 virtual ~NewTabPageHandler(); |
21 | 21 |
22 // WebUIMessageHandler implementation. | 22 // WebUIMessageHandler implementation. |
23 virtual WebUIMessageHandler* Attach(WebUI* web_ui) OVERRIDE; | 23 virtual WebUIMessageHandler* Attach(WebUI* web_ui) OVERRIDE; |
24 virtual void RegisterMessages() OVERRIDE; | 24 virtual void RegisterMessages() OVERRIDE; |
25 | 25 |
26 // Callback for "closeNotificationPromo". | 26 // Callback for "closeNotificationPromo". |
27 void HandleCloseNotificationPromo(const ListValue* args); | 27 void HandleCloseNotificationPromo(const ListValue* args); |
28 | 28 |
29 // Callback for "notificationPromoViewed". | 29 // Callback for "notificationPromoViewed". |
30 void HandleNotificationPromoViewed(const ListValue* args); | 30 void HandleNotificationPromoViewed(const ListValue* args); |
(...skipping 15 matching lines...) Expand all Loading... |
46 // Register NTP profile-independent preferences. | 46 // Register NTP profile-independent preferences. |
47 static void RegisterPrefs(PrefService* prefs); | 47 static void RegisterPrefs(PrefService* prefs); |
48 | 48 |
49 // Registers values (strings etc.) for the page. | 49 // Registers values (strings etc.) for the page. |
50 static void GetLocalizedValues(Profile* profile, DictionaryValue* values); | 50 static void GetLocalizedValues(Profile* profile, DictionaryValue* values); |
51 | 51 |
52 // Permanently dismiss the ntp4 bubble for new users. | 52 // Permanently dismiss the ntp4 bubble for new users. |
53 static void DismissIntroMessage(PrefService* prefs); | 53 static void DismissIntroMessage(PrefService* prefs); |
54 | 54 |
55 private: | 55 private: |
| 56 // Tracks the number of times the user has switches pages (for UMA). |
| 57 size_t page_switch_count_; |
| 58 |
56 // The purpose of this enum is to track which page on the NTP is showing. | 59 // The purpose of this enum is to track which page on the NTP is showing. |
57 // The lower 10 bits of kNTPShownPage are used for the index within the page | 60 // The lower 10 bits of kNTPShownPage are used for the index within the page |
58 // group, and the rest of the bits are used for the page group ID (defined | 61 // group, and the rest of the bits are used for the page group ID (defined |
59 // here). | 62 // here). |
60 static const int kPageIdOffset = 10; | 63 static const int kPageIdOffset = 10; |
61 enum { | 64 enum { |
62 INDEX_MASK = (1 << kPageIdOffset) - 1, | 65 INDEX_MASK = (1 << kPageIdOffset) - 1, |
63 MOST_VISITED_PAGE_ID = 1 << kPageIdOffset, | 66 MOST_VISITED_PAGE_ID = 1 << kPageIdOffset, |
64 APPS_PAGE_ID = 2 << kPageIdOffset, | 67 APPS_PAGE_ID = 2 << kPageIdOffset, |
65 BOOKMARKS_PAGE_ID = 3 << kPageIdOffset, | 68 BOOKMARKS_PAGE_ID = 3 << kPageIdOffset, |
66 LAST_PAGE_ID = BOOKMARKS_PAGE_ID | 69 LAST_PAGE_ID = BOOKMARKS_PAGE_ID |
67 }; | 70 }; |
68 static const int kHistogramEnumerationMax = | 71 static const int kHistogramEnumerationMax = |
69 (LAST_PAGE_ID >> kPageIdOffset) + 1; | 72 (LAST_PAGE_ID >> kPageIdOffset) + 1; |
70 | 73 |
71 // Helper to send out promo resource change notification. | 74 // Helper to send out promo resource change notification. |
72 void Notify(chrome::NotificationType notification_type); | 75 void Notify(chrome::NotificationType notification_type); |
73 | 76 |
74 DISALLOW_COPY_AND_ASSIGN(NewTabPageHandler); | 77 DISALLOW_COPY_AND_ASSIGN(NewTabPageHandler); |
75 }; | 78 }; |
76 | 79 |
77 #endif // CHROME_BROWSER_UI_WEBUI_NTP_NEW_TAB_PAGE_HANDLER_H_ | 80 #endif // CHROME_BROWSER_UI_WEBUI_NTP_NEW_TAB_PAGE_HANDLER_H_ |
OLD | NEW |