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

Side by Side Diff: chrome/browser/resources/chromeos/login/screen_arc_terms_of_service.js

Issue 2944703004: Run clang-format on .js files in c/b/r/chromeos (Closed)
Patch Set: Created 3 years, 6 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 * @fileoverview Oobe ARC Terms of Service screen implementation. 6 * @fileoverview Oobe ARC Terms of Service screen implementation.
7 */ 7 */
8 8
9 login.createScreen('ArcTermsOfServiceScreen', 'arc-tos', 9 login.createScreen('ArcTermsOfServiceScreen', 'arc-tos', function() {
10 function() { return { 10 return {
11 EXTERNAL_API: [ 11 EXTERNAL_API: [
12 'setMetricsMode', 12 'setMetricsMode', 'setBackupAndRestoreMode', 'setLocationServicesMode',
13 'setBackupAndRestoreMode',
14 'setLocationServicesMode',
15 'setCountryCode' 13 'setCountryCode'
16 ], 14 ],
17 15
18 /** @override */ 16 /** @override */
19 decorate: function(element) { 17 decorate: function(element) {
20 // Valid newOobeUI is not available at this time. 18 // Valid newOobeUI is not available at this time.
21 }, 19 },
22 20
23 /** 21 /**
24 * Makes sure that UI is initialized and MD mode is correctly set. 22 * Makes sure that UI is initialized and MD mode is correctly set.
(...skipping 16 matching lines...) Expand all
41 } else { 39 } else {
42 $('arc-tos').removeAttribute('md-mode'); 40 $('arc-tos').removeAttribute('md-mode');
43 } 41 }
44 42
45 var closeButtons = document.querySelectorAll('.arc-overlay-close-button'); 43 var closeButtons = document.querySelectorAll('.arc-overlay-close-button');
46 for (var i = 0; i < closeButtons.length; i++) { 44 for (var i = 0; i < closeButtons.length; i++) {
47 closeButtons[i].addEventListener('click', this.hideOverlay.bind(this)); 45 closeButtons[i].addEventListener('click', this.hideOverlay.bind(this));
48 } 46 }
49 47
50 var termsView = this.getElement_('arc-tos-view'); 48 var termsView = this.getElement_('arc-tos-view');
51 var requestFilter = { 49 var requestFilter = {urls: ['<all_urls>'], types: ['main_frame']};
52 urls: ['<all_urls>'],
53 types: ['main_frame']
54 };
55 50
56 termsView.request.onErrorOccurred.addListener( 51 termsView.request.onErrorOccurred.addListener(
57 this.onTermsViewErrorOccurred.bind(this), requestFilter); 52 this.onTermsViewErrorOccurred.bind(this), requestFilter);
58 termsView.addEventListener('contentload', 53 termsView.addEventListener(
59 this.onTermsViewContentLoad.bind(this)); 54 'contentload', this.onTermsViewContentLoad.bind(this));
60 55
61 // Open links from webview in overlay dialog. 56 // Open links from webview in overlay dialog.
62 var self = this; 57 var self = this;
63 termsView.addEventListener('newwindow', function(event) { 58 termsView.addEventListener('newwindow', function(event) {
64 event.preventDefault(); 59 event.preventDefault();
65 self.showUrlOverlay(event.targetUrl); 60 self.showUrlOverlay(event.targetUrl);
66 }); 61 });
67 62
68 termsView.addContentScripts([ 63 termsView.addContentScripts([{
69 { name: 'postProcess', 64 name: 'postProcess',
70 matches: ['https://play.google.com/*'], 65 matches: ['https://play.google.com/*'],
71 css: { files: ['playstore.css'] }, 66 css: {files: ['playstore.css']},
72 js: { files: ['playstore.js'] }, 67 js: {files: ['playstore.js']},
73 run_at: 'document_end' 68 run_at: 'document_end'
74 }]); 69 }]);
75 70
76 this.getElement_('arc-policy-link').onclick = function() { 71 this.getElement_('arc-policy-link').onclick = function() {
77 termsView.executeScript( 72 termsView.executeScript(
78 {code: 'getPrivacyPolicyLink();'}, 73 {code: 'getPrivacyPolicyLink();'}, function(results) {
79 function(results) {
80 if (results && results.length == 1 && 74 if (results && results.length == 1 &&
81 typeof results[0] == 'string') { 75 typeof results[0] == 'string') {
82 self.showUrlOverlay(results[0]); 76 self.showUrlOverlay(results[0]);
83 } else { 77 } else {
84 // currentLanguage can be updated in OOBE but not in Login page. 78 // currentLanguage can be updated in OOBE but not in Login page.
85 // languageList exists in OOBE otherwise use navigator.language. 79 // languageList exists in OOBE otherwise use navigator.language.
86 var currentLanguage; 80 var currentLanguage;
87 var languageList = loadTimeData.getValue('languageList'); 81 var languageList = loadTimeData.getValue('languageList');
88 if (languageList) { 82 if (languageList) {
89 currentLanguage = Oobe.getSelectedValue(languageList); 83 currentLanguage = Oobe.getSelectedValue(languageList);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 preference.parentElement.disabled = managed; 128 preference.parentElement.disabled = managed;
135 }, 129 },
136 130
137 /** 131 /**
138 * Sets current backup and restore mode. 132 * Sets current backup and restore mode.
139 * @param {boolean} enabled Defines the value for backup and restore 133 * @param {boolean} enabled Defines the value for backup and restore
140 * checkbox. 134 * checkbox.
141 * @param {boolean} managed Defines whether this setting is set by policy. 135 * @param {boolean} managed Defines whether this setting is set by policy.
142 */ 136 */
143 setBackupAndRestoreMode: function(enabled, managed) { 137 setBackupAndRestoreMode: function(enabled, managed) {
144 this.setPreference('arc-enable-backup-restore', 138 this.setPreference('arc-enable-backup-restore', enabled, managed);
145 enabled, managed);
146 }, 139 },
147 140
148 /** 141 /**
149 * Sets current usage of location service opt in mode. 142 * Sets current usage of location service opt in mode.
150 * @param {boolean} enabled Defines the value for location service opt in. 143 * @param {boolean} enabled Defines the value for location service opt in.
151 * @param {boolean} managed Defines whether this setting is set by policy. 144 * @param {boolean} managed Defines whether this setting is set by policy.
152 */ 145 */
153 setLocationServicesMode: function(enabled, managed) { 146 setLocationServicesMode: function(enabled, managed) {
154 this.setPreference('arc-enable-location-service', 147 this.setPreference('arc-enable-location-service', enabled, managed);
155 enabled, managed);
156 }, 148 },
157 149
158 /** 150 /**
159 * Sets current country code for ToS. 151 * Sets current country code for ToS.
160 * @param {string} countryCode Country code based on current timezone. 152 * @param {string} countryCode Country code based on current timezone.
161 */ 153 */
162 setCountryCode: function(countryCode) { 154 setCountryCode: function(countryCode) {
163 var scriptSetParameters = 'document.countryCode = \'' + 155 var scriptSetParameters =
164 countryCode.toLowerCase() + '\';'; 156 'document.countryCode = \'' + countryCode.toLowerCase() + '\';';
165 if (this.useMDOobe) { 157 if (this.useMDOobe) {
166 scriptSetParameters += 'document.viewMode = \'large-view\';'; 158 scriptSetParameters += 'document.viewMode = \'large-view\';';
167 } 159 }
168 var termsView = this.getElement_('arc-tos-view'); 160 var termsView = this.getElement_('arc-tos-view');
169 termsView.removeContentScripts(['preProcess']); 161 termsView.removeContentScripts(['preProcess']);
170 termsView.addContentScripts([ 162 termsView.addContentScripts([{
171 { name: 'preProcess', 163 name: 'preProcess',
172 matches: ['https://play.google.com/*'], 164 matches: ['https://play.google.com/*'],
173 js: { code: scriptSetParameters }, 165 js: {code: scriptSetParameters},
174 run_at: 'document_start' 166 run_at: 'document_start'
175 }]); 167 }]);
176 168
177 if (!$('arc-tos').hidden) { 169 if (!$('arc-tos').hidden) {
178 this.reloadPlayStore(); 170 this.reloadPlayStore();
179 } 171 }
180 }, 172 },
181 173
182 /** 174 /**
183 * Buttons in Oobe wizard's button strip. 175 * Buttons in Oobe wizard's button strip.
184 * @type {array} Array of Buttons. 176 * @type {array} Array of Buttons.
185 */ 177 */
(...skipping 28 matching lines...) Expand all
214 return buttons; 206 return buttons;
215 }, 207 },
216 208
217 /** 209 /**
218 * Handles Accept button click. 210 * Handles Accept button click.
219 */ 211 */
220 onAccept: function() { 212 onAccept: function() {
221 this.enableButtons_(false); 213 this.enableButtons_(false);
222 214
223 var isBackupRestoreEnabled = 215 var isBackupRestoreEnabled =
224 this.getElement_('arc-enable-backup-restore').checked; 216 this.getElement_('arc-enable-backup-restore').checked;
225 var isLocationServiceEnabled = 217 var isLocationServiceEnabled =
226 this.getElement_('arc-enable-location-service').checked; 218 this.getElement_('arc-enable-location-service').checked;
227 219
228 chrome.send('arcTermsOfServiceAccept', 220 chrome.send(
221 'arcTermsOfServiceAccept',
229 [isBackupRestoreEnabled, isLocationServiceEnabled]); 222 [isBackupRestoreEnabled, isLocationServiceEnabled]);
230 }, 223 },
231 224
232 /** 225 /**
233 * Handles Retry button click. 226 * Handles Retry button click.
234 */ 227 */
235 onSkip: function() { 228 onSkip: function() {
236 this.enableButtons_(false); 229 this.enableButtons_(false);
237 230
238 chrome.send('arcTermsOfServiceSkip'); 231 chrome.send('arcTermsOfServiceSkip');
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 this.enableButtons_(false); 300 this.enableButtons_(false);
308 }, 301 },
309 302
310 /** 303 /**
311 * Adds new class to the list of classes of root OOBE MD style and legacy 304 * Adds new class to the list of classes of root OOBE MD style and legacy
312 * style root elements. 305 * style root elements.
313 * @param {string} className class to remove. 306 * @param {string} className class to remove.
314 * 307 *
315 * @private 308 * @private
316 */ 309 */
317 addClass_: function (className) { 310 addClass_: function(className) {
318 this.classList.add(className); 311 this.classList.add(className);
319 $('arc-tos-md').getElement('arc-tos-dialog-md').classList.add(className); 312 $('arc-tos-md').getElement('arc-tos-dialog-md').classList.add(className);
320 }, 313 },
321 314
322 /** 315 /**
323 * Removes class from the list of classes of root OOBE MD style and legacy 316 * Removes class from the list of classes of root OOBE MD style and legacy
324 * style root elements. 317 * style root elements.
325 * @param {string} className class to remove. 318 * @param {string} className class to remove.
326 * 319 *
327 * @private 320 * @private
328 */ 321 */
329 removeClass_: function (className) { 322 removeClass_: function(className) {
330 this.classList.remove(className); 323 this.classList.remove(className);
331 $('arc-tos-md').getElement('arc-tos-dialog-md').classList. 324 $('arc-tos-md')
332 remove(className); 325 .getElement('arc-tos-dialog-md')
326 .classList.remove(className);
333 }, 327 },
334 328
335 /** 329 /**
336 * Handles event when terms view is loaded. 330 * Handles event when terms view is loaded.
337 */ 331 */
338 onTermsViewContentLoad: function() { 332 onTermsViewContentLoad: function() {
339 if (this.termsError) { 333 if (this.termsError) {
340 return; 334 return;
341 } 335 }
342 336
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 */ 373 */
380 onBeforeShow: function(data) { 374 onBeforeShow: function(data) {
381 this.setMDMode_(); 375 this.setMDMode_();
382 this.setLearnMoreHandlers_(); 376 this.setLearnMoreHandlers_();
383 377
384 Oobe.getInstance().headerHidden = true; 378 Oobe.getInstance().headerHidden = true;
385 379
386 // Reload caption image in case it was not loaded during the 380 // Reload caption image in case it was not loaded during the
387 // initialization phase. 381 // initialization phase.
388 $('arc-tos-logo').src = 382 $('arc-tos-logo').src =
389 'https://play.google.com/about/images/play_logo.png'; 383 'https://play.google.com/about/images/play_logo.png';
390 384
391 this.hideOverlay(); 385 this.hideOverlay();
392 this.reloadPlayStore(); 386 this.reloadPlayStore();
393 }, 387 },
394 388
395 /** 389 /**
396 * Returns requested element from related part of HTML determined by current 390 * Returns requested element from related part of HTML determined by current
397 * MD OOBE mode. 391 * MD OOBE mode.
398 * @param {string} id Id of an element to find. 392 * @param {string} id Id of an element to find.
399 * 393 *
(...skipping 19 matching lines...) Expand all
419 * service options. 413 * service options.
420 * 414 *
421 * @private 415 * @private
422 */ 416 */
423 setLearnMoreHandlers_: function() { 417 setLearnMoreHandlers_: function() {
424 var self = this; 418 var self = this;
425 419
426 var leanMoreBackupAndRestoreText = 420 var leanMoreBackupAndRestoreText =
427 loadTimeData.getString('arcLearnMoreBackupAndRestore'); 421 loadTimeData.getString('arcLearnMoreBackupAndRestore');
428 var backupAndRestore = this.getElement_('arc-enable-backup-restore'); 422 var backupAndRestore = this.getElement_('arc-enable-backup-restore');
429 backupAndRestore.parentElement.querySelector( 423 backupAndRestore.parentElement
430 '#learn-more-link-backup-restore').onclick = function(event) { 424 .querySelector('#learn-more-link-backup-restore')
425 .onclick = function(event) {
431 event.stopPropagation(); 426 event.stopPropagation();
432 self.showLearnMoreOverlay(leanMoreBackupAndRestoreText); 427 self.showLearnMoreOverlay(leanMoreBackupAndRestoreText);
433 }; 428 };
434 429
435 var leanMoreLocationServiceText = 430 var leanMoreLocationServiceText =
436 loadTimeData.getString('arcLearnMoreLocationService'); 431 loadTimeData.getString('arcLearnMoreLocationService');
437 var locationService = this.getElement_('arc-enable-location-service'); 432 var locationService = this.getElement_('arc-enable-location-service');
438 locationService.parentElement.querySelector( 433 locationService.parentElement
439 '#learn-more-link-location-service').onclick = function(event) { 434 .querySelector('#learn-more-link-location-service')
435 .onclick = function(event) {
440 event.stopPropagation(); 436 event.stopPropagation();
441 self.showLearnMoreOverlay(leanMoreLocationServiceText); 437 self.showLearnMoreOverlay(leanMoreLocationServiceText);
442 }; 438 };
443 } 439 }
444 }; 440 };
445 }); 441 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698