Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!-- <HTML> --> | |
|
Nikita (slow)
2015/04/07 12:37:48
Does it have to be in comment?
Dmitry Polukhin
2015/04/07 13:24:40
Done.
| |
| 2 <HEAD> | |
|
Nikita (slow)
2015/04/07 12:37:48
nit: lowercase here and below
Dmitry Polukhin
2015/04/07 13:24:40
Done.
| |
| 3 <SCRIPT> | |
| 4 var gaia = gaia || {}; | |
| 5 gaia.chromeOSLogin = {}; | |
| 6 | |
| 7 gaia.chromeOSLogin.parent_webview_signin_url_ = 'chrome://chrome-signin'; | |
| 8 gaia.chromeOSLogin.parent_webview_oob_url_ = 'chrome://oobe'; | |
| 9 gaia.chromeOSLogin.parent_webview_ = undefined; | |
| 10 gaia.chromeOSLogin.parent_webview_url_ = undefined; | |
| 11 | |
| 12 gaia.chromeOSLogin.registerHtml5Listener = function() { | |
| 13 var onMessage = function(e) { | |
| 14 if (e.origin == gaia.chromeOSLogin.parent_webview_signin_url_ || | |
| 15 e.origin == gaia.chromeOSLogin.parent_webview_oob_url_) { | |
| 16 gaia.chromeOSLogin.parent_webview_ = e.source; | |
| 17 gaia.chromeOSLogin.parent_webview_url_ = e.origin; | |
| 18 } | |
| 19 }; | |
| 20 window.addEventListener('message', onMessage); | |
| 21 } | |
| 22 | |
| 23 gaia.chromeOSLogin.attemptLogin = function(email, password) { | |
| 24 var msg = { | |
| 25 'method': 'attemptLogin', | |
| 26 'email': email, | |
| 27 'password': password, | |
| 28 }; | |
| 29 gaia.chromeOSLogin.parent_webview_.postMessage(msg, | |
| 30 gaia.chromeOSLogin.parent_webview_url_); | |
| 31 }; | |
| 32 | |
| 33 gaia.chromeOSLogin.backButton = function(show) { | |
| 34 var msg = { | |
| 35 'method': 'backButton', | |
| 36 'show': show, | |
| 37 }; | |
| 38 gaia.chromeOSLogin.parent_webview_.postMessage(msg, | |
| 39 gaia.chromeOSLogin.parent_webview_url_); | |
| 40 }; | |
| 41 | |
| 42 function goNext() { | |
| 43 if (!document.getElementById("page1").hidden) { | |
| 44 document.getElementById("page1").hidden = true; | |
| 45 document.getElementById("page2").hidden = false; | |
| 46 history.pushState({}, "", window.location.pathname + "#challengepassword"); | |
| 47 | |
| 48 request = new XMLHttpRequest(); | |
| 49 request.open('POST', '/_/embedded/lookup/accountlookup', true); | |
| 50 request.onreadystatechange = function() { | |
| 51 if (request.readyState == 4 && request.status == 200) { | |
|
Nikita (slow)
2015/04/07 12:37:48
nit: "4" - extract constant.
Dmitry Polukhin
2015/04/07 13:24:40
Discussed and decided to keep as is in tests. 200
| |
| 52 if (request.getResponseHeader("continue")) | |
| 53 location.assign(request.getResponseHeader("continue")); | |
| 54 } | |
| 55 }; | |
| 56 var email = document.getElementById("identifier").value; | |
| 57 request.send('identifier=' + encodeURIComponent(email)); | |
| 58 | |
| 59 gaia.chromeOSLogin.backButton(true); | |
| 60 } else if (!document.getElementById("page2").hidden) { | |
| 61 var email = document.getElementById("identifier").value; | |
| 62 var password = document.getElementById("password").value; | |
| 63 | |
| 64 request = new XMLHttpRequest(); | |
| 65 request.open('POST', '/_/embedded/signin/challenge', true); | |
| 66 request.onreadystatechange = function() { | |
| 67 if (request.readyState == 4 && request.status == 200) { | |
| 68 history.pushState({}, "", window.location.pathname + "#close"); | |
| 69 } | |
| 70 }; | |
| 71 request.send('identifier=' + encodeURIComponent(email)); | |
| 72 | |
| 73 gaia.chromeOSLogin.attemptLogin(email, password); | |
|
Nikita (slow)
2015/04/07 12:37:48
should follow "B-2" scenario
* Call clearOldAttem
Dmitry Polukhin
2015/04/07 13:24:40
Done.
| |
| 74 } | |
| 75 } | |
| 76 | |
| 77 function onLoad() { | |
| 78 gaia.chromeOSLogin.registerHtml5Listener(); | |
| 79 document.getElementById("page1").hidden = false; | |
| 80 history.replaceState({}, "", window.location.pathname + "#identifier"); | |
| 81 } | |
| 82 | |
| 83 </script> | |
| 84 </head> | |
| 85 <body onload='onLoad();'> | |
| 86 Local Auth Server:<br> | |
| 87 <div id="page1" hidden> | |
| 88 Email | |
| 89 <input id="identifier" name="identifier" type="email" spellcheck="false" aut ocomplete="off" formnovalidate=""> | |
| 90 </div> | |
| 91 <div id="page2" hidden> | |
| 92 Password | |
| 93 <input id="password" name="password" type="password" spellcheck="false" auto complete="off" formnovalidate=""> | |
| 94 </div><br> | |
| 95 <div id='nextButton' onclick='goNext();'>Next</div> | |
| 96 </body> | |
| 97 </html> | |
| OLD | NEW |