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.
14 var $ = function(id) { return document.getElementById(id); };
16 var gaiaLoginForm = $('gaia_loginform');
21 var onLoginSubmit = function(e) {
22 var checkboxElement = $('advanced-box');
23 var chooseWhatToSync = checkboxElement && checkboxElement.checked;
24 var msg = {method: 'attemptLogin',
25 email: gaiaLoginForm['Email'].value,
26 password: gaiaLoginForm['Passwd'].value,
27 attemptToken: new Date().getTime(),
28 chooseWhatToSync: chooseWhatToSync};
30 window.parent.postMessage(
31 msg, 'chrome-extension://mfffpogegjflfpflabcdkioaeobkgjik');
35 // Overrides the submit handler for the gaia login form.
36 gaiaLoginForm.onsubmit = onLoginSubmit;