| OLD | NEW |
| 1 <!-- | 1 <!-- |
| 2 Copyright 2014 Google Inc | 2 Copyright 2014 Google Inc |
| 3 | 3 |
| 4 Licensed under the Apache License, Version 2.0 (the "License"); | 4 Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 you may not use this file except in compliance with the License. | 5 you may not use this file except in compliance with the License. |
| 6 You may obtain a copy of the License at | 6 You may obtain a copy of the License at |
| 7 | 7 |
| 8 https://www.apache.org/licenses/LICENSE-2.0 | 8 https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | 9 |
| 10 Unless required by applicable law or agreed to in writing, software | 10 Unless required by applicable law or agreed to in writing, software |
| 11 distributed under the License is distributed on an "AS IS" BASIS, | 11 distributed under the License is distributed on an "AS IS" BASIS, |
| 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 See the License for the specific language governing permissions and | 13 See the License for the specific language governing permissions and |
| 14 limitations under the License. | 14 limitations under the License. |
| 15 --> | 15 --> |
| 16 | 16 |
| 17 <link rel="import" href="../polymer/polymer.html"> | 17 <link rel="import" href="../../../bower_components/polymer/polymer.html"> |
| 18 <link rel="import" href="../google-apis/google-js-api.html"> | 18 <link rel="import" href="../../../bower_components/google-apis/google-js-api.htm
l"> |
| 19 | 19 |
| 20 <script> | 20 <script> |
| 21 (function() { | 21 (function() { |
| 22 | 22 |
| 23 /** | 23 /** |
| 24 * Enum of attributes to be passed through to the login API call. | 24 * Enum of attributes to be passed through to the login API call. |
| 25 * @readonly | 25 * @readonly |
| 26 * @enum {string} | 26 * @enum {string} |
| 27 */ | 27 */ |
| 28 var ProxyLoginAttributes = { | 28 var ProxyLoginAttributes = { |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 /** True if have google+ scopes */ | 223 /** True if have google+ scopes */ |
| 224 _hasPlusScopes: false, | 224 _hasPlusScopes: false, |
| 225 | 225 |
| 226 /** | 226 /** |
| 227 * array of <google-signin-aware> | 227 * array of <google-signin-aware> |
| 228 * state changes are broadcast to them | 228 * state changes are broadcast to them |
| 229 */ | 229 */ |
| 230 signinAwares: [], | 230 signinAwares: [], |
| 231 | 231 |
| 232 init: function() { | 232 init: function() { |
| 233 this._apiLoader = document.createElement('google-js-api'); | 233 var that = this; |
| 234 this._apiLoader.addEventListener('js-api-load', this.loadAuth2.bind(this
)); | 234 document.addEventListener('DOMContentLoaded', function() { |
| 235 if (Polymer.Element) { | 235 that._apiLoader = document.createElement('google-js-api'); |
| 236 document.body.appendChild(this._apiLoader); | 236 that._apiLoader.addEventListener('js-api-load', that.loadAuth2.bind(th
at)); |
| 237 } | 237 if (Polymer.Element) { |
| 238 document.body.appendChild(that._apiLoader); |
| 239 } |
| 240 }) |
| 238 }, | 241 }, |
| 239 | 242 |
| 240 loadAuth2: function() { | 243 loadAuth2: function() { |
| 241 gapi.load('auth2', this.initAuth2.bind(this)); | 244 var that = this; |
| 245 gapi.load('auth2', that.initAuth2.bind(that)); |
| 242 }, | 246 }, |
| 243 | 247 |
| 244 initAuth2: function() { | 248 initAuth2: function() { |
| 245 if (!('gapi' in window) || !('auth2' in window.gapi) || !this.clientId)
{ | 249 if (!('gapi' in window) || !('auth2' in window.gapi) || !this.clientId)
{ |
| 246 return; | 250 return; |
| 247 } | 251 } |
| 248 var auth = gapi.auth2.init({ | 252 var auth = gapi.auth2.init({ |
| 249 'client_id': this.clientId, | 253 'client_id': this.clientId, |
| 250 'cookie_policy': this.cookiePolicy, | 254 'cookie_policy': this.cookiePolicy, |
| 251 'scope': this.requestedScopes, | 255 'scope': this.requestedScopes, |
| (...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 815 }, | 819 }, |
| 816 | 820 |
| 817 _updateOfflineCode: function(code) { | 821 _updateOfflineCode: function(code) { |
| 818 if (code) { | 822 if (code) { |
| 819 this.fire('google-signin-offline-success', {code: code}); | 823 this.fire('google-signin-offline-success', {code: code}); |
| 820 } | 824 } |
| 821 } | 825 } |
| 822 }); | 826 }); |
| 823 })(); | 827 })(); |
| 824 </script> | 828 </script> |
| OLD | NEW |