1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
6 * @fileoverview Code injected into Gaia sign in page for inline sign in flow.
7 * On load stop, it receives a message from the embedder extension with a
8 * JavaScript reference to the embedder window. Then upon submit of the sign
9 * in form, it posts the username and password to the embedder window.
16 var $ = function(id) { return document.getElementById(id); };
17 var gaiaLoginForm = $('gaia_loginform');
19 var onMessage = function(e) {
22 window.addEventListener('message', onMessage);
24 var onLoginSubmit = function(e) {
26 console.log('ERROR: no initial message received from the gaia ext');
31 var checkboxElement = $('advanced-box');
32 var chooseWhatToSync = checkboxElement && checkboxElement.checked;
33 var msg = {method: 'attemptLogin',
34 email: gaiaLoginForm['Email'].value,
35 password: gaiaLoginForm['Passwd'].value,
36 attemptToken: new Date().getTime(),
37 chooseWhatToSync: chooseWhatToSync};
39 extWindow.postMessage(msg, 'chrome://chrome-signin');
40 console.log('Credentials sent');
44 // Overrides the submit handler for the gaia login form.
45 gaiaLoginForm.onsubmit = onLoginSubmit;