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

Unified Diff: chrome/browser/resources/chromeos/login/oobe_screen_enable_debugging.js

Issue 539273002: Added UI to enable debugging features on CrOS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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/chromeos/login/oobe_screen_enable_debugging.js
diff --git a/chrome/browser/resources/chromeos/login/oobe_screen_enable_debugging.js b/chrome/browser/resources/chromeos/login/oobe_screen_enable_debugging.js
new file mode 100644
index 0000000000000000000000000000000000000000..8e328196e828b6b0d6fee71c1b6b0a2664e2e1f0
--- /dev/null
+++ b/chrome/browser/resources/chromeos/login/oobe_screen_enable_debugging.js
@@ -0,0 +1,175 @@
+// Copyright (c) 2014 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.
+
+/**
+ * @fileoverview Enable developer features screen implementation.
+ */
+
+login.createScreen('EnableDebuggingScreen', 'debugging', function() {
+ return {
+
+ /* Possible UI states of the reset screen. */
+ UI_STATE: {
+ ERROR: -1,
+ REMOVE_PROTECTION: 1,
+ SETUP: 2,
+ WAIT: 3,
+ DONE: 4
+ },
+
+ EXTERNAL_API: [
+ 'updateState'
+ ],
+
+ /** @override */
+ decorate: function() {
+ $('enable-debugging-help-link').addEventListener('click',
+ function(event) {
+ chrome.send('enableDebuggingOnLearnMore');
+ });
+
+ var password = $('enable-debugging-password');
+ var password2 = $('enable-debugging-password2');
+ $('enable-debugging-password').addEventListener(
+ 'keyup', this.onPasswordChanged_.bind(this));
xiyuan 2014/10/30 03:52:08 nit: There is a 'input' event for <input> and <tex
zel 2014/10/31 01:22:26 Done.
+ $('enable-debugging-password2').addEventListener(
+ 'keyup', this.onPasswordChanged_.bind(this));
+ },
+
+ /**
+ * Header text of the screen.
+ * @type {string}
+ */
+ get header() {
+ return loadTimeData.getString('enableDebuggingScreenTitle');
+ },
+
+ /**
+ * Buttons in oobe wizard's button strip.
+ * @type {array} Array of Buttons.
+ */
+ get buttons() {
+ var buttons = [];
+ var rootfsRemoveButton = this.ownerDocument.createElement('button');
+ rootfsRemoveButton.id = 'debugging-remove-protection-button';
+ rootfsRemoveButton.textContent =
+ loadTimeData.getString('enableDebuggingRemoveButton');
+ rootfsRemoveButton.addEventListener('click', function(e) {
+ chrome.send('enableDebuggingOnRemoveRootFSProtection');
+ e.stopPropagation();
+ });
+ buttons.push(rootfsRemoveButton);
+
+ var enableButton = this.ownerDocument.createElement('button');
+ enableButton.id = 'debugging-enable-button';
+ enableButton.textContent =
+ loadTimeData.getString('enableDebuggingEnableButton');
+ enableButton.addEventListener('click', function(e) {
+ chrome.send('enableDebuggingOnSetup',
+ [$('enable-debugging-password').value]);
+ e.stopPropagation();
+ });
+ buttons.push(enableButton);
+
+ var cancelButton = this.ownerDocument.createElement('button');
+ cancelButton.id = 'debugging-cancel-button';
+ cancelButton.textContent =
+ loadTimeData.getString('enableDebuggingCancelButton');
+ cancelButton.addEventListener('click', function(e) {
+ chrome.send('enableDebuggingOnCancel');
+ e.stopPropagation();
+ });
+ buttons.push(cancelButton);
+
+ var okButton = this.ownerDocument.createElement('button');
+ okButton.id = 'debugging-ok-button';
+ okButton.textContent =
+ loadTimeData.getString('enableDebuggingOKButton');
+ okButton.addEventListener('click', function(e) {
+ chrome.send('enableDebuggingOnDone');
+ e.stopPropagation();
+ });
+ buttons.push(okButton);
+
+ return buttons;
+ },
+
+ /**
+ * Returns a control which should receive an initial focus.
+ */
+ get defaultControl() {
+ if (this.state_ == this.UI_STATE.REMOVE_PROTECTION)
+ return $('debugging-remove-protection-button');
+ else if (this.state_ == this.UI_STATE.SETUP)
+ return $('enable-debugging-password');
+ else if (this.state_ == this.UI_STATE.DONE)
+ return $('debugging-ok-button');
+
+ return $('debugging-cancel-button');
+ },
+
+ /**
+ * Cancels the reset and drops the user back to the login screen.
+ */
+ cancel: function() {
+ chrome.send('enableDebuggingOnCancel');
+ },
+
+ /**
+ * Event handler that is invoked just before the screen in shown.
+ * @param {Object} data Screen init payload.
+ */
+ onBeforeShow: function(data) {
+ if (data === undefined)
+ return;
+
+ if ('needsRootfsRemoval' in data && data['needsRootfsRemoval']) {
+ this.setDialogView_(this.UI_STATE.REMOVE_PROTECTION);
+ } else {
+ this.setDialogView_(this.UI_STATE.SETUP);
+ }
+
+ if (!('isOfficialBuild' in data && data['isOfficialBuild']))
+ $('enable-debugging-help-link').setAttribute('hidden', true);
xiyuan 2014/10/30 03:52:08 nit: we can just do $('enable-debugging-help-link
zel 2014/10/31 01:22:26 Done.
+ },
+
+ onPasswordChanged_: function() {
+ var enableButton = $('debugging-enable-button');
+ var password = $('enable-debugging-password');
+ var password2 = $('enable-debugging-password2');
+ var pwd = password.value;
+ var pwd2 = password2.value;
+ enableButton.disabled = !((pwd.length == 0 && pwd2.length == 0) ||
+ (pwd == pwd2 && pwd.length >= 4));
+ },
+
+ /**
+ * Sets css style for corresponding state of the screen.
+ * @param {string} state.
xiyuan 2014/10/30 03:52:08 nit: |state| seems to be an number.
zel 2014/10/31 01:22:26 Done.
+ * @private
+ */
+ setDialogView_: function(state) {
+ this.state_ = state;
+ this.classList.remove('remove-protection-view');
+ this.classList.remove('setup-view');
+ this.classList.remove('wait-view');
+ this.classList.remove('done-view');
+ if (state == this.UI_STATE.REMOVE_PROTECTION) {
+ this.classList.add('remove-protection-view');
+ } else if (state == this.UI_STATE.SETUP) {
+ this.classList.add('setup-view');
+ } else if (state == this.UI_STATE.DONE) {
+ this.classList.add('done-view');
+ } else if (state == this.UI_STATE.WAIT) {
+ this.classList.add('wait-view');
+ } else { // error
+ console.error('State ' + state + ' is not supported by setDialogView.');
+ }
xiyuan 2014/10/30 03:52:08 nit: we could use classList.toggle to simplify a b
zel 2014/10/31 01:22:26 neat. done.
+ },
+
+ updateState: function(state) {
+ this.setDialogView_(state);
+ }
+ };
+});

Powered by Google App Engine
This is Rietveld 408576698