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

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

Issue 7461160: ntp4 info bubble (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: arv review Created 9 years, 4 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
diff --git a/chrome/browser/ui/webui/ntp/new_tab_page_handler.cc b/chrome/browser/ui/webui/ntp/new_tab_page_handler.cc
index e9722aeb8f439d1faf3c4546d1f8d2689e42a839..10736c8c38d7d22c95c53ad6463dedb65b6e455a 100644
--- a/chrome/browser/ui/webui/ntp/new_tab_page_handler.cc
+++ b/chrome/browser/ui/webui/ntp/new_tab_page_handler.cc
@@ -11,6 +11,10 @@
#include "chrome/browser/ui/webui/ntp/new_tab_ui.h"
#include "chrome/common/chrome_notification_types.h"
#include "content/common/notification_service.h"
+#include "grit/chromium_strings.h"
+#include "ui/base/l10n/l10n_util.h"
+
+static const int kIntroDisplayMax = 10;
void NewTabPageHandler::RegisterMessages() {
web_ui_->RegisterMessageCallback("closePromo", NewCallback(
@@ -19,6 +23,10 @@ void NewTabPageHandler::RegisterMessages() {
this, &NewTabPageHandler::HandleCloseSyncNotification));
web_ui_->RegisterMessageCallback("pageSelected", NewCallback(
this, &NewTabPageHandler::HandlePageSelected));
+ web_ui_->RegisterMessageCallback("navigationDotUsed", NewCallback(
+ this, &NewTabPageHandler::HandleNavDotUsed));
+ web_ui_->RegisterMessageCallback("introMessageSeen", NewCallback(
+ this, &NewTabPageHandler::HandleIntroMessageSeen));
}
void NewTabPageHandler::HandleClosePromo(const ListValue* args) {
@@ -50,11 +58,24 @@ void NewTabPageHandler::HandlePageSelected(const ListValue* args) {
prefs->SetInteger(prefs::kNTPShownPage, page_id | index);
}
+void NewTabPageHandler::HandleNavDotUsed(const ListValue* args) {
+ PrefService* prefs = Profile::FromWebUI(web_ui_)->GetPrefs();
+ prefs->SetInteger(prefs::kNTP4IntroDisplayCount, kIntroDisplayMax + 1);
+}
+
+void NewTabPageHandler::HandleIntroMessageSeen(const ListValue* args) {
+ PrefService* prefs = Profile::FromWebUI(web_ui_)->GetPrefs();
+ int intro_displays = prefs->GetInteger(prefs::kNTP4IntroDisplayCount);
+ prefs->SetInteger(prefs::kNTP4IntroDisplayCount, intro_displays + 1);
+}
+
// static
void NewTabPageHandler::RegisterUserPrefs(PrefService* prefs) {
// TODO(estade): should be syncable.
prefs->RegisterIntegerPref(prefs::kNTPShownPage, APPS_PAGE_ID,
PrefService::UNSYNCABLE_PREF);
+ prefs->RegisterIntegerPref(prefs::kNTP4IntroDisplayCount, 0,
+ PrefService::UNSYNCABLE_PREF);
}
// static
@@ -71,4 +92,10 @@ void NewTabPageHandler::GetLocalizedValues(Profile* profile,
int shown_page = prefs->GetInteger(prefs::kNTPShownPage);
values->SetInteger("shown_page_type", shown_page & ~INDEX_MASK);
values->SetInteger("shown_page_index", shown_page & INDEX_MASK);
+
+ int intro_displays = prefs->GetInteger(prefs::kNTP4IntroDisplayCount);
+ if (intro_displays <= kIntroDisplayMax) {
+ values->SetString("ntp4_intro_message",
+ l10n_util::GetStringUTF16(IDS_NTP4_INTRO_MESSAGE));
+ }
}
« no previous file with comments | « chrome/browser/ui/webui/ntp/new_tab_page_handler.h ('k') | chrome/browser/ui/webui/ntp/ntp_resource_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698