| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 <script> | 3 <script> |
| 4 var gaia = gaia || {}; | 4 var gaia = gaia || {}; |
| 5 gaia.chromeOSLogin = {}; | 5 gaia.chromeOSLogin = {}; |
| 6 | 6 |
| 7 gaia.chromeOSLogin.parent_webview_signin_url_ = 'chrome://chrome-signin'; | 7 gaia.chromeOSLogin.parent_webview_signin_url_ = 'chrome://chrome-signin'; |
| 8 gaia.chromeOSLogin.parent_webview_oob_url_ = 'chrome://oobe'; | 8 gaia.chromeOSLogin.parent_webview_oob_url_ = 'chrome://oobe'; |
| 9 gaia.chromeOSLogin.parent_webview_ = undefined; | 9 gaia.chromeOSLogin.parent_webview_ = undefined; |
| 10 gaia.chromeOSLogin.parent_webview_url_ = undefined; | 10 gaia.chromeOSLogin.parent_webview_url_ = undefined; |
| 11 | 11 |
| 12 gaia.chromeOSLogin.registerHtml5Listener = function() { | 12 gaia.chromeOSLogin.registerHtml5Listener = function() { |
| 13 var onMessage = function(e) { | 13 var onMessage = function(e) { |
| 14 if (e.origin == gaia.chromeOSLogin.parent_webview_signin_url_ || | 14 if (e.origin == gaia.chromeOSLogin.parent_webview_signin_url_ || |
| 15 e.origin == gaia.chromeOSLogin.parent_webview_oob_url_) { | 15 e.origin == gaia.chromeOSLogin.parent_webview_oob_url_) { |
| 16 gaia.chromeOSLogin.parent_webview_ = e.source; | 16 gaia.chromeOSLogin.parent_webview_ = e.source; |
| 17 gaia.chromeOSLogin.parent_webview_url_ = e.origin; | 17 gaia.chromeOSLogin.parent_webview_url_ = e.origin; |
| 18 | 18 |
| 19 // Repeat clearOldAttempts as soon as we got parent. | 19 // Repeat clearOldAttempts as soon as we got parent. |
| 20 gaia.chromeOSLogin.clearOldAttempts(); | 20 gaia.chromeOSLogin.clearOldAttempts(); |
| 21 } | 21 } |
| 22 }; | 22 }; |
| 23 window.addEventListener('message', onMessage); | 23 window.addEventListener('message', onMessage); |
| 24 window.addEventListener("popstate", function(e) { goBack(); }); |
| 24 } | 25 } |
| 25 | 26 |
| 26 gaia.chromeOSLogin.clearOldAttempts = function() { | 27 gaia.chromeOSLogin.clearOldAttempts = function() { |
| 27 var msg = { | 28 var msg = { |
| 28 'method': 'clearOldAttempts' | 29 'method': 'clearOldAttempts' |
| 29 }; | 30 }; |
| 30 gaia.chromeOSLogin.parent_webview_.postMessage(msg, | 31 gaia.chromeOSLogin.parent_webview_.postMessage(msg, |
| 31 gaia.chromeOSLogin.parent_webview_url_); | 32 gaia.chromeOSLogin.parent_webview_url_); |
| 32 }; | 33 }; |
| 33 | 34 |
| 34 gaia.chromeOSLogin.attemptLogin = function(email, password) { | 35 gaia.chromeOSLogin.attemptLogin = function(email, password) { |
| 35 var msg = { | 36 var msg = { |
| 36 'method': 'attemptLogin', | 37 'method': 'attemptLogin', |
| 37 'email': email, | 38 'email': email, |
| 38 'password': password, | 39 'password': password, |
| 39 }; | 40 }; |
| 40 gaia.chromeOSLogin.parent_webview_.postMessage(msg, | 41 gaia.chromeOSLogin.parent_webview_.postMessage(msg, |
| 41 gaia.chromeOSLogin.parent_webview_url_); | 42 gaia.chromeOSLogin.parent_webview_url_); |
| 42 }; | 43 }; |
| 43 | 44 |
| 44 gaia.chromeOSLogin.backButton = function(show) { | 45 gaia.chromeOSLogin.backButton = function(show) { |
| 45 var msg = { | 46 var msg = { |
| 46 'method': 'backButton', | 47 'method': 'backButton', |
| 47 'show': show, | 48 'show': show, |
| 48 }; | 49 }; |
| 49 gaia.chromeOSLogin.parent_webview_.postMessage(msg, | 50 gaia.chromeOSLogin.parent_webview_.postMessage(msg, |
| 50 gaia.chromeOSLogin.parent_webview_url_); | 51 gaia.chromeOSLogin.parent_webview_url_); |
| 51 }; | 52 }; |
| 52 | 53 |
| 54 function goFirstPage() { |
| 55 document.getElementById('page1').hidden = false; |
| 56 document.getElementById('page2').hidden = true; |
| 57 history.replaceState({}, '', window.location.pathname + '#identifier'); |
| 58 gaia.chromeOSLogin.backButton(false); |
| 59 } |
| 60 |
| 61 function goBack() { |
| 62 if (!document.getElementById('page2').hidden) { |
| 63 goFirstPage(); |
| 64 } |
| 65 } |
| 66 |
| 53 function goNext() { | 67 function goNext() { |
| 54 if (!document.getElementById("page1").hidden) { | 68 if (!document.getElementById("page1").hidden) { |
| 55 document.getElementById("page1").hidden = true; | 69 document.getElementById("page1").hidden = true; |
| 56 document.getElementById("page2").hidden = false; | 70 document.getElementById("page2").hidden = false; |
| 57 history.pushState({}, "", window.location.pathname + "#challengepassword"); | 71 history.pushState({}, "", window.location.pathname + "#challengepassword"); |
| 58 | 72 |
| 59 request = new XMLHttpRequest(); | 73 request = new XMLHttpRequest(); |
| 60 request.open('POST', '/_/embedded/lookup/accountlookup', true); | 74 request.open('POST', '/_/embedded/lookup/accountlookup', true); |
| 61 request.onreadystatechange = function() { | 75 request.onreadystatechange = function() { |
| 62 if (request.readyState == 4 && request.status == 200) { | 76 if (request.readyState == 4 && request.status == 200) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 81 } | 95 } |
| 82 }; | 96 }; |
| 83 request.send('identifier=' + encodeURIComponent(email)); | 97 request.send('identifier=' + encodeURIComponent(email)); |
| 84 | 98 |
| 85 gaia.chromeOSLogin.attemptLogin(email, password); | 99 gaia.chromeOSLogin.attemptLogin(email, password); |
| 86 } | 100 } |
| 87 } | 101 } |
| 88 | 102 |
| 89 function onLoad() { | 103 function onLoad() { |
| 90 gaia.chromeOSLogin.registerHtml5Listener(); | 104 gaia.chromeOSLogin.registerHtml5Listener(); |
| 91 document.getElementById("page1").hidden = false; | 105 goFirstPage(); |
| 92 history.replaceState({}, "", window.location.pathname + "#identifier"); | |
| 93 gaia.chromeOSLogin.clearOldAttempts(); | 106 gaia.chromeOSLogin.clearOldAttempts(); |
| 94 } | 107 } |
| 95 | 108 |
| 96 </script> | 109 </script> |
| 97 </head> | 110 </head> |
| 98 <body onload='onLoad();'> | 111 <body onload='onLoad();'> |
| 99 Local Auth Server:<br> | 112 Local Auth Server:<br> |
| 100 <div id="page1" hidden> | 113 <div id="page1" hidden> |
| 101 Email | 114 Email |
| 102 <input id="identifier" name="identifier" type="email" spellcheck="false" aut
ocomplete="off" formnovalidate=""> | 115 <input id="identifier" name="identifier" type="email" spellcheck="false" aut
ocomplete="off" formnovalidate=""> |
| 103 </div> | 116 </div> |
| 104 <div id="page2" hidden> | 117 <div id="page2" hidden> |
| 105 Password | 118 Password |
| 106 <input id="password" name="password" type="password" spellcheck="false" auto
complete="off" formnovalidate=""> | 119 <input id="password" name="password" type="password" spellcheck="false" auto
complete="off" formnovalidate=""> |
| 107 </div><br> | 120 </div><br> |
| 108 <div id='nextButton' onclick='goNext();'>Next</div> | 121 <div id='nextButton' onclick='goNext();'>Next</div> |
| 109 </body> | 122 </body> |
| 110 </html> | 123 </html> |
| OLD | NEW |