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

Unified Diff: chrome/browser/resources/new_new_tab.js

Issue 4804001: Add new promotional line for NTP.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 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
« no previous file with comments | « chrome/browser/resources/new_new_tab.css ('k') | chrome/browser/web_resource/web_resource_service.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/new_new_tab.js
===================================================================
--- chrome/browser/resources/new_new_tab.js (revision 67122)
+++ chrome/browser/resources/new_new_tab.js (working copy)
@@ -794,7 +794,17 @@
var notificationTimeout;
-function showNotification(text, actionText, opt_f, opt_delay) {
+/*
+ * Displays a message (either a string or a document fragment) in the
+ * notification slot at the top of the NTP.
+ * @param {string|Node} message String or node to use as message.
+ * @param {string} actionText The text to show as a link next to the message.
+ * @param {function=} opt_f Function to call when the user clicks the action
+ * link.
+ * @param {number=} opt_delay The time in milliseconds before hiding the
+ * i notification.
+ */
+function showNotification(message, actionText, opt_f, opt_delay) {
var notificationElement = $('notification');
var f = opt_f || function() {};
var delay = opt_delay || 10000;
@@ -814,11 +824,20 @@
hideNotification();
}
- // Remove any possible first-run trails.
+ // Remove classList entries from previous notifications.
notification.classList.remove('first-run');
+ notification.classList.remove('promo');
+ var notificationNode = notificationElement.firstElementChild;
+ notificationNode.removeChild(notificationNode.firstChild);
+
var actionLink = notificationElement.querySelector('.link-color');
- notificationElement.firstElementChild.textContent = text;
+
+ if (typeof message == 'string')
+ notificationElement.firstElementChild.textContent = message;
+ else
+ notificationElement.firstElementChild.appendChild(message);
+
actionLink.textContent = actionText;
actionLink.onclick = doAction;
@@ -859,6 +878,15 @@
notification.classList.add('first-run');
}
+function showPromoNotification() {
+ showNotification(parseHtmlSubset(localStrings.getString('serverpromo')),
+ localStrings.getString('closefirstrunnotification'),
+ function () { chrome.send('closePromo'); },
+ 60000);
+ var notificationElement = $('notification');
+ notification.classList.add('promo');
+}
+
$('main').addEventListener('click', function(e) {
var p = e.target;
while (p && p.tagName != 'H2') {
@@ -1190,6 +1218,8 @@
// Only show the first run notification if first run.
if (firstRun) {
showFirstRunNotification();
+ } else if (localStrings.getString('serverpromo')) {
+ showPromoNotification();
}
}
« no previous file with comments | « chrome/browser/resources/new_new_tab.css ('k') | chrome/browser/web_resource/web_resource_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698