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() {
10 var CONTEXT_KEY_USAGE_STATS_ENABLED = 'usageStatsEnabled';
14 decorate: function() {
15 $('eula-chrome-credits-link').hidden = true;
16 $('eula-chromeos-credits-link').hidden = true;
17 $('stats-help-link').addEventListener('click', function(event) {
18 chrome.send('eulaOnLearnMore');
20 $('installation-settings-link').addEventListener(
21 'click', function(event) {
22 chrome.send('eulaOnInstallationSettingsPopupOpened');
23 $('popup-overlay').hidden = false;
24 $('installation-settings-ok-button').focus();
26 $('installation-settings-ok-button').addEventListener(
27 'click', function(event) {
28 $('popup-overlay').hidden = true;
30 // Do not allow focus leaving the overlay.
31 $('popup-overlay').addEventListener('focusout', function(event) {
32 // WebKit does not allow immediate focus return.
33 window.setTimeout(function() {
34 // TODO(ivankr): focus cycling.
35 $('installation-settings-ok-button').focus();
37 event.preventDefault();
41 $('usage-stats').addEventListener('click', function(event) {
42 self.context.set(CONTEXT_KEY_USAGE_STATS_ENABLED,
43 $('usage-stats').checked);
44 self.commitContextChanges();
45 event.stopPropagation();
50 * Event handler that is invoked when 'chrome://terms' is loaded.
52 onFrameLoad: function() {
53 $('accept-button').disabled = false;
54 $('eula').classList.remove('eula-loading');
55 // Initially, the back button is focused and the accept button is
57 // Move the focus to the accept button now but only if the user has not
58 // moved the focus anywhere in the meantime.
59 if (!$('back-button').blurred)
60 $('accept-button').focus();
64 * Event handler that is invoked just before the screen is shown.
65 * @param {object} data Screen init payload.
67 onBeforeShow: function() {
68 $('eula').classList.add('eula-loading');
69 $('cros-eula-frame').onload = this.onFrameLoad;
70 $('accept-button').disabled = true;
71 $('cros-eula-frame').src = 'chrome://terms';
75 * Header text of the screen.
79 return loadTimeData.getString('eulaScreenTitle');
83 * Buttons in oobe wizard's button strip.
84 * @type {Array} Array of Buttons.
89 var backButton = this.declareButton('back-button');
90 backButton.textContent = loadTimeData.getString('back');
91 buttons.push(backButton);
93 var acceptButton = this.declareButton('accept-button');
94 acceptButton.disabled = true;
95 acceptButton.classList.add('preserve-disabled-state');
96 acceptButton.textContent = loadTimeData.getString('acceptAgreement');
97 acceptButton.addEventListener('click', function(e) {
98 $('eula').classList.add('loading'); // Mark EULA screen busy.
102 buttons.push(acceptButton);
108 * Returns a control which should receive an initial focus.
110 get defaultControl() {
111 return $('accept-button').disabled ? $('back-button') :
115 enableKeyboardFlow: function() {
116 $('eula-chrome-credits-link').hidden = false;
117 $('eula-chromeos-credits-link').hidden = false;
118 $('eula-chrome-credits-link').addEventListener('click',
120 chrome.send('eulaOnChromeCredits');
122 $('eula-chromeos-credits-link').addEventListener('click',
124 chrome.send('eulaOnChromeOSCredits');
129 * Updates localized content of the screen that is not updated via template.
131 updateLocalizedContent: function() {
132 // Force iframes to refresh. It's only available method because we have
133 // no access to iframe.contentWindow.
134 if ($('cros-eula-frame').src) {
135 $('cros-eula-frame').src = $('cros-eula-frame').src;
137 if ($('oem-eula-frame').src) {
138 $('oem-eula-frame').src = $('oem-eula-frame').src;