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

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: even more docs 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 6d68a2be191975df7bd7067cc4bd68b480ad1fcf..dfe6acba60a3a33e9cd8597342899e7b49b218ed 100644
--- a/chrome/browser/ui/webui/ntp/new_tab_page_handler.cc
+++ b/chrome/browser/ui/webui/ntp/new_tab_page_handler.cc
@@ -10,12 +10,20 @@
#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(
this, &NewTabPageHandler::HandleClosePromo));
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) {
@@ -39,11 +47,24 @@ void NewTabPageHandler::HandlePageSelected(const ListValue* args) {
prefs->SetInteger(prefs::kNTPShownPage, page_id | index);
}
+void NewTabPageHandler::HandleNavDotUsed(const ListValue* args) {
+ PrefService* prefs = web_ui_->GetProfile()->GetPrefs();
+ prefs->SetInteger(prefs::kNTP4IntroDisplayCount, kIntroDisplayMax + 1);
+}
+
+void NewTabPageHandler::HandleIntroMessageSeen(const ListValue* args) {
+ PrefService* prefs = web_ui_->GetProfile()->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
@@ -60,4 +81,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));
+ }
}

Powered by Google App Engine
This is Rietveld 408576698