1 // Copyright (c) 2012 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 eula screen implementation.
9 login.createScreen('EulaScreen', 'eula', function() {
12 decorate: function() {
13 $('stats-help-link').addEventListener('click', function(event) {
14 chrome.send('eulaOnLearnMore');
16 $('installation-settings-link').addEventListener(
17 'click', function(event) {
18 chrome.send('eulaOnInstallationSettingsPopupOpened');
19 $('popup-overlay').hidden = false;
20 $('installation-settings-ok-button').focus();
22 $('installation-settings-ok-button').addEventListener(
23 'click', function(event) {
24 $('popup-overlay').hidden = true;
26 // Do not allow focus leaving the overlay.
27 $('popup-overlay').addEventListener('focusout', function(event) {
28 // WebKit does not allow immediate focus return.
29 window.setTimeout(function() {
30 // TODO(ivankr): focus cycling.
31 $('installation-settings-ok-button').focus();
33 event.preventDefault();
38 * Event handler that is invoked when 'chrome://terms' is loaded.
40 onFrameLoad: function() {
41 $('accept-button').disabled = false;
42 $('eula').classList.remove('eula-loading');
43 // Initially, the back button is focused and the accept button is
45 // Move the focus to the accept button now but only if the user has not
46 // moved the focus anywhere in the meantime.
47 if (!$('back-button').blurred)
48 $('accept-button').focus();
52 * Event handler that is invoked just before the screen is shown.
53 * @param {object} data Screen init payload.
55 onBeforeShow: function() {
56 $('eula').classList.add('eula-loading');
57 $('cros-eula-frame').onload = this.onFrameLoad;
58 $('accept-button').disabled = true;
59 $('cros-eula-frame').src = 'chrome://terms';
63 * Header text of the screen.
67 return loadTimeData.getString('eulaScreenTitle');
71 * Buttons in oobe wizard's button strip.
72 * @type {Array} Array of Buttons.
77 var backButton = this.ownerDocument.createElement('button');
78 backButton.id = 'back-button';
79 backButton.textContent = loadTimeData.getString('back');
80 backButton.addEventListener('click', function(e) {
81 chrome.send('eulaOnExit', [false, $('usage-stats').checked]);
84 buttons.push(backButton);
86 var acceptButton = this.ownerDocument.createElement('button');
87 acceptButton.id = 'accept-button';
88 acceptButton.disabled = true;
89 acceptButton.classList.add('preserve-disabled-state');
90 acceptButton.textContent = loadTimeData.getString('acceptAgreement');
91 acceptButton.addEventListener('click', function(e) {
92 $('eula').classList.add('loading'); // Mark EULA screen busy.
93 chrome.send('eulaOnExit', [true, $('usage-stats').checked]);
96 buttons.push(acceptButton);
102 * Returns a control which should receive an initial focus.
104 get defaultControl() {
105 return $('accept-button').disabled ? $('back-button') :
110 * Updates localized content of the screen that is not updated via template.
112 updateLocalizedContent: function() {
113 // Force iframes to refresh. It's only available method because we have
114 // no access to iframe.contentWindow.
115 if ($('cros-eula-frame').src) {
116 $('cros-eula-frame').src = $('cros-eula-frame').src;
118 if ($('oem-eula-frame').src) {
119 $('oem-eula-frame').src = $('oem-eula-frame').src;