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..d16adfa48fc1294ed4f0cb5724ee5d79b9ffceff 100644 |
--- a/chrome/browser/resources/ntp4/new_tab.js |
+++ b/chrome/browser/resources/ntp4/new_tab.js |
@@ -97,6 +97,8 @@ cr.define('ntp', function() { |
* Invoked at startup once the DOM is available to initialize the app. |
*/ |
function onLoad() { |
+ var isUserSignedIn = Boolean( |
+ localStrings.getString('login_status_message')); |
Dan Beam
2012/03/23 21:12:47
Casting to Boolean() is a little different than ju
Patrick Dubroy
2012/03/26 15:16:46
What's the difference? According to the spec it sh
Dan Beam
2012/03/26 17:08:33
tl;dr casting or comparing to different types in J
|
cr.enablePlatformSpecificCSSRules(); |
sectionsToWaitFor = templateData.showApps ? 2 : 1; |
@@ -117,6 +119,8 @@ cr.define('ntp', function() { |
if (templateData.showOtherSessionsMenu) { |
cr.ui.decorate($('other-sessions-menu-button'), |
ntp.OtherSessionsMenuButton); |
+ $('other-sessions-menu-button').initialize( |
+ isUserSignedIn, showSyncLoginUI); |
} |
var mostVisited = new ntp.MostVisitedPage(); |
@@ -157,8 +161,7 @@ cr.define('ntp', function() { |
var url = appendParam(webstoreLink, 'utm_source', 'chrome-ntp-plus-icon'); |
$('app-install-hint-template').href = url; |
} |
- |
- if (localStrings.getString('login_status_message')) { |
+ if (isUserSignedIn) { |
Dan Beam
2012/03/23 21:12:47
I'd undo this.
Patrick Dubroy
2012/03/26 15:16:46
Done.
|
loginBubble = new cr.ui.Bubble; |
loginBubble.anchorNode = $('login-container'); |
loginBubble.setArrowLocation(cr.ui.ArrowLocation.TOP_END); |
@@ -216,10 +219,8 @@ 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', function(e) { |
+ showSyncLoginUI(this); |
Dan Beam
2012/03/23 21:12:47
can you change this to
loginContainer.addEventL
Patrick Dubroy
2012/03/26 19:36:46
Done.
|
}); |
chrome.send('initializeSyncLogin'); |
@@ -493,12 +494,13 @@ cr.define('ntp', function() { |
/** |
* Updates the text displayed in the login container. If there is no text then |
* the login container is hidden. |
+ * @param {Boolean} isUserSignedIn Indicates if the user is signed in or not. |
* @param {string} loginHeader The first line of text. |
* @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. |
*/ |
- function updateLogin(loginHeader, loginSubHeader, iconURL) { |
+ function updateLogin(isUserSignedIn, loginHeader, loginSubHeader, iconURL) { |
if (loginHeader || loginSubHeader) { |
$('login-container').hidden = false; |
$('login-status-header').innerHTML = loginHeader; |
@@ -524,6 +526,16 @@ cr.define('ntp', function() { |
} else if (loginBubble) { |
loginBubble.reposition(); |
} |
+ $('other-sessions-menu-button').updateSignInState(isUserSignedIn); |
+ } |
+ |
+ /** |
+ * Show the sync login UI. |element| is the element that triggered the login. |
Dan Beam
2012/03/23 21:12:47
doc param
Patrick Dubroy
2012/03/26 15:16:46
Done.
|
+ */ |
+ function showSyncLoginUI(element) { |
Dan Beam
2012/03/23 21:12:47
s/element/e/
var element = e.currentTarget;
Patrick Dubroy
2012/03/26 15:16:46
Done.
|
+ var rect = element.getBoundingClientRect(); |
+ chrome.send('showSyncLoginUI', |
+ [rect.left, rect.top, rect.width, rect.height]); |
} |
/** |