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

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: Rename files to notification_promo.[h|cc] 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 102893)
+++ chrome/browser/ui/webui/ntp/new_tab_page_handler.cc (working copy)
@@ -8,6 +8,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/ui/webui/ntp/new_tab_ui.h"
+#include "chrome/browser/web_resource/notification_promo.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/pref_names.h"
#include "content/common/notification_service.h"
@@ -22,8 +23,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("closeNotificationPromo", NewCallback(
+ this, &NewTabPageHandler::HandleCloseNotificationPromo));
+ web_ui_->RegisterMessageCallback("notificationPromoViewed", NewCallback(
+ this, &NewTabPageHandler::HandleNotificationPromoViewed));
web_ui_->RegisterMessageCallback("pageSelected", NewCallback(
this, &NewTabPageHandler::HandlePageSelected));
web_ui_->RegisterMessageCallback("introMessageDismissed", NewCallback(
@@ -32,15 +35,21 @@
this, &NewTabPageHandler::HandleIntroMessageSeen));
}
-void NewTabPageHandler::HandleClosePromo(const ListValue* args) {
- Profile::FromWebUI(web_ui_)->GetPrefs()->SetBoolean(prefs::kNTPPromoClosed,
- true);
- NotificationService* service = NotificationService::current();
- service->Notify(chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED,
- Source<NewTabPageHandler>(this),
- NotificationService::NoDetails());
+void NewTabPageHandler::HandleCloseNotificationPromo(const ListValue* args) {
+ NotificationPromo notification_promo(
+ Profile::FromWebUI(web_ui_)->GetPrefs(), NULL);
+ notification_promo.HandleClosed();
+ NotifyPromoResourceChanged();
}
+void NewTabPageHandler::HandleNotificationPromoViewed(const ListValue* args) {
+ NotificationPromo notification_promo(
+ Profile::FromWebUI(web_ui_)->GetPrefs(), NULL);
+ if (notification_promo.HandleViewed()) {
+ NotifyPromoResourceChanged();
+ }
+}
+
void NewTabPageHandler::HandlePageSelected(const ListValue* args) {
double page_id_double;
CHECK(args->GetDouble(0, &page_id_double));
@@ -103,3 +112,10 @@
void NewTabPageHandler::DismissIntroMessage(PrefService* prefs) {
prefs->SetInteger(prefs::kNTP4IntroDisplayCount, kIntroDisplayMax + 1);
}
+
+void NewTabPageHandler::NotifyPromoResourceChanged() {
+ NotificationService* service = NotificationService::current();
+ service->Notify(chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED,
+ Source<NewTabPageHandler>(this),
+ NotificationService::NoDetails());
+}
« no previous file with comments | « chrome/browser/ui/webui/ntp/new_tab_page_handler.h ('k') | chrome/browser/web_resource/notification_promo.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698