| 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 var chrome = chrome || {}; | 5 var chrome = chrome || {}; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Organizes all signin event listeners and asynchronous requests. | 8 * Organizes all signin event listeners and asynchronous requests. |
| 9 * This object has no public constructor. | 9 * This object has no public constructor. |
| 10 * @type {Object} | 10 * @type {Object} |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 } else { | 105 } else { |
| 106 console.error(e); | 106 console.error(e); |
| 107 } | 107 } |
| 108 } | 108 } |
| 109 } | 109 } |
| 110 }; | 110 }; |
| 111 | 111 |
| 112 // These are the events that will be registered. | 112 // These are the events that will be registered. |
| 113 chrome.signin.events = { | 113 chrome.signin.events = { |
| 114 'signin_manager': [ | 114 'signin_manager': [ |
| 115 'onSigninInfoChanged' | 115 'onSigninInfoChanged', |
| 116 'onCookieAccountsFetched' |
| 116 ] | 117 ] |
| 117 }; | 118 }; |
| 118 | 119 |
| 119 for (var eventType in chrome.signin.events) { | 120 for (var eventType in chrome.signin.events) { |
| 120 var events = chrome.signin.events[eventType]; | 121 var events = chrome.signin.events[eventType]; |
| 121 for (var i = 0; i < events.length; ++i) { | 122 for (var i = 0; i < events.length; ++i) { |
| 122 var event = events[i]; | 123 var event = events[i]; |
| 123 chrome.signin[event] = new Event(); | 124 chrome.signin[event] = new Event(); |
| 124 } | 125 } |
| 125 } | 126 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 | 165 |
| 165 // Replace the displayed values with the latest fetched ones. | 166 // Replace the displayed values with the latest fetched ones. |
| 166 function refreshSigninInfo(signinInfo) { | 167 function refreshSigninInfo(signinInfo) { |
| 167 chrome.signin.internalsInfo = signinInfo; | 168 chrome.signin.internalsInfo = signinInfo; |
| 168 var internalsInfoDiv = $('signin-info'); | 169 var internalsInfoDiv = $('signin-info'); |
| 169 jstProcess(new JsEvalContext(signinInfo), internalsInfoDiv); | 170 jstProcess(new JsEvalContext(signinInfo), internalsInfoDiv); |
| 170 var tokenInfoDiv = $('token-info'); | 171 var tokenInfoDiv = $('token-info'); |
| 171 jstProcess(new JsEvalContext(signinInfo), tokenInfoDiv); | 172 jstProcess(new JsEvalContext(signinInfo), tokenInfoDiv); |
| 172 } | 173 } |
| 173 | 174 |
| 175 // Replace the cookie information with the fetched values. |
| 176 function updateCookieAccounts(cookieAccountsInfo) { |
| 177 var cookieInfoDiv = $('cookie-info'); |
| 178 jstProcess(new JsEvalContext(cookieAccountsInfo), cookieInfoDiv); |
| 179 } |
| 180 |
| 174 // On load, do an initial refresh and register refreshSigninInfo to be invoked | 181 // On load, do an initial refresh and register refreshSigninInfo to be invoked |
| 175 // whenever we get new signin information from SigninInternalsUI. | 182 // whenever we get new signin information from SigninInternalsUI. |
| 176 function onLoad() { | 183 function onLoad() { |
| 177 chrome.signin.getSigninInfo(refreshSigninInfo); | 184 chrome.signin.getSigninInfo(refreshSigninInfo); |
| 178 | 185 |
| 179 chrome.signin.onSigninInfoChanged.addListener(function(info) { | 186 chrome.signin.onSigninInfoChanged.addListener(function(info) { |
| 180 refreshSigninInfo(info); | 187 refreshSigninInfo(info); |
| 181 }); | 188 }); |
| 189 chrome.signin.onCookieAccountsFetched.addListener(function(info) { |
| 190 updateCookieAccounts(info); |
| 191 }); |
| 182 } | 192 } |
| 183 | 193 |
| 184 document.addEventListener('DOMContentLoaded', onLoad, false); | 194 document.addEventListener('DOMContentLoaded', onLoad, false); |
| 185 })(); | 195 })(); |
| OLD | NEW |