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

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: Remove auth-dialog code (from other cl) Created 6 years, 1 month 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
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 if (base.isAppsV2()) {
12 remoting.identity = new remoting.Identity(consentRequired_);
13 } else {
14 remoting.oauth2 = new remoting.OAuth2();
15 if (!remoting.oauth2.isAuthenticated()) {
16 document.getElementById('auth-dialog').hidden = false;
17 }
18 remoting.identity = remoting.oauth2;
19 }
20
21 /** @param {remoting.Error} error */
22 var onGetEmailError = function(error) {
23 // No need to show the error message for NOT_AUTHENTICATED
24 // because we will show "auth-dialog".
25 if (error != remoting.Error.NOT_AUTHENTICATED) {
26 remoting.showErrorMessage(error);
27 }
28 }
29 remoting.identity.getEmail(remoting.onEmail, onGetEmailError);
30 }
31
32 /**
33 * Display the user's email address and allow access to the rest of the app,
34 * including parsing URL parameters.
35 *
36 * @param {string} email The user's email address.
37 * @return {void} Nothing.
38 */
39 remoting.onEmail = function(email) {
40 document.getElementById('current-email').innerText = email;
41 document.getElementById('get-started-it2me').disabled = false;
42 document.getElementById('get-started-me2me').disabled = false;
43 };
44
45 /**
46 * Show the authorization consent UI and register a one-shot event handler to
47 * continue the authorization process.
48 *
49 * @param {function():void} authContinue Callback to invoke when the user
50 * clicks "Continue".
51 */
52 function consentRequired_(authContinue) {
53 /** @type {HTMLElement} */
54 var dialog = document.getElementById('auth-dialog');
55 /** @type {HTMLElement} */
56 var button = document.getElementById('auth-button');
57 var consentGranted = function(event) {
58 dialog.hidden = true;
59 button.removeEventListener('click', consentGranted, false);
60 authContinue();
61 remoting.windowShape.updateClientWindowShape();
62 };
63 dialog.hidden = false;
64
65 /** @type {HTMLElement} */
66 var dialog_border = document.getElementById('auth-dialog-border');
67 remoting.authDialog = new remoting.AuthDialog(dialog_border);
68 remoting.windowShape.addCallback(remoting.authDialog);
69
70 button.addEventListener('click', consentGranted, false);
71 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698