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

Unified Diff: chrome/browser/resources/signin_error/signin_error.js

Issue 2274013002: [Signin Error Dialog] (1/3) Added necessary web components (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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/signin_error/signin_error.js
diff --git a/chrome/browser/resources/signin_error/signin_error.js b/chrome/browser/resources/signin_error/signin_error.js
new file mode 100644
index 0000000000000000000000000000000000000000..28c179beaffa91e68d1b92307486d78e4a947e32
--- /dev/null
+++ b/chrome/browser/resources/signin_error/signin_error.js
@@ -0,0 +1,57 @@
+/* Copyright 2016 The Chromium Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file. */
+
+cr.define('signin.error', function() {
+ 'use strict';
+
+ function onConfirm(e) {
+ chrome.send('confirm');
+ }
+
+ function onSwitchToExistingProfile(e) {
+ chrome.send('switchToExistingProfile');
+ }
+
+ function onLearnMore(e) {
+ chrome.send('learnMore');
+ }
+
+ function initialize() {
+ document.addEventListener('keydown', onKeyDown);
+ $('primaryConfirmButton').addEventListener('click', onConfirm);
+ $('secondaryConfirmButton').addEventListener('click', onConfirm);
+ $('switchButton').addEventListener('click', onSwitchToExistingProfile);
+ $('learnMoreLink').addEventListener('click', onLearnMore);
+ chrome.send('initializedWithSize', [document.body.scrollHeight]);
+ }
+
+ function clearFocus() {
tommycli 2016/08/24 17:22:52 Can we confirm that this is still needed? Esp. if
Jane 2016/08/25 16:35:29 Confirmed that on mac, the "Learn more" link would
+ document.activeElement.blur();
+ }
+
+ function onKeyDown(e) {
tommycli 2016/08/24 17:22:52 nit: would be good to make the order of these func
Jane 2016/08/25 16:35:29 Done nit. I talked to anthonyvd@ who did this for
+ // If the currently focused element isn't something that performs an action
+ // on "enter" being pressed and the user hits "enter", perform the default
+ // action of the dialog, which is "OK".
+ if (e.key == 'Enter' &&
+ !/^(A|PAPER-BUTTON)$/.test(document.activeElement.tagName)) {
+ $('primaryConfirmButton').click();
+ e.preventDefault();
+ }
+ }
+
+ function removeSwitchButton() {
+ $('switchButton').style.display = 'none';
+ $('secondaryConfirmButton').style.display = 'none';
+ $('primaryConfirmButton').style.display = '';
+ }
+
+ return {
+ clearFocus: clearFocus,
+ initialize: initialize,
+ removeSwitchButton: removeSwitchButton
+ };
+});
+
+document.addEventListener('DOMContentLoaded', signin.error.initialize);

Powered by Google App Engine
This is Rietveld 408576698