Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Side by Side Diff: chrome/browser/resources/gaia_auth/desktop_injected.js

Issue 134263005: Implement inline signin with iframe (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix for various iframe bugs Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview Code injected into Gaia sign in page for inline sign in flow. 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 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 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. 9 * in form, it posts the username and password to the embedder window.
10 * Prototype Only. 10 * Prototype Only.
11 */ 11 */
12 12
13 (function() { 13 (function() {
14 var extWindow; 14 var $ = function(id) { return document.getElementById(id); };
15 15
16 var $ = function(id) { return document.getElementById(id); };
17 var gaiaLoginForm = $('gaia_loginform'); 16 var gaiaLoginForm = $('gaia_loginform');
18 17 if (!gaiaLoginForm) {
19 var onMessage = function(e) { 18 return;
20 extWindow = e.source; 19 }
21 };
22 window.addEventListener('message', onMessage);
23 20
24 var onLoginSubmit = function(e) { 21 var onLoginSubmit = function(e) {
25 if (!extWindow) {
26 console.log('ERROR: no initial message received from the gaia ext');
27 e.preventDefault();
28 return;
29 }
30
31 var checkboxElement = $('advanced-box'); 22 var checkboxElement = $('advanced-box');
32 var chooseWhatToSync = checkboxElement && checkboxElement.checked; 23 var chooseWhatToSync = checkboxElement && checkboxElement.checked;
33 var msg = {method: 'attemptLogin', 24 var msg = {method: 'attemptLogin',
34 email: gaiaLoginForm['Email'].value, 25 email: gaiaLoginForm['Email'].value,
35 password: gaiaLoginForm['Passwd'].value, 26 password: gaiaLoginForm['Passwd'].value,
36 attemptToken: new Date().getTime(), 27 attemptToken: new Date().getTime(),
37 chooseWhatToSync: chooseWhatToSync}; 28 chooseWhatToSync: chooseWhatToSync};
38 29
39 extWindow.postMessage(msg, 'chrome://chrome-signin'); 30 window.parent.postMessage(
40 console.log('Credentials sent'); 31 msg, 'chrome-extension://mfffpogegjflfpflabcdkioaeobkgjik');
41 32
42 return; 33 return;
43 }; 34 };
44 // Overrides the submit handler for the gaia login form. 35 // Overrides the submit handler for the gaia login form.
45 gaiaLoginForm.onsubmit = onLoginSubmit; 36 gaiaLoginForm.onsubmit = onLoginSubmit;
46 })(); 37 })();
OLDNEW
« no previous file with comments | « chrome/browser/resources/gaia_auth/background.js ('k') | chrome/browser/resources/gaia_auth/inline_injected.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698