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)); |