| 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_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/public/browser/web_ui_message_handler.h" | 10 #include "content/public/browser/web_ui_message_handler.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 | 24 |
| 25 // Callback for "closeNotificationPromo". | 25 // Callback for "closeNotificationPromo". |
| 26 void HandleCloseNotificationPromo(const ListValue* args); | 26 void HandleCloseNotificationPromo(const ListValue* args); |
| 27 | 27 |
| 28 // Callback for "notificationPromoViewed". | 28 // Callback for "notificationPromoViewed". |
| 29 void HandleNotificationPromoViewed(const ListValue* args); | 29 void HandleNotificationPromoViewed(const ListValue* args); |
| 30 | 30 |
| 31 // Callback for "pageSelected". | 31 // Callback for "pageSelected". |
| 32 void HandlePageSelected(const ListValue* args); | 32 void HandlePageSelected(const ListValue* args); |
| 33 | 33 |
| 34 // Callback for "introMessageDismissed". This is called when the close button | |
| 35 // on the ntp4 bubble is clicked or when a NavDot is clicked. | |
| 36 void HandleIntroMessageDismissed(const ListValue* args); | |
| 37 | |
| 38 // Callback for "handleIntroMessageSeen". No arguments. Called when the intro | |
| 39 // message is displayed. | |
| 40 void HandleIntroMessageSeen(const ListValue* args); | |
| 41 | |
| 42 // Register NTP per-profile preferences. | 34 // Register NTP per-profile preferences. |
| 43 static void RegisterUserPrefs(PrefService* prefs); | 35 static void RegisterUserPrefs(PrefService* prefs); |
| 44 | 36 |
| 45 // Register NTP profile-independent preferences. | 37 // Register NTP profile-independent preferences. |
| 46 static void RegisterPrefs(PrefService* prefs); | 38 static void RegisterPrefs(PrefService* prefs); |
| 47 | 39 |
| 48 // Registers values (strings etc.) for the page. | 40 // Registers values (strings etc.) for the page. |
| 49 static void GetLocalizedValues(Profile* profile, DictionaryValue* values); | 41 static void GetLocalizedValues(Profile* profile, DictionaryValue* values); |
| 50 | 42 |
| 51 // Permanently dismiss the ntp4 bubble for new users. | |
| 52 static void DismissIntroMessage(PrefService* prefs); | |
| 53 | |
| 54 private: | 43 private: |
| 55 // Tracks the number of times the user has switches pages (for UMA). | 44 // Tracks the number of times the user has switches pages (for UMA). |
| 56 size_t page_switch_count_; | 45 size_t page_switch_count_; |
| 57 | 46 |
| 58 // The purpose of this enum is to track which page on the NTP is showing. | 47 // The purpose of this enum is to track which page on the NTP is showing. |
| 59 // The lower 10 bits of kNtpShownPage are used for the index within the page | 48 // The lower 10 bits of kNtpShownPage are used for the index within the page |
| 60 // group, and the rest of the bits are used for the page group ID (defined | 49 // group, and the rest of the bits are used for the page group ID (defined |
| 61 // here). | 50 // here). |
| 62 static const int kPageIdOffset = 10; | 51 static const int kPageIdOffset = 10; |
| 63 enum { | 52 enum { |
| 64 INDEX_MASK = (1 << kPageIdOffset) - 1, | 53 INDEX_MASK = (1 << kPageIdOffset) - 1, |
| 65 MOST_VISITED_PAGE_ID = 1 << kPageIdOffset, | 54 MOST_VISITED_PAGE_ID = 1 << kPageIdOffset, |
| 66 APPS_PAGE_ID = 2 << kPageIdOffset, | 55 APPS_PAGE_ID = 2 << kPageIdOffset, |
| 67 BOOKMARKS_PAGE_ID = 3 << kPageIdOffset, | 56 BOOKMARKS_PAGE_ID = 3 << kPageIdOffset, |
| 68 SUGGESTIONS_PAGE_ID = 4 << kPageIdOffset, | 57 SUGGESTIONS_PAGE_ID = 4 << kPageIdOffset, |
| 69 LAST_PAGE_ID = SUGGESTIONS_PAGE_ID | 58 LAST_PAGE_ID = SUGGESTIONS_PAGE_ID |
| 70 }; | 59 }; |
| 71 static const int kHistogramEnumerationMax = | 60 static const int kHistogramEnumerationMax = |
| 72 (LAST_PAGE_ID >> kPageIdOffset) + 1; | 61 (LAST_PAGE_ID >> kPageIdOffset) + 1; |
| 73 | 62 |
| 74 // Helper to send out promo resource change notification. | 63 // Helper to send out promo resource change notification. |
| 75 void Notify(chrome::NotificationType notification_type); | 64 void Notify(chrome::NotificationType notification_type); |
| 76 | 65 |
| 77 DISALLOW_COPY_AND_ASSIGN(NewTabPageHandler); | 66 DISALLOW_COPY_AND_ASSIGN(NewTabPageHandler); |
| 78 }; | 67 }; |
| 79 | 68 |
| 80 #endif // CHROME_BROWSER_UI_WEBUI_NTP_NEW_TAB_PAGE_HANDLER_H_ | 69 #endif // CHROME_BROWSER_UI_WEBUI_NTP_NEW_TAB_PAGE_HANDLER_H_ |
| OLD | NEW |