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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
110 notificationContainer = getRequiredElement('notification-container'); | 110 notificationContainer = getRequiredElement('notification-container'); |
111 notificationContainer.addEventListener( | 111 notificationContainer.addEventListener( |
112 'webkitTransitionEnd', onNotificationTransitionEnd); | 112 'webkitTransitionEnd', onNotificationTransitionEnd); |
113 | 113 |
114 cr.ui.decorate($('recently-closed-menu-button'), ntp.RecentMenuButton); | 114 cr.ui.decorate($('recently-closed-menu-button'), ntp.RecentMenuButton); |
115 chrome.send('getRecentlyClosedTabs'); | 115 chrome.send('getRecentlyClosedTabs'); |
116 | 116 |
117 if (templateData.showOtherSessionsMenu) { | 117 if (templateData.showOtherSessionsMenu) { |
118 cr.ui.decorate($('other-sessions-menu-button'), | 118 cr.ui.decorate($('other-sessions-menu-button'), |
119 ntp.OtherSessionsMenuButton); | 119 ntp.OtherSessionsMenuButton); |
120 $('other-sessions-menu-button').initialize(templateData.isUserSignedIn); | |
Dan Beam
2012/03/26 23:18:54
any reason you're not assigning this getElementByI
Patrick Dubroy
2012/03/26 23:46:07
Done.
| |
120 } | 121 } |
121 | 122 |
122 var mostVisited = new ntp.MostVisitedPage(); | 123 var mostVisited = new ntp.MostVisitedPage(); |
123 // Move the footer into the most visited page if we are in "bare minimum" | 124 // Move the footer into the most visited page if we are in "bare minimum" |
124 // mode. | 125 // mode. |
125 if (document.body.classList.contains('bare-minimum')) | 126 if (document.body.classList.contains('bare-minimum')) |
126 mostVisited.appendFooter(getRequiredElement('footer')); | 127 mostVisited.appendFooter(getRequiredElement('footer')); |
127 newTabView.appendTilePage(mostVisited, | 128 newTabView.appendTilePage(mostVisited, |
128 localStrings.getString('mostvisited'), | 129 localStrings.getString('mostvisited'), |
129 false); | 130 false); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
209 /^data\:image\/(?:png|gif|jpe?g)/.test(value); | 210 /^data\:image\/(?:png|gif|jpe?g)/.test(value); |
210 }, | 211 }, |
211 }; | 212 }; |
212 showNotification(parseHtmlSubset(promo, tags, attrs), [], function() { | 213 showNotification(parseHtmlSubset(promo, tags, attrs), [], function() { |
213 chrome.send('closeNotificationPromo'); | 214 chrome.send('closeNotificationPromo'); |
214 }, 60000); | 215 }, 60000); |
215 chrome.send('notificationPromoViewed'); | 216 chrome.send('notificationPromoViewed'); |
216 } | 217 } |
217 | 218 |
218 var loginContainer = getRequiredElement('login-container'); | 219 var loginContainer = getRequiredElement('login-container'); |
219 loginContainer.addEventListener('click', function() { | 220 loginContainer.addEventListener('click', showSyncLoginUI); |
220 var rect = loginContainer.getBoundingClientRect(); | |
221 chrome.send('showSyncLoginUI', | |
222 [rect.left, rect.top, rect.width, rect.height]); | |
223 }); | |
224 chrome.send('initializeSyncLogin'); | 221 chrome.send('initializeSyncLogin'); |
225 | 222 |
226 doWhenAllSectionsReady(function() { | 223 doWhenAllSectionsReady(function() { |
227 // Tell the slider about the pages. | 224 // Tell the slider about the pages. |
228 newTabView.updateSliderCards(); | 225 newTabView.updateSliderCards(); |
229 // Mark the current page. | 226 // Mark the current page. |
230 newTabView.cardSlider.currentCardValue.navigationDot.classList.add( | 227 newTabView.cardSlider.currentCardValue.navigationDot.classList.add( |
231 'selected'); | 228 'selected'); |
232 | 229 |
233 document.documentElement.classList.remove('starting-up'); | 230 document.documentElement.classList.remove('starting-up'); |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
490 node.stripeColor = color; | 487 node.stripeColor = color; |
491 } | 488 } |
492 | 489 |
493 /** | 490 /** |
494 * Updates the text displayed in the login container. If there is no text then | 491 * Updates the text displayed in the login container. If there is no text then |
495 * the login container is hidden. | 492 * the login container is hidden. |
496 * @param {string} loginHeader The first line of text. | 493 * @param {string} loginHeader The first line of text. |
497 * @param {string} loginSubHeader The second line of text. | 494 * @param {string} loginSubHeader The second line of text. |
498 * @param {string} iconURL The url for the login status icon. If this is null | 495 * @param {string} iconURL The url for the login status icon. If this is null |
499 then the login status icon is hidden. | 496 then the login status icon is hidden. |
497 * @param {boolean} isUserSignedIn Indicates if the user is signed in or not. | |
500 */ | 498 */ |
501 function updateLogin(loginHeader, loginSubHeader, iconURL) { | 499 function updateLogin(loginHeader, loginSubHeader, iconURL, isUserSignedIn) { |
502 if (loginHeader || loginSubHeader) { | 500 if (loginHeader || loginSubHeader) { |
503 $('login-container').hidden = false; | 501 $('login-container').hidden = false; |
504 $('login-status-header').innerHTML = loginHeader; | 502 $('login-status-header').innerHTML = loginHeader; |
505 $('login-status-sub-header').innerHTML = loginSubHeader; | 503 $('login-status-sub-header').innerHTML = loginSubHeader; |
506 $('card-slider-frame').classList.add('showing-login-area'); | 504 $('card-slider-frame').classList.add('showing-login-area'); |
507 | 505 |
508 if (iconURL) { | 506 if (iconURL) { |
509 $('login-status-header-container').style.backgroundImage = url(iconURL); | 507 $('login-status-header-container').style.backgroundImage = url(iconURL); |
510 $('login-status-header-container').classList.add('login-status-icon'); | 508 $('login-status-header-container').classList.add('login-status-icon'); |
511 } else { | 509 } else { |
512 $('login-status-header-container').style.backgroundImage = 'none'; | 510 $('login-status-header-container').style.backgroundImage = 'none'; |
513 $('login-status-header-container').classList.remove( | 511 $('login-status-header-container').classList.remove( |
514 'login-status-icon'); | 512 'login-status-icon'); |
515 } | 513 } |
516 } else { | 514 } else { |
517 $('login-container').hidden = true; | 515 $('login-container').hidden = true; |
518 $('card-slider-frame').classList.remove('showing-login-area'); | 516 $('card-slider-frame').classList.remove('showing-login-area'); |
519 } | 517 } |
520 if (shouldShowLoginBubble) { | 518 if (shouldShowLoginBubble) { |
521 window.setTimeout(loginBubble.show.bind(loginBubble), 0); | 519 window.setTimeout(loginBubble.show.bind(loginBubble), 0); |
522 chrome.send('loginMessageSeen'); | 520 chrome.send('loginMessageSeen'); |
523 shouldShowLoginBubble = false; | 521 shouldShowLoginBubble = false; |
524 } else if (loginBubble) { | 522 } else if (loginBubble) { |
525 loginBubble.reposition(); | 523 loginBubble.reposition(); |
526 } | 524 } |
525 $('other-sessions-menu-button').updateSignInState(isUserSignedIn); | |
527 } | 526 } |
528 | 527 |
529 /** | 528 /** |
529 * Show the sync login UI. | |
530 * @param {Event} e The click event. | |
531 */ | |
532 function showSyncLoginUI(e) { | |
533 var rect = e.currentTarget.getBoundingClientRect(); | |
534 chrome.send('showSyncLoginUI', | |
535 [rect.left, rect.top, rect.width, rect.height]); | |
536 } | |
537 | |
538 /** | |
530 * Wrappers to forward the callback to corresponding PageListView member. | 539 * Wrappers to forward the callback to corresponding PageListView member. |
531 */ | 540 */ |
532 function appAdded() { | 541 function appAdded() { |
533 return newTabView.appAdded.apply(newTabView, arguments); | 542 return newTabView.appAdded.apply(newTabView, arguments); |
534 } | 543 } |
535 | 544 |
536 function appMoved() { | 545 function appMoved() { |
537 return newTabView.appMoved.apply(newTabView, arguments); | 546 return newTabView.appMoved.apply(newTabView, arguments); |
538 } | 547 } |
539 | 548 |
540 function appRemoved() { | 549 function appRemoved() { |
541 return newTabView.appRemoved.apply(newTabView, arguments); | 550 return newTabView.appRemoved.apply(newTabView, arguments); |
542 } | 551 } |
543 | 552 |
544 function appsPrefChangeCallback() { | 553 function appsPrefChangeCallback() { |
545 return newTabView.appsPrefChangedCallback.apply(newTabView, arguments); | 554 return newTabView.appsPrefChangedCallback.apply(newTabView, arguments); |
546 } | 555 } |
547 | 556 |
548 function appsReordered() { | 557 function appsReordered() { |
549 return newTabView.appsReordered.apply(newTabView, arguments); | 558 return newTabView.appsReordered.apply(newTabView, arguments); |
550 } | 559 } |
551 | 560 |
552 function enterRearrangeMode() { | 561 function enterRearrangeMode() { |
553 return newTabView.enterRearrangeMode.apply(newTabView, arguments); | 562 return newTabView.enterRearrangeMode.apply(newTabView, arguments); |
554 } | 563 } |
555 | 564 |
556 function foreignSessions(sessionList) { | 565 function foreignSessions(sessionList, isTabSyncEnabled) { |
Dan Beam
2012/03/26 23:18:54
nit: this should probably be named getForeignSessi
Patrick Dubroy
2012/03/27 00:36:51
Done.
| |
557 $('other-sessions-menu-button').sessions = sessionList; | 566 $('other-sessions-menu-button').setForeignSessions(sessionList, |
567 isTabSyncEnabled); | |
558 } | 568 } |
559 | 569 |
560 function getAppsCallback() { | 570 function getAppsCallback() { |
561 return newTabView.getAppsCallback.apply(newTabView, arguments); | 571 return newTabView.getAppsCallback.apply(newTabView, arguments); |
562 } | 572 } |
563 | 573 |
564 function getAppsPageIndex() { | 574 function getAppsPageIndex() { |
565 return newTabView.getAppsPageIndex.apply(newTabView, arguments); | 575 return newTabView.getAppsPageIndex.apply(newTabView, arguments); |
566 } | 576 } |
567 | 577 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
601 setSuggestionsPages: setSuggestionsPages, | 611 setSuggestionsPages: setSuggestionsPages, |
602 setRecentlyClosedTabs: setRecentlyClosedTabs, | 612 setRecentlyClosedTabs: setRecentlyClosedTabs, |
603 setStripeColor: setStripeColor, | 613 setStripeColor: setStripeColor, |
604 showNotification: showNotification, | 614 showNotification: showNotification, |
605 themeChanged: themeChanged, | 615 themeChanged: themeChanged, |
606 updateLogin: updateLogin | 616 updateLogin: updateLogin |
607 }; | 617 }; |
608 }); | 618 }); |
609 | 619 |
610 document.addEventListener('DOMContentLoaded', ntp.onLoad); | 620 document.addEventListener('DOMContentLoaded', ntp.onLoad); |
OLD | NEW |