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

Side by Side Diff: remoting/webapp/base/js/auth_init.js

Issue 742473002: [Chromoting] Break up the webapp's init function into smaller chunks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix browsertest break by removing onload handler Created 6 years 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 unified diff | Download patch
« no previous file with comments | « remoting/remoting_webapp_files.gypi ('k') | remoting/webapp/crd/js/crd_main.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 'use strict';
6
7 /** @suppress {duplicate} */
8 var remoting = remoting || {};
9
10 remoting.initIdentity = function() {
11
12 /**
13 * Show the authorization consent UI and register a one-shot event handler to
14 * continue the authorization process.
15 *
16 * @param {function():void} authContinue Callback to invoke when the user
17 * clicks "Continue".
18 */
19 function promptForConsent(authContinue) {
20 /** @type {HTMLElement} */
21 var dialog = document.getElementById('auth-dialog');
22 /** @type {HTMLElement} */
23 var button = document.getElementById('auth-button');
24 var consentGranted = function(event) {
25 dialog.hidden = true;
26 button.removeEventListener('click', consentGranted, false);
27 authContinue();
28 remoting.windowShape.updateClientWindowShape();
29 };
30 dialog.hidden = false;
31
32 /** @type {HTMLElement} */
33 var dialog_border = document.getElementById('auth-dialog-border');
34 remoting.authDialog = new remoting.AuthDialog(dialog_border);
35 remoting.windowShape.addCallback(remoting.authDialog);
36
37 button.addEventListener('click', consentGranted, false);
38 }
39
40 if (base.isAppsV2()) {
41 remoting.identity = new remoting.Identity(promptForConsent);
42 } else {
43 // TODO(garykac) Remove this and replace with identity.
44 remoting.oauth2 = new remoting.OAuth2();
45 if (!remoting.oauth2.isAuthenticated()) {
46 document.getElementById('auth-dialog').hidden = false;
47 }
48 remoting.identity = remoting.oauth2;
49 }
50 }
51
52 /** @param {remoting.Error} error */
53 remoting.onGetIdentityInfoError = function(error) {
54 // No need to show the error message for NOT_AUTHENTICATED
55 // because we will show "auth-dialog".
56 if (error != remoting.Error.NOT_AUTHENTICATED) {
57 remoting.showErrorMessage(error);
58 }
59 }
60
61 /**
62 * @param {function(string):void} onEmailAvailable Callback invoked when the
63 * email address is available.
64 * @return {void} Nothing.
65 */
66 remoting.initIdentityEmail = function(onEmailAvailable) {
67 remoting.identity.getEmail(onEmailAvailable,
68 remoting.onGetIdentityInfoError);
69 }
70
71 /**
72 * Get the user's email address and full name.
73 *
74 * @param {function(string,string):void} onUserInfoAvailable Callback invoked
75 * when the user's email address and full name are available.
76 * @return {void} Nothing.
77 */
78 remoting.initIdentityUserInfo = function(onUserInfoAvailable) {
79 remoting.identity.getUserInfo(onUserInfoAvailable,
80 remoting.onGetIdentityInfoError);
81 }
OLDNEW
« no previous file with comments | « remoting/remoting_webapp_files.gypi ('k') | remoting/webapp/crd/js/crd_main.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698