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

Unified Diff: chrome/browser/dom_ui/new_tab_ui.cc

Issue 394005: Add message and image to NTP to promote extensions and bookmark sync.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month 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/dom_ui/new_tab_ui.cc
===================================================================
--- chrome/browser/dom_ui/new_tab_ui.cc (revision 32026)
+++ chrome/browser/dom_ui/new_tab_ui.cc (working copy)
@@ -199,6 +199,36 @@
}
///////////////////////////////////////////////////////////////////////////////
+// PromotionalMessageHandler
+
+class PromotionalMessageHandler : public DOMMessageHandler {
+ public:
+ PromotionalMessageHandler() {}
+ virtual ~PromotionalMessageHandler() {}
+
+ // DOMMessageHandler implementation.
+ virtual void RegisterMessages();
+
+ // Zero promotional message counter.
+ void HandleClosePromotionalMessage(const Value* content);
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(PromotionalMessageHandler);
+};
+
+void PromotionalMessageHandler::RegisterMessages() {
+ dom_ui_->RegisterMessageCallback("stopPromoMessages",
+ NewCallback(this,
+ &PromotionalMessageHandler::HandleClosePromotionalMessage));
+}
+
+void PromotionalMessageHandler::HandleClosePromotionalMessage(
+ const Value* content) {
+ dom_ui_->GetProfile()->GetPrefs()->SetInteger(prefs::kNTPPromoRemaining, 0);
+}
+
+
+///////////////////////////////////////////////////////////////////////////////
// RecentlyClosedTabsHandler
class RecentlyClosedTabsHandler : public DOMMessageHandler,
@@ -569,6 +599,7 @@
}
AddMessageHandler((new NewTabPageSetHomePageHandler())->Attach(this));
+ AddMessageHandler((new PromotionalMessageHandler())->Attach(this));
NewTabHTMLSource* html_source = new NewTabHTMLSource(GetProfile());
bool posted = ChromeThread::PostTask(
@@ -883,6 +914,15 @@
l10n_util::GetString(IDS_NEW_TAB_TIPS));
localized_strings.SetString(L"sync",
l10n_util::GetString(IDS_NEW_TAB_SHOW_HIDE_BOOKMARK_SYNC));
+ localized_strings.SetString(L"promonew",
+ l10n_util::GetString(IDS_NTP_PROMOTION_NEW));
+ localized_strings.SetString(L"promomessage",
+ l10n_util::GetStringF(IDS_NTP_PROMOTION_MESSAGE,
+ l10n_util::GetString(IDS_PRODUCT_NAME),
+ ASCIIToWide(Extension::kGalleryBrowseUrl),
+ l10n_util::GetString(IDS_SYNC_SERVICE_HELP_URL)));
+ localized_strings.SetString(L"extensionslink",
+ ASCIIToWide(Extension::kGalleryBrowseUrl));
// Don't initiate the sync related message passing with the page if the sync
// code is not present.
@@ -902,8 +942,8 @@
// Decrement ntp promo counter; the default value is specified in
// Browser::RegisterUserPrefs.
- profile->GetPrefs()->SetInteger(prefs::kNTPThemePromoRemaining,
- profile->GetPrefs()->GetInteger(prefs::kNTPThemePromoRemaining) - 1);
+ profile->GetPrefs()->SetInteger(prefs::kNTPPromoRemaining,
+ profile->GetPrefs()->GetInteger(prefs::kNTPPromoRemaining) - 1);
first_view_ = false;
}

Powered by Google App Engine
This is Rietveld 408576698