summaryrefslogtreecommitdiff
path: root/chromium/chrome/browser/resources/chromeos/login/screen_device_disabled.js
blob: baaf9c3fd0947486047bfac6a2ec7265a69a1771 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// Copyright 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 Device disabled screen implementation.
 */

login.createScreen('DeviceDisabledScreen', 'device-disabled', function() {
  return {
    EXTERNAL_API: [
      'setEnrollmentDomain',
      'setMessage'
    ],

    /**
     * Ignore any accelerators the user presses on this screen.
     */
    ignoreAccelerators: true,

    /** @override */
    decorate: function() {
      this.setEnrollmentDomain(null);
    },

    /**
     * The visibility of the cancel button in the header bar is controlled by a
     * global. Although the device disabling screen hides the button, a
     * notification intended for an earlier screen (e.g animation finished)
     * could re-show the button. If this happens, the current screen's cancel()
     * method will be shown when the user actually clicks the button. Make sure
     * that this is a no-op.
     */
    cancel: function() {
    },

    /**
     * Event handler that is invoked just before the screen in shown.
     */
    onBeforeShow: function() {
      $('progress-dots').hidden = true;
      var headerBar = $('login-header-bar');
      headerBar.allowCancel = false;
      headerBar.showGuestButton = false;
      headerBar.signinUIState = SIGNIN_UI_STATE.HIDDEN;
    },

    /**
      * Updates the explanation shown to the user. The explanation will indicate
      * that the device is owned by |enrollment_domain|. If |enrollment_domain|
      * is null or empty, a generic explanation will be used instead that does
      * not reference any domain.
      * @param {string} enrollment_domain The domain that owns the device.
      */
    setEnrollmentDomain: function(enrollment_domain) {
      if (enrollment_domain) {
        // The contents of |enrollment_domain| is untrusted. Set the resulting
        // string as |textContent| so that it gets treated as plain text and
        // cannot be used to inject JS or HTML.
        $('device-disabled-explanation').textContent = loadTimeData.getStringF(
            'deviceDisabledExplanationWithDomain',
            enrollment_domain);
      } else {
        $('device-disabled-explanation').textContent = loadTimeData.getString(
            'deviceDisabledExplanationWithoutDomain');
      }
    },


    /**
      * Sets the message to show to the user.
      * @param {string} message The message to show to the user.
      */
    setMessage: function(message) {
      // The contents of |message| is untrusted. Set it as |textContent| so that
      // it gets treated as plain text and cannot be used to inject JS or HTML.
      $('device-disabled-message').textContent = message;
    }
  };
});