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

Unified Diff: chrome/browser/resources/ntp4/new_tab.js

Issue 7672012: Support for promo in ntp4. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' 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
« no previous file with comments | « chrome/browser/resources/ntp4/new_tab.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/ntp4/new_tab.js
===================================================================
--- chrome/browser/resources/ntp4/new_tab.js (revision 97318)
+++ chrome/browser/resources/ntp4/new_tab.js (working copy)
@@ -207,6 +207,13 @@
bookmarksPage = new ntp4.BookmarksPage();
appendTilePage(bookmarksPage, localStrings.getString('bookmarksPage'));
chrome.send('getBookmarksData');
+
+ var serverpromo = localStrings.getString('serverpromo');
+ if (serverpromo) {
+ showNotification(parseHtmlSubset(serverpromo), [], function() {
+ chrome.send('closePromo');
+ }, 60000);
+ }
}
/**
@@ -637,7 +644,8 @@
/**
* Shows the notification bubble.
- * @param {string} text The notification message.
+ * @param {string|Node} message The notification message or node to use as
+ * message.
* @param {Array.<{text: string, action: function()}>} links An array of
* records describing the links in the notification. Each record should
* have a 'text' attribute (the display string) and an 'action' attribute
@@ -645,10 +653,17 @@
* @param {Function} opt_closeHandler The callback invoked if the user
* manually dismisses the notification.
*/
- function showNotification(text, links, opt_closeHandler) {
+ function showNotification(message, links, opt_closeHandler, opt_timeout) {
window.clearTimeout(notificationTimeout_);
- document.querySelector('#notification > span').textContent = text;
+ var span = document.querySelector('#notification > span');
+ if (typeof message == 'string') {
+ span.textContent = message;
+ } else {
+ span.textContent = ''; // Remove all children.
+ span.appendChild(message);
+ }
+
var linksBin = $('notificationLinks');
linksBin.textContent = '';
for (var i = 0; i < links.length; i++) {
@@ -671,8 +686,9 @@
hideNotification();
};
+ var timeout = opt_timeout || 10000;
$('notification').classList.remove('inactive');
- notificationTimeout_ = window.setTimeout(hideNotification, 10000);
+ notificationTimeout_ = window.setTimeout(hideNotification, timeout);
}
/**
« no previous file with comments | « chrome/browser/resources/ntp4/new_tab.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698