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

Side by Side Diff: chrome/browser/resources/ntp4/new_tab.js

Issue 10911196: Support for ntp promo bubble. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: allow BR in parseHtmlSubset Created 8 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/ui/webui/ntp/new_tab_page_handler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 13 matching lines...) Expand all
24 * @type {!Element|undefined} 24 * @type {!Element|undefined}
25 */ 25 */
26 var notificationContainer; 26 var notificationContainer;
27 27
28 /** 28 /**
29 * If non-null, an info bubble for showing messages to the user. It points at 29 * If non-null, an info bubble for showing messages to the user. It points at
30 * the Most Visited label, and is used to draw more attention to the 30 * the Most Visited label, and is used to draw more attention to the
31 * navigation dot UI. 31 * navigation dot UI.
32 * @type {!Element|undefined} 32 * @type {!Element|undefined}
33 */ 33 */
34 var infoBubble; 34 var promoBubble;
35 35
36 /** 36 /**
37 * If non-null, an bubble confirming that the user has signed into sync. It 37 * If non-null, an bubble confirming that the user has signed into sync. It
38 * points at the login status at the top of the page. 38 * points at the login status at the top of the page.
39 * @type {!Element|undefined} 39 * @type {!Element|undefined}
40 */ 40 */
41 var loginBubble; 41 var loginBubble;
42 42
43 /** 43 /**
44 * true if |loginBubble| should be shown. 44 * true if |loginBubble| should be shown.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 pageSwitcherStart, pageSwitcherEnd); 91 pageSwitcherStart, pageSwitcherEnd);
92 } 92 }
93 93
94 NewTabView.prototype = { 94 NewTabView.prototype = {
95 __proto__: ntp.PageListView.prototype, 95 __proto__: ntp.PageListView.prototype,
96 96
97 /** @inheritDoc */ 97 /** @inheritDoc */
98 appendTilePage: function(page, title, titleIsEditable, opt_refNode) { 98 appendTilePage: function(page, title, titleIsEditable, opt_refNode) {
99 ntp.PageListView.prototype.appendTilePage.apply(this, arguments); 99 ntp.PageListView.prototype.appendTilePage.apply(this, arguments);
100 100
101 if (infoBubble) 101 if (promoBubble)
102 window.setTimeout(infoBubble.reposition.bind(infoBubble), 0); 102 window.setTimeout(promoBubble.reposition.bind(promoBubble), 0);
103 } 103 }
104 }; 104 };
105 105
106 /** 106 /**
107 * Invoked at startup once the DOM is available to initialize the app. 107 * Invoked at startup once the DOM is available to initialize the app.
108 */ 108 */
109 function onLoad() { 109 function onLoad() {
110 sectionsToWaitFor = loadTimeData.getBoolean('showApps') ? 2 : 1; 110 sectionsToWaitFor = loadTimeData.getBoolean('showApps') ? 2 : 1;
111 if (loadTimeData.getBoolean('isDiscoveryInNTPEnabled')) 111 if (loadTimeData.getBoolean('isDiscoveryInNTPEnabled'))
112 sectionsToWaitFor++; 112 sectionsToWaitFor++;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 $('login-status-dismiss').onclick = loginBubble.hide.bind(loginBubble); 176 $('login-status-dismiss').onclick = loginBubble.hide.bind(loginBubble);
177 177
178 var bubbleContent = $('login-status-bubble-contents'); 178 var bubbleContent = $('login-status-bubble-contents');
179 loginBubble.content = bubbleContent; 179 loginBubble.content = bubbleContent;
180 180
181 // The anchor node won't be updated until updateLogin is called so don't 181 // The anchor node won't be updated until updateLogin is called so don't
182 // show the bubble yet. 182 // show the bubble yet.
183 shouldShowLoginBubble = true; 183 shouldShowLoginBubble = true;
184 } 184 }
185 185
186 if (loadTimeData.valueExists('bubblePromoText')) {
187 promoBubble = new cr.ui.Bubble;
188 promoBubble.anchorNode = getRequiredElement('logo-img');
189 promoBubble.setArrowLocation(cr.ui.ArrowLocation.BOTTOM_START);
190 promoBubble.bubbleAlignment =
191 cr.ui.BubbleAlignment.BUBBLE_EDGE_TO_ANCHOR_EDGE;
192 promoBubble.deactivateToDismissDelay = 2000;
193 promoBubble.content = parseHtmlSubset(loadTimeData.getString(
194 'bubblePromoText'), ['BR']);
195 promoBubble.handleCloseEvent = function() {
196 promoBubble.hide();
197 chrome.send('bubblePromoClosed');
198 };
199 promoBubble.show();
200 chrome.send('bubblePromoViewed');
201 }
202
186 var loginContainer = getRequiredElement('login-container'); 203 var loginContainer = getRequiredElement('login-container');
187 loginContainer.addEventListener('click', showSyncLoginUI); 204 loginContainer.addEventListener('click', showSyncLoginUI);
188 chrome.send('initializeSyncLogin'); 205 chrome.send('initializeSyncLogin');
189 206
190 doWhenAllSectionsReady(function() { 207 doWhenAllSectionsReady(function() {
191 // Tell the slider about the pages. 208 // Tell the slider about the pages.
192 newTabView.updateSliderCards(); 209 newTabView.updateSliderCards();
193 // Mark the current page. 210 // Mark the current page.
194 newTabView.cardSlider.currentCardValue.navigationDot.classList.add( 211 newTabView.cardSlider.currentCardValue.navigationDot.classList.add(
195 'selected'); 212 'selected');
196 213
197 if (loadTimeData.valueExists('serverpromo')) { 214 if (loadTimeData.valueExists('notificationPromoText')) {
198 var promo = loadTimeData.getString('serverpromo'); 215 var promo = loadTimeData.getString('notificationPromoText');
199 var tags = ['IMG']; 216 var tags = ['IMG'];
200 var attrs = { 217 var attrs = {
201 src: function(node, value) { 218 src: function(node, value) {
202 return node.tagName == 'IMG' && 219 return node.tagName == 'IMG' &&
203 /^data\:image\/(?:png|gif|jpe?g)/.test(value); 220 /^data\:image\/(?:png|gif|jpe?g)/.test(value);
204 }, 221 },
205 }; 222 };
206 showNotification(parseHtmlSubset(promo, tags, attrs), [], function() { 223 showNotification(parseHtmlSubset(promo, tags, attrs), [], function() {
207 chrome.send('closeNotificationPromo'); 224 chrome.send('notificationPromoClosed');
208 }, 60000); 225 }, 60000);
209 chrome.send('notificationPromoViewed'); 226 chrome.send('notificationPromoViewed');
210 } 227 }
211 228
212 cr.dispatchSimpleEvent(document, 'ntpLoaded', true, true); 229 cr.dispatchSimpleEvent(document, 'ntpLoaded', true, true);
213 document.documentElement.classList.remove('starting-up'); 230 document.documentElement.classList.remove('starting-up');
214 }); 231 });
215 232
216 preventDefaultOnPoundLinkClicks(); // From shared/js/util.js. 233 preventDefaultOnPoundLinkClicks(); // From shared/js/util.js.
217 } 234 }
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 setFaviconDominantColor: setFaviconDominantColor, 605 setFaviconDominantColor: setFaviconDominantColor,
589 showNotification: showNotification, 606 showNotification: showNotification,
590 themeChanged: themeChanged, 607 themeChanged: themeChanged,
591 updateLogin: updateLogin 608 updateLogin: updateLogin
592 }; 609 };
593 }); 610 });
594 611
595 document.addEventListener('DOMContentLoaded', ntp.onLoad); 612 document.addEventListener('DOMContentLoaded', ntp.onLoad);
596 613
597 var toCssPx = cr.ui.toCssPx; 614 var toCssPx = cr.ui.toCssPx;
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/webui/ntp/new_tab_page_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698