summaryrefslogtreecommitdiffstats
path: root/chrome/browser/dom_ui
diff options
context:
space:
mode:
authormirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-15 19:19:30 +0000
committermirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-15 19:19:30 +0000
commita7a2b70880a149060184f7039fb0468d2dda7b4b (patch)
treeba2cf6af9903256bfad59e15f57bc93bcca1d0e1 /chrome/browser/dom_ui
parent50d7d721e63e1e1604b37b9361ec03a5affdfd0d (diff)
downloadchromium_src-a7a2b70880a149060184f7039fb0468d2dda7b4b.zip
chromium_src-a7a2b70880a149060184f7039fb0468d2dda7b4b.tar.gz
chromium_src-a7a2b70880a149060184f7039fb0468d2dda7b4b.tar.bz2
Add message and image to NTP to promote extensions and bookmark sync.
BUG= 27393, 26744 TEST= promotional messages should show up on NTP. Review URL: http://codereview.chromium.org/394005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32027 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/dom_ui')
-rw-r--r--chrome/browser/dom_ui/dom_ui_theme_source.cc7
-rw-r--r--chrome/browser/dom_ui/new_tab_ui.cc44
2 files changed, 47 insertions, 4 deletions
diff --git a/chrome/browser/dom_ui/dom_ui_theme_source.cc b/chrome/browser/dom_ui/dom_ui_theme_source.cc
index e447c3e..768c589 100644
--- a/chrome/browser/dom_ui/dom_ui_theme_source.cc
+++ b/chrome/browser/dom_ui/dom_ui_theme_source.cc
@@ -184,10 +184,13 @@ void DOMUIThemeSource::InitNewTabCSS(Profile* profile) {
subst2.push_back(SkColorToRGBAString(color_link_underline)); // $$6
subst2.push_back(SkColorToRGBAString(color_section_link_underline)); // $$7
- if (profile->GetPrefs()->GetInteger(prefs::kNTPThemePromoRemaining) > 0)
+ if (profile->GetPrefs()->GetInteger(prefs::kNTPPromoRemaining) > 0) {
subst2.push_back("block"); // $$8
- else
+ subst2.push_back("inline-block"); // $$9
+ } else {
subst2.push_back("none"); // $$8
+ subst2.push_back("none"); // $$9
+ }
// Get our template.
static const base::StringPiece new_tab_theme_css(
diff --git a/chrome/browser/dom_ui/new_tab_ui.cc b/chrome/browser/dom_ui/new_tab_ui.cc
index 8956c47..b319fb5 100644
--- a/chrome/browser/dom_ui/new_tab_ui.cc
+++ b/chrome/browser/dom_ui/new_tab_ui.cc
@@ -199,6 +199,36 @@ void IncognitoTabHTMLSource::InitFullHTML() {
}
///////////////////////////////////////////////////////////////////////////////
+// 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 @@ NewTabUI::NewTabUI(TabContents* contents)
}
AddMessageHandler((new NewTabPageSetHomePageHandler())->Attach(this));
+ AddMessageHandler((new PromotionalMessageHandler())->Attach(this));
NewTabHTMLSource* html_source = new NewTabHTMLSource(GetProfile());
bool posted = ChromeThread::PostTask(
@@ -883,6 +914,15 @@ void NewTabUI::NewTabHTMLSource::InitFullHTML(Profile* profile) {
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 @@ void NewTabUI::NewTabHTMLSource::InitFullHTML(Profile* profile) {
// 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;
}