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

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

Issue 2179803002: arc: Use location service consent. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebae 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 115
115 var scriptSetCountryCode = 'document.countryCode = \'' + countryCode + '\';'; 116 var scriptSetCountryCode = 'document.countryCode = \'' + countryCode + '\';';
116 termsView.addContentScripts([ 117 termsView.addContentScripts([
117 { name: 'preProcess', 118 { name: 'preProcess',
118 matches: ['https://play.google.com/*'], 119 matches: ['https://play.google.com/*'],
119 js: { code: scriptSetCountryCode }, 120 js: { code: scriptSetCountryCode },
120 run_at: 'document_start' 121 run_at: 'document_start'
121 }, 122 },
122 { name: 'postProcess', 123 { name: 'postProcess',
123 matches: ['https://play.google.com/*'], 124 matches: ['https://play.google.com/*'],
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 doc.getElementById('text-metrics').innerHTML = text; 160 doc.getElementById('text-metrics').innerHTML = text;
160 doc.getElementById('settings-link').addEventListener('click', onSettings); 161 doc.getElementById('settings-link').addEventListener('click', onSettings);
161 doc.getElementById('learn-more-link-metrics').addEventListener('click', 162 doc.getElementById('learn-more-link-metrics').addEventListener('click',
162 onLearnMore); 163 onLearnMore);
163 164
164 // Applying metrics mode changes page layout, update terms height. 165 // Applying metrics mode changes page layout, update terms height.
165 updateTermsHeight(); 166 updateTermsHeight();
166 } 167 }
167 168
168 /** 169 /**
169 * Sets current metrics mode. 170 * Sets current backup and restore mode.
170 * @param {string} text String used to display next to checkbox. 171 * @param {string} text String used to display next to checkbox.
171 * @param {boolean} defaultCheckValue Defines the default value for backup and 172 * @param {boolean} defaultCheckValue Defines the default value for backup and
172 * restore checkbox. 173 * restore checkbox.
173 */ 174 */
174 function setBackupRestoreMode(text, defaultCheckValue) { 175 function setBackupRestoreMode(text, defaultCheckValue) {
175 var doc = appWindow.contentWindow.document; 176 var doc = appWindow.contentWindow.document;
176 doc.getElementById('enable-backup-restore').checked = defaultCheckValue; 177 doc.getElementById('enable-backup-restore').checked = defaultCheckValue;
177 178
178 doc.getElementById('text-backup-restore').innerHTML = text; 179 doc.getElementById('text-backup-restore').innerHTML = text;
179 doc.getElementById('learn-more-link-backup-restore').addEventListener('click', 180 doc.getElementById('learn-more-link-backup-restore').addEventListener('click',
180 onLearnMore); 181 onLearnMore);
181 } 182 }
182 183
183 /** 184 /**
185 * Sets current usage of location service opt in mode.
186 * @param {string} text String used to display next to checkbox.
187 * @param {boolean} defaultCheckValue Defines the default value for location
188 * service opt in.
189 */
190 function setLocationServiceMode(text, defaultCheckValue) {
191 var doc = appWindow.contentWindow.document;
192 doc.getElementById('enable-location-service').checked = defaultCheckValue;
193
194 doc.getElementById('text-location-service').innerHTML = text;
195 doc.getElementById('learn-more-link-location-service').
196 addEventListener('click', onLearnMore);
197 }
198
199 /**
184 * Updates terms view height manually because webview is not automatically 200 * Updates terms view height manually because webview is not automatically
185 * resized in case parent div element gets resized. 201 * resized in case parent div element gets resized.
186 */ 202 */
187 function updateTermsHeight() { 203 function updateTermsHeight() {
188 var setTermsHeight = function() { 204 var setTermsHeight = function() {
189 var doc = appWindow.contentWindow.document; 205 var doc = appWindow.contentWindow.document;
190 var termsContainer = doc.getElementById('terms-container'); 206 var termsContainer = doc.getElementById('terms-container');
191 // Reset terms-view height in order to stabilize style computation. For 207 // Reset terms-view height in order to stabilize style computation. For
192 // some reason, child webview affects final result. 208 // some reason, child webview affects final result.
193 termsView.style.height = '0px'; 209 termsView.style.height = '0px';
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 sendNativeMessage('enableMetrics', { 485 sendNativeMessage('enableMetrics', {
470 'enabled': enableMetrics.checked 486 'enabled': enableMetrics.checked
471 }); 487 });
472 } 488 }
473 489
474 var enableBackupRestore = doc.getElementById('enable-backup-restore'); 490 var enableBackupRestore = doc.getElementById('enable-backup-restore');
475 sendNativeMessage('setBackupRestore', { 491 sendNativeMessage('setBackupRestore', {
476 'enabled': enableBackupRestore.checked 492 'enabled': enableBackupRestore.checked
477 }); 493 });
478 494
495 var enableLocationService = doc.getElementById('enable-location-service');
496 sendNativeMessage('setLocationService', {
xiyuan 2016/07/25 18:03:40 nit: wrong indent
khmel 2016/07/25 22:48:48 Done.
497 'enabled': enableLocationService.checked
498 });
499
479 sendNativeMessage('startLso'); 500 sendNativeMessage('startLso');
480 }; 501 };
481 502
482 var onCancel = function() { 503 var onCancel = function() {
483 if (appWindow) { 504 if (appWindow) {
484 windowClosedInternally = false; 505 windowClosedInternally = false;
485 appWindow.close(); 506 appWindow.close();
486 appWindow = null; 507 appWindow = null;
487 } 508 }
488 }; 509 };
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 type: 'chrome', 559 type: 'chrome',
539 color: '#ffffff' 560 color: '#ffffff'
540 }, 561 },
541 'innerBounds': { 562 'innerBounds': {
542 'width': INNER_WIDTH, 563 'width': INNER_WIDTH,
543 'height': INNER_HEIGHT 564 'height': INNER_HEIGHT
544 } 565 }
545 }; 566 };
546 chrome.app.window.create('main.html', options, onWindowCreated); 567 chrome.app.window.create('main.html', options, onWindowCreated);
547 }); 568 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698