1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
6 * @fileoverview Oobe Terms of Service screen implementation.
9 login.createScreen('TermsOfServiceScreen', 'terms-of-service',
13 'setTermsOfServiceLoadError',
18 * Updates headings on the screen to indicate that the Terms of Service
19 * being shown belong to |domain|.
20 * @param {string} domain The domain whose Terms of Service are being shown.
22 setDomain: function(domain) {
23 $('tos-heading').textContent =
24 loadTimeData.getStringF('termsOfServiceScreenHeading', domain);
25 $('tos-subheading').textContent =
26 loadTimeData.getStringF('termsOfServiceScreenSubheading', domain);
27 $('tos-content-heading').textContent =
28 loadTimeData.getStringF('termsOfServiceContentHeading', domain);
32 * Displays an error message on the Terms of Service screen. Called when the
33 * download of the Terms of Service has failed.
35 setTermsOfServiceLoadError: function() {
36 this.classList.remove('tos-loading');
37 this.classList.add('error');
41 * Displays the given |termsOfService|, enables the accept button and moves
43 * @param {string} termsOfService The terms of service, as plain text.
45 setTermsOfService: function(termsOfService) {
46 this.classList.remove('tos-loading');
47 $('tos-content-main').textContent = termsOfService;
48 $('tos-accept-button').disabled = false;
49 // Initially, the back button is focused and the accept button is
51 // Move the focus to the accept button now but only if the user has not
52 // moved the focus anywhere in the meantime.
53 if (!$('tos-back-button').blurred)
54 $('tos-accept-button').focus();
58 * Buttons in Oobe wizard's button strip.
59 * @type {array} Array of Buttons.
64 var backButton = this.ownerDocument.createElement('button');
65 backButton.id = 'tos-back-button';
66 backButton.textContent =
67 loadTimeData.getString('termsOfServiceBackButton');
68 backButton.addEventListener('click', function(event) {
69 $('tos-back-button').disabled = true;
70 $('tos-accept-button').disabled = true;
71 chrome.send('termsOfServiceBack');
73 backButton.addEventListener('blur', function(event) {
76 buttons.push(backButton);
78 var acceptButton = this.ownerDocument.createElement('button');
79 acceptButton.id = 'tos-accept-button';
80 acceptButton.disabled = true;
81 acceptButton.classList.add('preserve-disabled-state');
82 acceptButton.textContent =
83 loadTimeData.getString('termsOfServiceAcceptButton');
84 acceptButton.addEventListener('click', function(event) {
85 $('tos-back-button').disabled = true;
86 $('tos-accept-button').disabled = true;
87 chrome.send('termsOfServiceAccept');
89 buttons.push(acceptButton);
95 * Returns the control which should receive initial focus.
97 get defaultControl() {
98 return $('tos-accept-button').disabled ? $('tos-back-button') :
99 $('tos-accept-button');
103 * Event handler that is invoked just before the screen is shown.
104 * @param {object} data Screen init payload.
106 onBeforeShow: function(data) {
107 Oobe.getInstance().headerHidden = true;