Chromium Code Reviews| Index: chrome/browser/resources/ntp4/new_tab.js |
| diff --git a/chrome/browser/resources/ntp4/new_tab.js b/chrome/browser/resources/ntp4/new_tab.js |
| index eef19f37bf44a60bd41ac3f3e88b106df83ab6a0..70fdf54add69871b6128751a80d3ee524ffd3491 100644 |
| --- a/chrome/browser/resources/ntp4/new_tab.js |
| +++ b/chrome/browser/resources/ntp4/new_tab.js |
| @@ -53,6 +53,12 @@ cr.define('ntp', function() { |
| var shouldShowLoginBubble = false; |
| /** |
| + * The 'other-sessions-menu-button' element. |
| + * @type {!Element|undefined} |
| + */ |
| + var otherSessionsButton; |
| + |
| + /** |
| * The time in milliseconds for most transitions. This should match what's |
| * in new_tab.css. Unfortunately there's no better way to try to time |
| * something to occur until after a transition has completed. |
| @@ -115,8 +121,9 @@ cr.define('ntp', function() { |
| chrome.send('getRecentlyClosedTabs'); |
| if (templateData.showOtherSessionsMenu) { |
| - cr.ui.decorate($('other-sessions-menu-button'), |
| - ntp.OtherSessionsMenuButton); |
| + otherSessionsButton = getRequiredElement('other-sessions-menu-button'); |
| + cr.ui.decorate(otherSessionsButton, ntp.OtherSessionsMenuButton); |
| + otherSessionsButton.initialize(templateData.isUserSignedIn); |
| } |
| var mostVisited = new ntp.MostVisitedPage(); |
| @@ -216,11 +223,7 @@ cr.define('ntp', function() { |
| } |
| var loginContainer = getRequiredElement('login-container'); |
| - loginContainer.addEventListener('click', function() { |
| - var rect = loginContainer.getBoundingClientRect(); |
| - chrome.send('showSyncLoginUI', |
| - [rect.left, rect.top, rect.width, rect.height]); |
| - }); |
| + loginContainer.addEventListener('click', showSyncLoginUI); |
| chrome.send('initializeSyncLogin'); |
| doWhenAllSectionsReady(function() { |
| @@ -497,8 +500,9 @@ cr.define('ntp', function() { |
| * @param {string} loginSubHeader The second line of text. |
| * @param {string} iconURL The url for the login status icon. If this is null |
| then the login status icon is hidden. |
| + * @param {boolean} isUserSignedIn Indicates if the user is signed in or not. |
| */ |
| - function updateLogin(loginHeader, loginSubHeader, iconURL) { |
| + function updateLogin(loginHeader, loginSubHeader, iconURL, isUserSignedIn) { |
| if (loginHeader || loginSubHeader) { |
| $('login-container').hidden = false; |
| $('login-status-header').innerHTML = loginHeader; |
| @@ -524,6 +528,18 @@ cr.define('ntp', function() { |
| } else if (loginBubble) { |
| loginBubble.reposition(); |
| } |
| + if (otherSessionsButton) |
| + otherSessionsButton.updateSignInState(isUserSignedIn); |
| + } |
| + |
| + /** |
| + * Show the sync login UI. |
| + * @param {Event} e The click event. |
| + */ |
| + function showSyncLoginUI(e) { |
| + var rect = e.currentTarget.getBoundingClientRect(); |
| + chrome.send('showSyncLoginUI', |
| + [rect.left, rect.top, rect.width, rect.height]); |
| } |
| /** |
| @@ -553,8 +569,11 @@ cr.define('ntp', function() { |
| return newTabView.enterRearrangeMode.apply(newTabView, arguments); |
| } |
| - function foreignSessions(sessionList) { |
| - $('other-sessions-menu-button').sessions = sessionList; |
| + function setForeignSessions(sessionList, isTabSyncEnabled) { |
| + if (otherSessionsButton) { |
| + return otherSessionsButton.setForeignSessions(sessionList, |
|
Evan Stade
2012/03/27 18:20:20
looks weird to have a return statement in one case
Patrick Dubroy
2012/03/27 20:06:19
Ok, I've removed it here. There is no meaningful r
|
| + isTabSyncEnabled); |
| + } |
| } |
| function getAppsCallback() { |
| @@ -588,7 +607,6 @@ cr.define('ntp', function() { |
| appRemoved: appRemoved, |
| appsPrefChangeCallback: appsPrefChangeCallback, |
| enterRearrangeMode: enterRearrangeMode, |
| - foreignSessions: foreignSessions, |
| getAppsCallback: getAppsCallback, |
| getAppsPageIndex: getAppsPageIndex, |
| getCardSlider: getCardSlider, |
| @@ -597,6 +615,7 @@ cr.define('ntp', function() { |
| saveAppPageName: saveAppPageName, |
| setAppToBeHighlighted: setAppToBeHighlighted, |
| setBookmarkBarAttached: setBookmarkBarAttached, |
| + setForeignSessions: setForeignSessions, |
| setMostVisitedPages: setMostVisitedPages, |
| setSuggestionsPages: setSuggestionsPages, |
| setRecentlyClosedTabs: setRecentlyClosedTabs, |