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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/gaia_auth/offline.js
diff --git a/chrome/browser/resources/gaia_auth/offline.js b/chrome/browser/resources/gaia_auth/offline.js
index 7b4da1f528591f1144c2145c32f2808e1c65b970..dcc153f21faeabe77c4f14ff70d67b70af597239 100644
--- a/chrome/browser/resources/gaia_auth/offline.js
+++ b/chrome/browser/resources/gaia_auth/offline.js
@@ -6,9 +6,11 @@
* @fileoverview Offline login implementation.
*/
-function load() {
- var params = getUrlSearchParams(location.search);
-
+/**
+ * Initialize the offline page.
+ * @param {Object} params Intialization params passed from parent page.
+ */
+function load(params) {
// Setup localized strings.
$('sign-in-title').textContent = decodeURIComponent(params['stringSignIn']);
$('email-label').textContent = decodeURIComponent(params['stringEmail']);
@@ -59,4 +61,26 @@ function load() {
window.parent.postMessage({'method': 'loginUILoaded'}, 'chrome://oobe/');
}
-document.addEventListener('DOMContentLoaded', load);
+/**
+ * Handles initialization message from parent page.
+ * @param {MessageEvent} e
+ */
+function handleInitializeMessage(e) {
+ var ALLOWED_PARENT_ORIGINS = [
+ 'chrome://oobe',
+ 'chrome://chrome-signin'
+ ];
+
+ if (ALLOWED_PARENT_ORIGINS.indexOf(e.origin) == -1)
+ return;
+
+ window.removeEventListener('message', handleInitializeMessage);
+
+ var params = e.data;
+ params.parentPage = e.origin;
+ load(params);
+}
+
+document.addEventListener('DOMContentLoaded', function() {
+ window.addEventListener('message', handleInitializeMessage);
+});
« 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