OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @fileoverview New tab page | 6 * @fileoverview New tab page |
7 * This is the main code for the new tab page used by touch-enabled Chrome | 7 * This is the main code for the new tab page used by touch-enabled Chrome |
8 * browsers. For now this is still a prototype. | 8 * browsers. For now this is still a prototype. |
9 */ | 9 */ |
10 | 10 |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 chrome.send('initializeSyncLogin'); | 220 chrome.send('initializeSyncLogin'); |
221 | 221 |
222 doWhenAllSectionsReady(function() { | 222 doWhenAllSectionsReady(function() { |
223 // Tell the slider about the pages. | 223 // Tell the slider about the pages. |
224 newTabView.updateSliderCards(); | 224 newTabView.updateSliderCards(); |
225 // Mark the current page. | 225 // Mark the current page. |
226 newTabView.cardSlider.currentCardValue.navigationDot.classList.add( | 226 newTabView.cardSlider.currentCardValue.navigationDot.classList.add( |
227 'selected'); | 227 'selected'); |
228 | 228 |
229 if (loadTimeData.valueExists('notificationPromoText')) { | 229 if (loadTimeData.valueExists('notificationPromoText')) { |
230 var promo = loadTimeData.getString('notificationPromoText'); | 230 var promoText = loadTimeData.getString('notificationPromoText'); |
231 var tags = ['IMG']; | 231 var tags = ['IMG']; |
232 var attrs = { | 232 var attrs = { |
233 src: function(node, value) { | 233 src: function(node, value) { |
234 return node.tagName == 'IMG' && | 234 return node.tagName == 'IMG' && |
235 /^data\:image\/(?:png|gif|jpe?g)/.test(value); | 235 /^data\:image\/(?:png|gif|jpe?g)/.test(value); |
236 }, | 236 }, |
237 }; | 237 }; |
238 showNotification(parseHtmlSubset(promo, tags, attrs), [], function() { | 238 |
| 239 var promo = parseHtmlSubset(promoText, tags, attrs); |
| 240 var promoLink = promo.querySelector('a'); |
| 241 if (promoLink) { |
| 242 promoLink.addEventListener('click', function(e) { |
| 243 chrome.send('notificationPromoLinkClicked'); |
| 244 }); |
| 245 } |
| 246 |
| 247 showNotification(promo, [], function() { |
239 chrome.send('notificationPromoClosed'); | 248 chrome.send('notificationPromoClosed'); |
240 }, 60000); | 249 }, 60000); |
241 chrome.send('notificationPromoViewed'); | 250 chrome.send('notificationPromoViewed'); |
242 } | 251 } |
243 | 252 |
244 cr.dispatchSimpleEvent(document, 'ntpLoaded', true, true); | 253 cr.dispatchSimpleEvent(document, 'ntpLoaded', true, true); |
245 document.documentElement.classList.remove('starting-up'); | 254 document.documentElement.classList.remove('starting-up'); |
246 | 255 |
247 startTime = Date.now(); | 256 startTime = Date.now(); |
248 }); | 257 }); |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 setFaviconDominantColor: setFaviconDominantColor, | 642 setFaviconDominantColor: setFaviconDominantColor, |
634 showNotification: showNotification, | 643 showNotification: showNotification, |
635 themeChanged: themeChanged, | 644 themeChanged: themeChanged, |
636 updateLogin: updateLogin | 645 updateLogin: updateLogin |
637 }; | 646 }; |
638 }); | 647 }); |
639 | 648 |
640 document.addEventListener('DOMContentLoaded', ntp.onLoad); | 649 document.addEventListener('DOMContentLoaded', ntp.onLoad); |
641 | 650 |
642 var toCssPx = cr.ui.toCssPx; | 651 var toCssPx = cr.ui.toCssPx; |
OLD | NEW |