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

Side by Side Diff: web/inc/auth/auth-signin.html

Issue 2335223003: LogDog: Update web code, stream/query with auth. (Closed)
Patch Set: Fix background page loading. Created 4 years, 3 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 unified diff | Download patch
« no previous file with comments | « web/bower.json ('k') | web/inc/logdog-stream-view/logdog-stream-fetcher.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!-- 1 <!--
2 Copyright 2016 The LUCI Authors. All rights reserved. 2 Copyright 2016 The LUCI Authors. All rights reserved.
3 Use of this source code is governed under the Apache License, Version 2.0 3 Use of this source code is governed under the Apache License, Version 2.0
4 that can be found in the LICENSE file. 4 that can be found in the LICENSE file.
5 --> 5 -->
6 6
7 <link rel="import" href="../bower_components/polymer/polymer.html"> 7 <link rel="import" href="../bower_components/polymer/polymer.html">
8 <link rel="import" 8 <link rel="import"
9 href="../bower_components/google-signin/google-signin-aware.html"> 9 href="../bower_components/google-signin/google-signin-aware.html">
10 10
11 <!-- 11 <!--
12 The `auth-signin` element displays sign-in/sign-out button, user email and 12 The `auth-signin` element displays sign-in/sign-out button, user email and
13 avatar. 13 avatar.
14 --> 14 -->
15 <dom-module id="auth-signin"> 15 <dom-module id="auth-signin">
16 <template> 16 <template>
17 <style> 17 <style>
18 #avatar { 18 #avatar {
19 border-radius: 5px; 19 border-radius: 5px;
20 } 20 }
21 #signinContainer { 21 #signinContainer {
22 margin-top: 14px; 22 margin-top: 14px;
23 } 23 }
24 </style> 24 </style>
25 25
26 <google-signin-aware id="aware" 26 <google-signin-aware id="aware"
27 client-id="[[clientId]]"
28 scopes="email" 27 scopes="email"
29 on-google-signin-aware-success="_onSignin" 28 on-google-signin-aware-success="_onSignin"
30 on-google-signin-aware-signed-out="_onSignout" 29 on-google-signin-aware-signed-out="_onSignout"
31 ></google-signin-aware> 30 ></google-signin-aware>
32 31
33 <template is="dom-if" if="[[!signedIn]]"> 32 <template is="dom-if" if="[[!signedIn]]">
34 <div id="signinContainer"> 33 <div id="signinContainer">
35 <a on-tap="signIn" href="#">Sign in</a> 34 <a on-tap="signIn" href="#">Sign in</a>
36 </div> 35 </div>
37 </template> 36 </template>
(...skipping 14 matching lines...) Expand all
52 properties: { 51 properties: {
53 signedIn: { 52 signedIn: {
54 type: Boolean, 53 type: Boolean,
55 readOnly: true, 54 readOnly: true,
56 value: false 55 value: false
57 }, 56 },
58 57
59 profile: { 58 profile: {
60 type: Object, 59 type: Object,
61 readOnly: true 60 readOnly: true
61 },
62
63 clientId: {
64 type: String,
65 notify: true,
66 observer: '_clientIdChanged',
67 },
68 },
69
70 created: function() {
71 this._attached = false;
72 this._lastPushedClientId = null;
73 },
74
75 attached: function() {
76 this._attached = true;
77 this._pushClientId();
78 },
79
80 _clientIdChanged: function() {
81 this._pushClientId();
82 },
83
84 _pushClientId: function() {
85 // Set the client ID here explicitly rather than data-binding. If this
86 // page is loaded in the background, the "auth-signin-aware" AuthEngine
87 // will sign in before the <augh-signin-aware> elements actually attach.
88 // Consequently, they will never receive the sign-in success/fail event.
89 //
90 // By delaying the Client ID setting until the elements have all been
91 // attached, we ensure that they all receive the event as intended.
92 if (this._attached && (this.clientId != this._lastPushedClientId)) {
93 this.$.aware.clientId = this.clientId;
94 this._lastPushedClientId = this.clientId;
62 } 95 }
63 }, 96 },
64 97
65 _onSignin: function(e) { 98 _onSignin: function(e) {
66 this._setSignedIn(true); 99 this._setSignedIn(true);
67 var user = gapi.auth2.getAuthInstance().currentUser.get(); 100 var user = gapi.auth2.getAuthInstance().currentUser.get();
68 var profile = user.getBasicProfile(); 101 var profile = user.getBasicProfile();
69 this._setProfile({ 102 this._setProfile({
70 email: profile.getEmail(), 103 email: profile.getEmail(),
71 imageUrl: profile.getImageUrl() 104 imageUrl: profile.getImageUrl()
72 }); 105 });
73 }, 106 },
74 107
75 _onSignout: function(e) { 108 _onSignout: function(e) {
76 this._setSignedIn(false); 109 this._setSignedIn(false);
77 this._setProfile(null); 110 this._setProfile(null);
78 }, 111 },
79 112
80 signIn: function() { 113 signIn: function() {
81 this.$.aware.signIn(); 114 this.$.aware.signIn();
82 }, 115 },
83 116
84 signOut: function() { 117 signOut: function() {
85 this.$.aware.signOut(); 118 this.$.aware.signOut();
86 } 119 }
87 }); 120 });
88 </script> 121 </script>
89 </dom-module> 122 </dom-module>
OLDNEW
« no previous file with comments | « web/bower.json ('k') | web/inc/logdog-stream-view/logdog-stream-fetcher.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698