Chromium Code Reviews| Index: remoting/webapp/remoting.js |
| diff --git a/remoting/webapp/remoting.js b/remoting/webapp/remoting.js |
| index feda0ffec8e1efd2fd5516024a4d387fcbb23128..856c084bba7fa7b2afef2c381f518fd7ab876693 100644 |
| --- a/remoting/webapp/remoting.js |
| +++ b/remoting/webapp/remoting.js |
| @@ -29,6 +29,27 @@ remoting.Error = { |
| }; |
| /** |
| + * Show the consent UI and register a one-shot event handler to continue |
|
Wez
2013/01/07 23:52:44
nit: consent -> authorization consent
Jamie
2013/01/08 22:09:10
Done.
|
| + * the authorization process. |
| + * |
| + * @param {function():void} authContinue Callback to invoke when the user |
| + * clicks "Continue". |
| + */ |
| +function consentRequired_(authContinue) { |
| + /** @type {HTMLElement} */ |
| + var dialog = document.getElementById('auth-dialog'); |
| + /** @type {HTMLElement} */ |
| + var button = document.getElementById('auth-button'); |
| + var consentGranted = function(event) { |
| + dialog.hidden = true; |
| + button.removeEventListener('click', consentGranted, false); |
| + authContinue(); |
| + }; |
| + dialog.hidden = false; |
| + button.addEventListener('click', consentGranted, false); |
| +} |
| + |
| +/** |
| * Entry point for app initialization. |
| */ |
| remoting.init = function() { |
| @@ -39,6 +60,9 @@ remoting.init = function() { |
| l10n.localize(); |
| // Create global objects. |
| remoting.oauth2 = new remoting.OAuth2(); |
| + // TODO(jamiewalch): Reinstate this when we migrate to apps v2. |
|
Wez
2013/01/07 23:52:44
nit: Reference the v2 app bug.
Jamie
2013/01/08 22:09:10
Done, here and elsewhere.
|
| + // remoting.identity = new remoting.Identity(consentRequired_); |
| + remoting.identity = remoting.oauth2; |
| remoting.stats = new remoting.ConnectionStats( |
| document.getElementById('statistics')); |
| remoting.formatIq = new remoting.FormatIq(); |
| @@ -58,7 +82,7 @@ remoting.init = function() { |
| } |
| ); |
| - remoting.oauth2.getEmail(remoting.onEmail, remoting.showErrorMessage); |
| + remoting.identity.getEmail(remoting.onEmail, remoting.showErrorMessage); |
| remoting.showOrHideIt2MeUi(); |
| remoting.showOrHideMe2MeUi(); |
| @@ -113,7 +137,10 @@ remoting.initDaemonUi = function () { |
| remoting.hostController = new remoting.HostController(); |
| document.getElementById('share-button').disabled = |
| !remoting.hostController.isPluginSupported(); |
| - remoting.setMode(getAppStartupMode_()); |
| + remoting.setMode(remoting.AppMode.HOME); |
| + if (!remoting.oauth2.isAuthenticated()) { |
| + document.getElementById('auth-dialog').hidden = false; |
| + } |
| remoting.hostSetupDialog = |
| new remoting.HostSetupDialog(remoting.hostController); |
| // Display the cached host list, then asynchronously update and re-display it. |
| @@ -190,7 +217,8 @@ remoting.promptClose = function() { |
| remoting.signOut = function() { |
| remoting.oauth2.clear(); |
|
rmsousa
2013/01/05 05:21:11
What are we planning to do here for appsv2? experi
Wez
2013/01/07 23:52:44
Token revocation is much less critical in this cas
Jamie
2013/01/08 22:09:10
I think we'll eventually remove the option from th
|
| chrome.storage.local.clear(); |
| - remoting.setMode(remoting.AppMode.UNAUTHENTICATED); |
| + remoting.setMode(remoting.AppMode.HOME); |
| + document.getElementById('auth-dialog').hidden = false; |
| }; |
| /** |
| @@ -232,18 +260,6 @@ function pluginGotCopy_(eventUncast) { |
| } |
| /** |
| - * Gets the major-mode that this application should start up in. |
| - * |
| - * @return {remoting.AppMode} The mode to start in. |
| - */ |
| -function getAppStartupMode_() { |
| - if (!remoting.oauth2.isAuthenticated()) { |
| - return remoting.AppMode.UNAUTHENTICATED; |
| - } |
| - return remoting.AppMode.HOME; |
| -} |
| - |
| -/** |
| * Returns whether Host mode is supported on this platform. |
| * |
| * @return {boolean} True if Host mode is supported. |