Chromium Code Reviews| 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 |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..8fe08f6333f22e3b29c2cb764ac63cbcd874d3b0 |
| --- /dev/null |
| +++ b/chrome/browser/resources/gaia_auth/offline.js |
| @@ -0,0 +1,50 @@ |
| +// Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +/** |
| + * @fileoverview Offline login implementation. |
| + */ |
| + |
| +function load() { |
| + var params = getUrlSearchParams(location.search); |
| + |
| + // Setup localized strings. |
| + var signInTitle = $('sign-in-title'); |
| + var emailLabel = $('email-label'); |
| + var passwordLabel = $('password-label'); |
| + var submitButton = $('submit-button'); |
| + var errorSpan = $('errormsg-alert'); |
|
csilv
2012/05/25 22:38:39
nit/optional. these vars are only used once, woul
zel
2012/05/25 23:33:53
Done.
|
| + |
| + signInTitle.textContent = decodeURIComponent(params['stringSignIn']); |
| + emailLabel.textContent = decodeURIComponent(params['stringEmail']); |
| + passwordLabel.textContent = decodeURIComponent(params['stringPassword']); |
| + submitButton.value = decodeURIComponent(params['stringSignIn']); |
| + errorSpan.textContent = decodeURIComponent(params['stringError']); |
| + |
| + // Setup actions. |
| + var form = $('offline-login-form'); |
| + form.addEventListener('submit', function(e) { |
| + var msg = { |
| + 'method': 'offlineLogin', |
| + 'email': form.email.value, |
| + 'password': form.password.value |
| + }; |
| + window.parent.postMessage(msg, 'chrome://oobe/'); |
| + e.preventDefault(); |
| + }); |
| + |
| + var email = params['email']; |
| + if (email) { |
| + // Email is present, which means that unsuccessful login attempt has been |
| + // made. Try to mimic Gaia's behaviour. |
| + form.email.value = email; |
| + form.password.classList.add('form-error'); |
| + form.password.focus(); |
| + } else { |
| + form.email.focus(); |
| + } |
| + window.parent.postMessage({'method': 'loginUILoaded'}, 'chrome://oobe/'); |
| +} |
| + |
| +document.addEventListener('DOMContentLoaded', load); |