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

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

Issue 10911196: Support for ntp promo bubble. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: allow BR in parseHtmlSubset Created 8 years, 3 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 | Annotate | Revision Log
OLDNEW
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"
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 content::WebUIMessageHandler { 17 class NewTabPageHandler : public content::WebUIMessageHandler {
18 public: 18 public:
19 NewTabPageHandler(); 19 NewTabPageHandler();
20 virtual ~NewTabPageHandler();
21
22 // WebUIMessageHandler implementation.
23 virtual void RegisterMessages() OVERRIDE;
24
25 // Callback for "closeNotificationPromo".
26 void HandleCloseNotificationPromo(const ListValue* args);
27
28 // Callback for "notificationPromoViewed".
29 void HandleNotificationPromoViewed(const ListValue* args);
30
31 // Callback for "pageSelected".
32 void HandlePageSelected(const ListValue* args);
33 20
34 // Register NTP per-profile preferences. 21 // Register NTP per-profile preferences.
35 static void RegisterUserPrefs(PrefService* prefs); 22 static void RegisterUserPrefs(PrefService* prefs);
36 23
37 // Register NTP profile-independent preferences. 24 // Register NTP profile-independent preferences.
38 static void RegisterPrefs(PrefService* prefs); 25 static void RegisterPrefs(PrefService* prefs);
39 26
40 // Registers values (strings etc.) for the page. 27 // Registers values (strings etc.) for the page.
41 static void GetLocalizedValues(Profile* profile, DictionaryValue* values); 28 static void GetLocalizedValues(Profile* profile, DictionaryValue* values);
42 29
43 private: 30 private:
31 virtual ~NewTabPageHandler();
32
33 // WebUIMessageHandler implementation.
34 virtual void RegisterMessages() OVERRIDE;
35
36 // Callback for "notificationPromoClosed". No arguments.
37 void HandleNotificationPromoClosed(const ListValue* args);
38
39 // Callback for "notificationPromoViewed". No arguments.
40 void HandleNotificationPromoViewed(const ListValue* args);
41
42 // Callback for "bubblePromoClosed". No arguments.
43 void HandleBubblePromoClosed(const ListValue* args);
44
45 // Callback for "bubblePromoViewed". No arguments.
46 void HandleBubblePromoViewed(const ListValue* args);
47
48 // Callback for "pageSelected".
49 void HandlePageSelected(const ListValue* args);
50
44 // Tracks the number of times the user has switches pages (for UMA). 51 // Tracks the number of times the user has switches pages (for UMA).
45 size_t page_switch_count_; 52 size_t page_switch_count_;
46 53
47 // The purpose of this enum is to track which page on the NTP is showing. 54 // The purpose of this enum is to track which page on the NTP is showing.
48 // The lower 10 bits of kNtpShownPage are used for the index within the page 55 // The lower 10 bits of kNtpShownPage are used for the index within the page
49 // group, and the rest of the bits are used for the page group ID (defined 56 // group, and the rest of the bits are used for the page group ID (defined
50 // here). 57 // here).
51 static const int kPageIdOffset = 10; 58 static const int kPageIdOffset = 10;
52 enum { 59 enum {
53 INDEX_MASK = (1 << kPageIdOffset) - 1, 60 INDEX_MASK = (1 << kPageIdOffset) - 1,
54 MOST_VISITED_PAGE_ID = 1 << kPageIdOffset, 61 MOST_VISITED_PAGE_ID = 1 << kPageIdOffset,
55 APPS_PAGE_ID = 2 << kPageIdOffset, 62 APPS_PAGE_ID = 2 << kPageIdOffset,
56 BOOKMARKS_PAGE_ID = 3 << kPageIdOffset, 63 BOOKMARKS_PAGE_ID = 3 << kPageIdOffset,
57 SUGGESTIONS_PAGE_ID = 4 << kPageIdOffset, 64 SUGGESTIONS_PAGE_ID = 4 << kPageIdOffset,
58 RECENTLY_CLOSED_PAGE_ID = 5 << kPageIdOffset, 65 RECENTLY_CLOSED_PAGE_ID = 5 << kPageIdOffset,
59 LAST_PAGE_ID = RECENTLY_CLOSED_PAGE_ID 66 LAST_PAGE_ID = RECENTLY_CLOSED_PAGE_ID
60 }; 67 };
61 static const int kHistogramEnumerationMax = 68 static const int kHistogramEnumerationMax =
62 (LAST_PAGE_ID >> kPageIdOffset) + 1; 69 (LAST_PAGE_ID >> kPageIdOffset) + 1;
63 70
64 // Helper to send out promo resource change notification. 71 // Helper to send out promo resource change notification.
65 void Notify(chrome::NotificationType notification_type); 72 void Notify(chrome::NotificationType notification_type);
66 73
67 DISALLOW_COPY_AND_ASSIGN(NewTabPageHandler); 74 DISALLOW_COPY_AND_ASSIGN(NewTabPageHandler);
68 }; 75 };
69 76
70 #endif // CHROME_BROWSER_UI_WEBUI_NTP_NEW_TAB_PAGE_HANDLER_H_ 77 #endif // CHROME_BROWSER_UI_WEBUI_NTP_NEW_TAB_PAGE_HANDLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/resources/ntp4/new_tab.js ('k') | chrome/browser/ui/webui/ntp/new_tab_page_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698