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(); });
26 type
: 'gaia_saml_api',
27 call
: {method
: 'initialize', requestedVersion
: 1}}, '/');
30 gaia
.chromeOSLogin
.clearOldAttempts = function() {
32 'method': 'clearOldAttempts'
34 gaia
.chromeOSLogin
.parent_webview_
.postMessage(msg
,
35 gaia
.chromeOSLogin
.parent_webview_url_
);
38 gaia
.chromeOSLogin
.attemptLogin = function(email
, password
) {
40 'method': 'attemptLogin',
43 gaia
.chromeOSLogin
.parent_webview_
.postMessage(msg
,
44 gaia
.chromeOSLogin
.parent_webview_url_
);
46 // SAML credential passing api for password.
48 {type
: 'gaia_saml_api',
52 passwordBytes
: password
,
53 keyType
: 'KEY_TYPE_PASSWORD_PLAIN'}
57 gaia
.chromeOSLogin
.backButton = function(show
) {
59 'method': 'backButton',
62 gaia
.chromeOSLogin
.parent_webview_
.postMessage(msg
,
63 gaia
.chromeOSLogin
.parent_webview_url_
);
66 function goFirstPage() {
67 document
.getElementById('page1').hidden
= false;
68 document
.getElementById('page2').hidden
= true;
69 history
.replaceState({}, '', window
.location
.pathname
+ '#identifier');
70 gaia
.chromeOSLogin
.backButton(false);
74 if (!document
.getElementById('page2').hidden
) {
80 if (!document
.getElementById("page1").hidden
) {
81 document
.getElementById("page1").hidden
= true;
82 document
.getElementById("page2").hidden
= false;
83 history
.pushState({}, "", window
.location
.pathname
+ "#challengepassword");
85 request
= new XMLHttpRequest();
86 request
.open('POST', '/_/embedded/lookup/accountlookup', true);
87 request
.onreadystatechange = function() {
88 if (request
.readyState
== 4 && request
.status
== 200) {
89 if (request
.getResponseHeader("continue"))
90 location
.assign(request
.getResponseHeader("continue"));
93 var email
= document
.getElementById("identifier").value
;
94 request
.send('identifier=' + encodeURIComponent(email
));
96 gaia
.chromeOSLogin
.attemptLogin(email
, "");
97 gaia
.chromeOSLogin
.backButton(true);
98 } else if (!document
.getElementById("page2").hidden
) {
99 var email
= document
.getElementById("identifier").value
;
100 var password
= document
.getElementById("password").value
;
102 request
= new XMLHttpRequest();
103 request
.open('POST', '/_/embedded/signin/challenge', true);
104 request
.onreadystatechange = function() {
105 if (request
.readyState
== 4 && request
.status
== 200) {
106 history
.pushState({}, "", window
.location
.pathname
+ "#close");
109 request
.send('identifier=' + encodeURIComponent(email
));
111 gaia
.chromeOSLogin
.attemptLogin(email
, password
);
116 gaia
.chromeOSLogin
.registerHtml5Listener();
118 gaia
.chromeOSLogin
.clearOldAttempts();
123 <body onload='onLoad();'
>
124 Local Auth Server:
<br>
125 <div id=
"page1" hidden
>
127 <input id=
"identifier" name=
"identifier" type=
"email" spellcheck=
"false" autocomplete=
"off" formnovalidate=
"">
129 <div id=
"page2" hidden
>
131 <input id=
"password" name=
"password" type=
"password" spellcheck=
"false" autocomplete=
"off" formnovalidate=
"">
133 <div id='nextButton' onclick='goNext();'
>Next
</div>