5 gaia
.chromeOSLogin
= {};
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;
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
;
19 // Repeat clearOldAttempts as soon as we got parent.
20 gaia
.chromeOSLogin
.clearOldAttempts();
23 window
.addEventListener('message', onMessage
);
24 window
.addEventListener("popstate", function(e
) { goBack(); });
27 gaia
.chromeOSLogin
.clearOldAttempts = function() {
29 'method': 'clearOldAttempts'
31 gaia
.chromeOSLogin
.parent_webview_
.postMessage(msg
,
32 gaia
.chromeOSLogin
.parent_webview_url_
);
35 gaia
.chromeOSLogin
.attemptLogin = function(email
, password
) {
37 'method': 'attemptLogin',
41 gaia
.chromeOSLogin
.parent_webview_
.postMessage(msg
,
42 gaia
.chromeOSLogin
.parent_webview_url_
);
45 gaia
.chromeOSLogin
.backButton = function(show
) {
47 'method': 'backButton',
50 gaia
.chromeOSLogin
.parent_webview_
.postMessage(msg
,
51 gaia
.chromeOSLogin
.parent_webview_url_
);
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);
62 if (!document
.getElementById('page2').hidden
) {
68 if (!document
.getElementById("page1").hidden
) {
69 document
.getElementById("page1").hidden
= true;
70 document
.getElementById("page2").hidden
= false;
71 history
.pushState({}, "", window
.location
.pathname
+ "#challengepassword");
73 request
= new XMLHttpRequest();
74 request
.open('POST', '/_/embedded/lookup/accountlookup', true);
75 request
.onreadystatechange = function() {
76 if (request
.readyState
== 4 && request
.status
== 200) {
77 if (request
.getResponseHeader("continue"))
78 location
.assign(request
.getResponseHeader("continue"));
81 var email
= document
.getElementById("identifier").value
;
82 request
.send('identifier=' + encodeURIComponent(email
));
84 gaia
.chromeOSLogin
.attemptLogin(email
, "");
85 gaia
.chromeOSLogin
.backButton(true);
86 } else if (!document
.getElementById("page2").hidden
) {
87 var email
= document
.getElementById("identifier").value
;
88 var password
= document
.getElementById("password").value
;
90 request
= new XMLHttpRequest();
91 request
.open('POST', '/_/embedded/signin/challenge', true);
92 request
.onreadystatechange = function() {
93 if (request
.readyState
== 4 && request
.status
== 200) {
94 history
.pushState({}, "", window
.location
.pathname
+ "#close");
97 request
.send('identifier=' + encodeURIComponent(email
));
99 gaia
.chromeOSLogin
.attemptLogin(email
, password
);
104 gaia
.chromeOSLogin
.registerHtml5Listener();
106 gaia
.chromeOSLogin
.clearOldAttempts();
111 <body onload='onLoad();'
>
112 Local Auth Server:
<br>
113 <div id=
"page1" hidden
>
115 <input id=
"identifier" name=
"identifier" type=
"email" spellcheck=
"false" autocomplete=
"off" formnovalidate=
"">
117 <div id=
"page2" hidden
>
119 <input id=
"password" name=
"password" type=
"password" spellcheck=
"false" autocomplete=
"off" formnovalidate=
"">
121 <div id='nextButton' onclick='goNext();'
>Next
</div>