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

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

Issue 902493003: cros: Pass gaia_auth init params via postMessage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix nits Created 5 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 Offline login implementation. 6 * @fileoverview Offline login implementation.
7 */ 7 */
8 8
9 function load() { 9 /**
10 var params = getUrlSearchParams(location.search); 10 * Initialize the offline page.
11 11 * @param {Object} params Intialization params passed from parent page.
12 */
13 function load(params) {
12 // Setup localized strings. 14 // Setup localized strings.
13 $('sign-in-title').textContent = decodeURIComponent(params['stringSignIn']); 15 $('sign-in-title').textContent = decodeURIComponent(params['stringSignIn']);
14 $('email-label').textContent = decodeURIComponent(params['stringEmail']); 16 $('email-label').textContent = decodeURIComponent(params['stringEmail']);
15 $('password-label').textContent = 17 $('password-label').textContent =
16 decodeURIComponent(params['stringPassword']); 18 decodeURIComponent(params['stringPassword']);
17 $('submit-button').value = decodeURIComponent(params['stringSignIn']); 19 $('submit-button').value = decodeURIComponent(params['stringSignIn']);
18 $('empty-email-alert').textContent = 20 $('empty-email-alert').textContent =
19 decodeURIComponent(params['stringEmptyEmail']); 21 decodeURIComponent(params['stringEmptyEmail']);
20 $('empty-password-alert').textContent = 22 $('empty-password-alert').textContent =
21 decodeURIComponent(params['stringEmptyPassword']); 23 decodeURIComponent(params['stringEmptyPassword']);
(...skipping 30 matching lines...) Expand all
52 // made. Try to mimic Gaia's behaviour. 54 // made. Try to mimic Gaia's behaviour.
53 form.email.value = email; 55 form.email.value = email;
54 form.password.classList.add('form-error'); 56 form.password.classList.add('form-error');
55 form.password.focus(); 57 form.password.focus();
56 } else { 58 } else {
57 form.email.focus(); 59 form.email.focus();
58 } 60 }
59 window.parent.postMessage({'method': 'loginUILoaded'}, 'chrome://oobe/'); 61 window.parent.postMessage({'method': 'loginUILoaded'}, 'chrome://oobe/');
60 } 62 }
61 63
62 document.addEventListener('DOMContentLoaded', load); 64 /**
65 * Handles initialization message from parent page.
66 * @param {MessageEvent} e
67 */
68 function handleInitializeMessage(e) {
69 var ALLOWED_PARENT_ORIGINS = [
70 'chrome://oobe',
71 'chrome://chrome-signin'
72 ];
73
74 if (ALLOWED_PARENT_ORIGINS.indexOf(e.origin) == -1)
75 return;
76
77 window.removeEventListener('message', handleInitializeMessage);
78
79 var params = e.data;
80 params.parentPage = e.origin;
81 load(params);
82 }
83
84 document.addEventListener('DOMContentLoaded', function() {
85 window.addEventListener('message', handleInitializeMessage);
86 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/gaia_auth/manifest_keyboard.json ('k') | chrome/browser/resources/gaia_auth/util.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698