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

Unified Diff: chrome/browser/resources/ntp4/new_tab.js

Issue 9838064: Add a sign-in promo message to the Other Devices menu. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address previously-unaddressed nits. Created 8 years, 9 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 side-by-side diff with in-line comments
Download patch
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..ebffb7eee51b6216a293810d176c520770845ec4 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,10 @@ 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)
Dan Beam 2012/03/27 01:21:06 nit: curlies
Patrick Dubroy 2012/03/27 13:44:21 Done.
+ return otherSessionsButton.setForeignSessions(sessionList,
+ isTabSyncEnabled);
}
function getAppsCallback() {
@@ -588,7 +606,6 @@ cr.define('ntp', function() {
appRemoved: appRemoved,
appsPrefChangeCallback: appsPrefChangeCallback,
enterRearrangeMode: enterRearrangeMode,
- foreignSessions: foreignSessions,
getAppsCallback: getAppsCallback,
getAppsPageIndex: getAppsPageIndex,
getCardSlider: getCardSlider,
@@ -597,6 +614,7 @@ cr.define('ntp', function() {
saveAppPageName: saveAppPageName,
setAppToBeHighlighted: setAppToBeHighlighted,
setBookmarkBarAttached: setBookmarkBarAttached,
+ setForeignSessions: setForeignSessions,
Dan Beam 2012/03/27 01:21:06 I mentioned getForeignSessions, but I guess this i
Patrick Dubroy 2012/03/27 13:44:21 Yeah, I saw what you wrote but getForeignSessions
setMostVisitedPages: setMostVisitedPages,
setSuggestionsPages: setSuggestionsPages,
setRecentlyClosedTabs: setRecentlyClosedTabs,

Powered by Google App Engine
This is Rietveld 408576698