Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Side by Side Diff: chrome/browser/resources/chromeos/arc_support/background.js

Issue 2225933002: Suppress ToS and reflect admin policy in ARC++ welcome screen (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add OS_CHROMEOS checks Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * UI Pages. Note the order must be in sync with the ArcAuthService::UIPage 6 * UI Pages. Note the order must be in sync with the ArcAuthService::UIPage
7 * enum. 7 * enum.
8 * @type {Array<string>} 8 * @type {Array<string>}
9 */ 9 */
10 var UI_PAGES = ['none', 10 var UI_PAGES = ['none',
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 * @param {!Object} data Localized strings and relevant information. 103 * @param {!Object} data Localized strings and relevant information.
104 * @param {string} deviceId Current device id. 104 * @param {string} deviceId Current device id.
105 */ 105 */
106 function initialize(data, deviceId) { 106 function initialize(data, deviceId) {
107 currentDeviceId = deviceId; 107 currentDeviceId = deviceId;
108 var doc = appWindow.contentWindow.document; 108 var doc = appWindow.contentWindow.document;
109 var loadTimeData = appWindow.contentWindow.loadTimeData; 109 var loadTimeData = appWindow.contentWindow.loadTimeData;
110 loadTimeData.data = data; 110 loadTimeData.data = data;
111 appWindow.contentWindow.i18nTemplate.process(doc, loadTimeData); 111 appWindow.contentWindow.i18nTemplate.process(doc, loadTimeData);
112 var countryCode = data.countryCode.toLowerCase(); 112 var countryCode = data.countryCode.toLowerCase();
113 setBackupRestoreMode(data.textBackupRestore, data.backupRestoreEnabled); 113 setBackupRestoreMode(data.textBackupRestore, data.backupRestoreEnabled,
114 setLocationServiceMode(data.textLocationService, data.locationServiceEnabled); 114 data.backupRestoreManaged, data.managementText);
115 setLocationServiceMode(data.textLocationService, data.locationServiceEnabled,
116 data.locationServiceManaged, data.managementText);
117 hideTermsIfManaged(data.profileManaged);
115 118
116 var scriptSetCountryCode = 'document.countryCode = \'' + countryCode + '\';'; 119 var scriptSetCountryCode = 'document.countryCode = \'' + countryCode + '\';';
117 termsView.addContentScripts([ 120 termsView.addContentScripts([
118 { name: 'preProcess', 121 { name: 'preProcess',
119 matches: ['https://play.google.com/*'], 122 matches: ['https://play.google.com/*'],
120 js: { code: scriptSetCountryCode }, 123 js: { code: scriptSetCountryCode },
121 run_at: 'document_start' 124 run_at: 'document_start'
122 }, 125 },
123 { name: 'postProcess', 126 { name: 'postProcess',
124 matches: ['https://play.google.com/*'], 127 matches: ['https://play.google.com/*'],
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 168
166 // Applying metrics mode changes page layout, update terms height. 169 // Applying metrics mode changes page layout, update terms height.
167 updateTermsHeight(); 170 updateTermsHeight();
168 } 171 }
169 172
170 /** 173 /**
171 * Sets current backup and restore mode. 174 * Sets current backup and restore mode.
172 * @param {string} text String used to display next to checkbox. 175 * @param {string} text String used to display next to checkbox.
173 * @param {boolean} defaultCheckValue Defines the default value for backup and 176 * @param {boolean} defaultCheckValue Defines the default value for backup and
174 * restore checkbox. 177 * restore checkbox.
178 * @param {boolean} isManaged Defines whether this setting is set by policy.
179 * @param {string} managementText String explaining that the setting is enforced
180 * by the administrator.
175 */ 181 */
176 function setBackupRestoreMode(text, defaultCheckValue) { 182 function setBackupRestoreMode(text, defaultCheckValue, isManaged,
183 managementText) {
177 var doc = appWindow.contentWindow.document; 184 var doc = appWindow.contentWindow.document;
178 doc.getElementById('enable-backup-restore').checked = defaultCheckValue; 185 doc.getElementById('enable-backup-restore').checked = defaultCheckValue;
186 doc.getElementById('enable-backup-restore').disabled = isManaged;
179 187
180 doc.getElementById('text-backup-restore').innerHTML = text; 188 doc.getElementById('text-backup-restore').innerHTML = text;
189 doc.getElementById('text-backup-restore').disabled = isManaged;
181 doc.getElementById('learn-more-link-backup-restore').addEventListener('click', 190 doc.getElementById('learn-more-link-backup-restore').addEventListener('click',
182 onLearnMore); 191 onLearnMore);
192
193 if (isManaged) {
194 doc.getElementById('backup-management-indicator').style.display = 'block';
195 doc.getElementById('backup-management-indicator').title = managementText;
196 }
183 } 197 }
184 198
185 /** 199 /**
186 * Sets current usage of location service opt in mode. 200 * Sets current usage of location service opt in mode.
187 * @param {string} text String used to display next to checkbox. 201 * @param {string} text String used to display next to checkbox.
188 * @param {boolean} defaultCheckValue Defines the default value for location 202 * @param {boolean} defaultCheckValue Defines the default value for location
189 * service opt in. 203 * service opt in.
204 * @param {boolean} isManaged Defines whether this setting is set by policy.
205 * @param {string} managementText String explaining that the setting is enforced
206 * by the administrator.
190 */ 207 */
191 function setLocationServiceMode(text, defaultCheckValue) { 208 function setLocationServiceMode(text, defaultCheckValue, isManaged,
209 managementText) {
192 var doc = appWindow.contentWindow.document; 210 var doc = appWindow.contentWindow.document;
193 doc.getElementById('enable-location-service').checked = defaultCheckValue; 211 doc.getElementById('enable-location-service').checked = defaultCheckValue;
212 doc.getElementById('enable-location-service').disabled = isManaged;
194 213
195 doc.getElementById('text-location-service').innerHTML = text; 214 doc.getElementById('text-location-service').innerHTML = text;
215 doc.getElementById('text-location-service').disabled = isManaged;
196 doc.getElementById('learn-more-link-location-service'). 216 doc.getElementById('learn-more-link-location-service').
197 addEventListener('click', onLearnMore); 217 addEventListener('click', onLearnMore);
218 if (isManaged) {
219 doc.getElementById('location-management-indicator').style.display = 'block';
220 doc.getElementById('location-management-indicator').title = managementText;
221 }
198 } 222 }
199 223
200 /** 224 /**
225 * Hides Terms of Service if the account is managed, because the admin already
226 * agreed to the terms.
227 * @param {boolean} profileManaged Whether the account is managed on Chrome OS.
228 */
229 function hideTermsIfManaged(profileManaged) {
230 var doc = appWindow.contentWindow.document;
231 if (profileManaged) {
232 doc.getElementById('terms-title').style.display = 'none';
233 doc.getElementById('terms-container').style.display = 'none';
234 }
235 }
236
237 /**
201 * Updates terms view height manually because webview is not automatically 238 * Updates terms view height manually because webview is not automatically
202 * resized in case parent div element gets resized. 239 * resized in case parent div element gets resized.
203 */ 240 */
204 function updateTermsHeight() { 241 function updateTermsHeight() {
205 var setTermsHeight = function() { 242 var setTermsHeight = function() {
206 var doc = appWindow.contentWindow.document; 243 var doc = appWindow.contentWindow.document;
207 var termsContainer = doc.getElementById('terms-container'); 244 var termsContainer = doc.getElementById('terms-container');
208 // Reset terms-view height in order to stabilize style computation. For 245 // Reset terms-view height in order to stabilize style computation. For
209 // some reason, child webview affects final result. 246 // some reason, child webview affects final result.
210 termsView.style.height = '0px'; 247 termsView.style.height = '0px';
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 type: 'chrome', 599 type: 'chrome',
563 color: '#ffffff' 600 color: '#ffffff'
564 }, 601 },
565 'innerBounds': { 602 'innerBounds': {
566 'width': INNER_WIDTH, 603 'width': INNER_WIDTH,
567 'height': INNER_HEIGHT 604 'height': INNER_HEIGHT
568 } 605 }
569 }; 606 };
570 chrome.app.window.create('main.html', options, onWindowCreated); 607 chrome.app.window.create('main.html', options, onWindowCreated);
571 }); 608 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698