summaryrefslogtreecommitdiffstats
path: root/chromium/ui/webui/resources/cr_components/managed_footnote/managed_footnote.js
blob: 09ce1cf272828e686d8e667349a8a83cf90ab69a (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
// Copyright 2018 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 Polymer element for indicating that this user is managed by
 * their organization. This component uses the |isManaged| boolean in
 * loadTimeData, and the |managedByOrg| i18n string.
 *
 * If |isManaged| is false, this component is hidden. If |isManaged| is true, it
 * becomes visible.
 */

(function() {
/**
 * URL of the help article for the clickable link.
 * @type {string}
 */
// TODO(nicolaso): Use a p-link instead, once it's available. b/117655761
const HELP_ARTICLE_URL = 'https://support.google.com/chromebook/answer/1331549';

Polymer({
  is: 'managed-footnote',

  behaviors: [I18nBehavior],

  properties: {
    /**
     * Whether the browser is managed by their organization through enterprise
     * policies.
     * @private
     */
    isManaged_: {
      reflectToAttribute: true,
      type: Boolean,
      value: function() {
        return loadTimeData.getBoolean('isManaged');
      },
    },

    /**
     * Localized message to display in the footnote. May contain an <a>
     * element.
     * @private
     */
    message_: String,
  },

  /** @override */
  ready: function() {
    this.message_ = this.i18nAdvanced('managedByOrg', {
      substitutions: [HELP_ARTICLE_URL],
      tags: ['a'],
      attrs: {
        target: (node, v) => v === '_blank',
        href: (node, v) => v === HELP_ARTICLE_URL,
      },
    });

    cr.addWebUIListener('is-managed-changed', managed => {
      loadTimeData.overrideValues({isManaged: managed});
      this.isManaged_ = managed;
    });
  },
});

chrome.send('observeManagedUI');

})();