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

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

Issue 2235293002: arc: Support managed Arc and managed Location Service and B&R consents. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2225933002_managed_BR_LOC
Patch Set: update 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 hideTermsIfManaged(data.profileManaged);
114 setLocationServiceMode(data.textLocationService, data.locationServiceEnabled); 114
115 doc.getElementById('text-backup-restore').innerHTML = data.textBackupRestore;
116 doc.getElementById('learn-more-link-backup-restore').
117 addEventListener('click', onLearnMore);
118
119 doc.getElementById('text-location-service').innerHTML =
120 data.textLocationService;
121 doc.getElementById('learn-more-link-location-service').
122 addEventListener('click', onLearnMore);
115 123
116 var scriptSetCountryCode = 'document.countryCode = \'' + countryCode + '\';'; 124 var scriptSetCountryCode = 'document.countryCode = \'' + countryCode + '\';';
117 termsView.addContentScripts([ 125 termsView.addContentScripts([
118 { name: 'preProcess', 126 { name: 'preProcess',
119 matches: ['https://play.google.com/*'], 127 matches: ['https://play.google.com/*'],
120 js: { code: scriptSetCountryCode }, 128 js: { code: scriptSetCountryCode },
121 run_at: 'document_start' 129 run_at: 'document_start'
122 }, 130 },
123 { name: 'postProcess', 131 { name: 'postProcess',
124 matches: ['https://play.google.com/*'], 132 matches: ['https://play.google.com/*'],
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 doc.getElementById('settings-link').addEventListener('click', onSettings); 170 doc.getElementById('settings-link').addEventListener('click', onSettings);
163 doc.getElementById('learn-more-link-metrics').addEventListener('click', 171 doc.getElementById('learn-more-link-metrics').addEventListener('click',
164 onLearnMore); 172 onLearnMore);
165 173
166 // Applying metrics mode changes page layout, update terms height. 174 // Applying metrics mode changes page layout, update terms height.
167 updateTermsHeight(); 175 updateTermsHeight();
168 } 176 }
169 177
170 /** 178 /**
171 * Sets current backup and restore mode. 179 * Sets current backup and restore mode.
172 * @param {string} text String used to display next to checkbox.
173 * @param {boolean} defaultCheckValue Defines the default value for backup and 180 * @param {boolean} defaultCheckValue Defines the default value for backup and
174 * restore checkbox. 181 * restore checkbox.
182 * @param {boolean} isManaged Defines whether this setting is set by policy.
175 */ 183 */
176 function setBackupRestoreMode(text, defaultCheckValue) { 184 function setBackupRestoreMode(defaultCheckValue, isManaged) {
xiyuan 2016/08/11 20:01:11 nit: defaultCheckValue -> enabled, since this is t
khmel 2016/08/12 20:33:23 Done.
177 var doc = appWindow.contentWindow.document; 185 var doc = appWindow.contentWindow.document;
178 doc.getElementById('enable-backup-restore').checked = defaultCheckValue; 186 doc.getElementById('enable-backup-restore').checked = defaultCheckValue;
179 187 doc.getElementById('enable-backup-restore').disabled = isManaged;
180 doc.getElementById('text-backup-restore').innerHTML = text; 188 doc.getElementById('text-backup-restore').disabled = isManaged;
181 doc.getElementById('learn-more-link-backup-restore').addEventListener('click',
182 onLearnMore);
183 } 189 }
184 190
185 /** 191 /**
186 * Sets current usage of location service opt in mode. 192 * Sets current usage of location service opt in mode.
187 * @param {string} text String used to display next to checkbox.
188 * @param {boolean} defaultCheckValue Defines the default value for location 193 * @param {boolean} defaultCheckValue Defines the default value for location
189 * service opt in. 194 * service opt in.
195 * @param {boolean} isManaged Defines whether this setting is set by policy.
190 */ 196 */
191 function setLocationServiceMode(text, defaultCheckValue) { 197 function setLocationServiceMode(defaultCheckValue, isManaged) {
xiyuan 2016/08/11 20:01:11 nit: defaultCheckValue -> enabled
khmel 2016/08/12 20:33:23 Done.
192 var doc = appWindow.contentWindow.document; 198 var doc = appWindow.contentWindow.document;
193 doc.getElementById('enable-location-service').checked = defaultCheckValue; 199 doc.getElementById('enable-location-service').checked = defaultCheckValue;
194 200 doc.getElementById('enable-location-service').disabled = isManaged;
195 doc.getElementById('text-location-service').innerHTML = text; 201 doc.getElementById('text-location-service').disabled = isManaged;
196 doc.getElementById('learn-more-link-location-service').
197 addEventListener('click', onLearnMore);
198 } 202 }
199 203
200 /** 204 /**
205 * Hides Terms of Service if the account is managed, because the admin already
206 * agreed to the terms.
207 * @param {boolean} profileManaged Whether the account is managed on Chrome OS.
208 */
209 function hideTermsIfManaged(profileManaged) {
210 var doc = appWindow.contentWindow.document;
211 if (profileManaged) {
212 doc.getElementById('terms-title').style.visibility = 'hidden';
213 doc.getElementById('terms-container').style.visibility = 'hidden';
214 }
215 }
216
217 /**
201 * Updates terms view height manually because webview is not automatically 218 * Updates terms view height manually because webview is not automatically
202 * resized in case parent div element gets resized. 219 * resized in case parent div element gets resized.
203 */ 220 */
204 function updateTermsHeight() { 221 function updateTermsHeight() {
205 var setTermsHeight = function() { 222 var setTermsHeight = function() {
206 var doc = appWindow.contentWindow.document; 223 var doc = appWindow.contentWindow.document;
207 var termsContainer = doc.getElementById('terms-container'); 224 var termsContainer = doc.getElementById('terms-container');
208 // Reset terms-view height in order to stabilize style computation. For 225 // Reset terms-view height in order to stabilize style computation. For
209 // some reason, child webview affects final result. 226 // some reason, child webview affects final result.
210 termsView.style.height = '0px'; 227 termsView.style.height = '0px';
(...skipping 15 matching lines...) Expand all
226 243
227 if (!appWindow) { 244 if (!appWindow) {
228 console.warn('Received native message when window is not available.'); 245 console.warn('Received native message when window is not available.');
229 return; 246 return;
230 } 247 }
231 248
232 if (message.action == 'initialize') { 249 if (message.action == 'initialize') {
233 initialize(message.data, message.deviceId); 250 initialize(message.data, message.deviceId);
234 } else if (message.action == 'setMetricsMode') { 251 } else if (message.action == 'setMetricsMode') {
235 setMetricsMode(message.text, message.canEnable, message.on); 252 setMetricsMode(message.text, message.canEnable, message.on);
253 } else if (message.action == 'setBackupAndRestoreMode') {
254 setBackupRestoreMode(message.enabled, message.managed);
255 } else if (message.action == 'setLocationServiceMode') {
256 setLocationServiceMode(message.enabled, message.managed);
236 } else if (message.action == 'closeUI') { 257 } else if (message.action == 'closeUI') {
237 closeWindowInternally(); 258 closeWindowInternally();
238 } else if (message.action == 'showPage') { 259 } else if (message.action == 'showPage') {
239 showPageWithStatus(message.page, message.status); 260 showPageWithStatus(message.page, message.status);
240 } else if (message.action == 'setWindowBounds') { 261 } else if (message.action == 'setWindowBounds') {
241 setWindowBounds(); 262 setWindowBounds();
242 } 263 }
243 } 264 }
244 265
245 /** 266 /**
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 type: 'chrome', 583 type: 'chrome',
563 color: '#ffffff' 584 color: '#ffffff'
564 }, 585 },
565 'innerBounds': { 586 'innerBounds': {
566 'width': INNER_WIDTH, 587 'width': INNER_WIDTH,
567 'height': INNER_HEIGHT 588 'height': INNER_HEIGHT
568 } 589 }
569 }; 590 };
570 chrome.app.window.create('main.html', options, onWindowCreated); 591 chrome.app.window.create('main.html', options, onWindowCreated);
571 }); 592 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698