| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * Authenticator class wraps the communications between Gaia and its host. | 6 * Authenticator class wraps the communications between Gaia and its host. |
| 7 */ | 7 */ |
| 8 function Authenticator() { | 8 function Authenticator() { |
| 9 } | 9 } |
| 10 | 10 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 if (this.inputLang_) | 87 if (this.inputLang_) |
| 88 url = appendParam(url, 'hl', this.inputLang_); | 88 url = appendParam(url, 'hl', this.inputLang_); |
| 89 if (this.inputEmail_) | 89 if (this.inputEmail_) |
| 90 url = appendParam(url, 'Email', this.inputEmail_); | 90 url = appendParam(url, 'Email', this.inputEmail_); |
| 91 | 91 |
| 92 return url; | 92 return url; |
| 93 }, | 93 }, |
| 94 | 94 |
| 95 /** Callback when all loads in the gaia webview is complete. */ | 95 /** Callback when all loads in the gaia webview is complete. */ |
| 96 onWebviewLoadstop_: function(gaiaFrame) { | 96 onWebviewLoadstop_: function(gaiaFrame) { |
| 97 // Report the current state to the parent which will then update the | 97 if (gaiaFrame.src.lastIndexOf(this.continueUrlWithoutParams_, 0) == 0) { |
| 98 // browser history so that later it could respond properly to back/forward. | |
| 99 var msg = { | |
| 100 'method': 'reportState', | |
| 101 'src': gaiaFrame.src | |
| 102 }; | |
| 103 window.parent.postMessage(msg, this.parentPage_); | |
| 104 | |
| 105 if (gaiaFrame.src.lastIndexOf( | |
| 106 this.continueUrlWithoutParams_, 0) == 0) { | |
| 107 // Detect when login is finished by the load stop event of the continue | 98 // Detect when login is finished by the load stop event of the continue |
| 108 // URL. Cannot reuse the login complete flow in success.html, because | 99 // URL. Cannot reuse the login complete flow in success.html, because |
| 109 // webview does not support extension pages yet. | 100 // webview does not support extension pages yet. |
| 110 var skipForNow = false; | 101 var skipForNow = false; |
| 111 if (this.inlineMode_ && gaiaFrame.src.indexOf('ntp=1') >= 0) { | 102 if (this.inlineMode_ && gaiaFrame.src.indexOf('ntp=1') >= 0) { |
| 112 skipForNow = true; | 103 skipForNow = true; |
| 113 } | 104 } |
| 114 msg = { | 105 msg = { |
| 115 'method': 'completeLogin', | 106 'method': 'completeLogin', |
| 116 'skipForNow': skipForNow | 107 'skipForNow': skipForNow |
| 117 }; | 108 }; |
| 118 window.parent.postMessage(msg, this.parentPage_); | 109 window.parent.postMessage(msg, this.parentPage_); |
| 110 // Do no report state to the parent for the continue URL, since it is a |
| 111 // blank page. |
| 119 return; | 112 return; |
| 120 } | 113 } |
| 121 | 114 |
| 115 // Report the current state to the parent which will then update the |
| 116 // browser history so that later it could respond properly to back/forward. |
| 117 var msg = { |
| 118 'method': 'reportState', |
| 119 'src': gaiaFrame.src |
| 120 }; |
| 121 window.parent.postMessage(msg, this.parentPage_); |
| 122 |
| 122 if (gaiaFrame.src.lastIndexOf(this.gaiaUrl_, 0) == 0) { | 123 if (gaiaFrame.src.lastIndexOf(this.gaiaUrl_, 0) == 0) { |
| 123 gaiaFrame.executeScript({file: 'inline_injected.js'}, function() { | 124 gaiaFrame.executeScript({file: 'inline_injected.js'}, function() { |
| 124 // Send an initial message to gaia so that it has an JavaScript | 125 // Send an initial message to gaia so that it has an JavaScript |
| 125 // reference to the embedder. | 126 // reference to the embedder. |
| 126 gaiaFrame.contentWindow.postMessage('', gaiaFrame.src); | 127 gaiaFrame.contentWindow.postMessage('', gaiaFrame.src); |
| 127 }); | 128 }); |
| 128 } | 129 } |
| 129 | 130 |
| 130 this.loaded_ || this.onLoginUILoaded(); | 131 this.loaded_ || this.onLoginUILoaded(); |
| 131 }, | 132 }, |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 } else if (msg.method == 'redirectToSignin' && | 304 } else if (msg.method == 'redirectToSignin' && |
| 304 this.isParentMessage_(e)) { | 305 this.isParentMessage_(e)) { |
| 305 $('gaia-frame').src = this.constructInitialFrameUrl_(); | 306 $('gaia-frame').src = this.constructInitialFrameUrl_(); |
| 306 } else { | 307 } else { |
| 307 console.error('Authenticator.onMessage: unknown message + origin!?'); | 308 console.error('Authenticator.onMessage: unknown message + origin!?'); |
| 308 } | 309 } |
| 309 } | 310 } |
| 310 }; | 311 }; |
| 311 | 312 |
| 312 Authenticator.getInstance().initialize(); | 313 Authenticator.getInstance().initialize(); |
| OLD | NEW |