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

Unified Diff: chrome/browser/ui/webui/ntp/new_tab_page_handler.cc

Issue 8045012: NotificationPromo (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: rebase Created 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/ntp/new_tab_page_handler.cc
===================================================================
--- chrome/browser/ui/webui/ntp/new_tab_page_handler.cc (revision 102829)
+++ chrome/browser/ui/webui/ntp/new_tab_page_handler.cc (working copy)
@@ -22,8 +22,10 @@
"http://www.google.com/support/chrome/bin/answer.py?answer=95451";
void NewTabPageHandler::RegisterMessages() {
- web_ui_->RegisterMessageCallback("closePromo", NewCallback(
- this, &NewTabPageHandler::HandleClosePromo));
+ web_ui_->RegisterMessageCallback("closePromoNotification", NewCallback(
+ this, &NewTabPageHandler::HandleClosePromoNotification));
+ web_ui_->RegisterMessageCallback("promoNotificationViewed", NewCallback(
+ this, &NewTabPageHandler::HandlePromoNotificationViewed));
web_ui_->RegisterMessageCallback("pageSelected", NewCallback(
this, &NewTabPageHandler::HandlePageSelected));
web_ui_->RegisterMessageCallback("introMessageDismissed", NewCallback(
@@ -32,7 +34,7 @@
this, &NewTabPageHandler::HandleIntroMessageSeen));
}
-void NewTabPageHandler::HandleClosePromo(const ListValue* args) {
+void NewTabPageHandler::HandleClosePromoNotification(const ListValue* args) {
Profile::FromWebUI(web_ui_)->GetPrefs()->SetBoolean(prefs::kNTPPromoClosed,
true);
NotificationService* service = NotificationService::current();
@@ -41,6 +43,20 @@
NotificationService::NoDetails());
}
+void NewTabPageHandler::HandlePromoNotificationViewed(const ListValue* args) {
+ PrefService* prefs = Profile::FromWebUI(web_ui_)->GetPrefs();
+ const int views = prefs->GetInteger(prefs::kNTPPromoViews) + 1;
+ prefs->SetInteger(prefs::kNTPPromoViews, views);
+ const int max_views = prefs->GetInteger(prefs::kNTPPromoViewsMax);
+
+ if (views >= max_views) {
+ NotificationService* service = NotificationService::current();
+ service->Notify(chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED,
+ Source<NewTabPageHandler>(this),
+ NotificationService::NoDetails());
+ }
Dan Beam 2011/09/27 03:27:55 You might consider making this a different notific
achuithb 2011/09/27 08:03:19 The same notification is sent by the promo_resourc
+}
+
void NewTabPageHandler::HandlePageSelected(const ListValue* args) {
double page_id_double;
CHECK(args->GetDouble(0, &page_id_double));

Powered by Google App Engine
This is Rietveld 408576698