| OLD | NEW |
| 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', |
| 10 function() { return { | 10 function() { return { |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 | 144 |
| 145 /** | 145 /** |
| 146 * Buttons in Oobe wizard's button strip. | 146 * Buttons in Oobe wizard's button strip. |
| 147 * @type {array} Array of Buttons. | 147 * @type {array} Array of Buttons. |
| 148 */ | 148 */ |
| 149 get buttons() { | 149 get buttons() { |
| 150 var buttons = []; | 150 var buttons = []; |
| 151 | 151 |
| 152 var skipButton = this.ownerDocument.createElement('button'); | 152 var skipButton = this.ownerDocument.createElement('button'); |
| 153 skipButton.id = 'arc-tos-skip-button'; | 153 skipButton.id = 'arc-tos-skip-button'; |
| 154 skipButton.disabled = this.classList.contains('arc-tos-loading'); |
| 155 skipButton.classList.add('preserve-disabled-state'); |
| 154 skipButton.textContent = | 156 skipButton.textContent = |
| 155 loadTimeData.getString('arcTermsOfServiceSkipButton'); | 157 loadTimeData.getString('arcTermsOfServiceSkipButton'); |
| 156 skipButton.addEventListener('click', function(event) { | 158 skipButton.addEventListener('click', function(event) { |
| 157 $('arc-tos-skip-button').disabled = true; | 159 $('arc-tos-skip-button').disabled = true; |
| 158 $('arc-tos-accept-button').disabled = true; | 160 $('arc-tos-accept-button').disabled = true; |
| 159 chrome.send('arcTermsOfServiceSkip'); | 161 chrome.send('arcTermsOfServiceSkip'); |
| 160 }); | 162 }); |
| 161 buttons.push(skipButton); | 163 buttons.push(skipButton); |
| 162 | 164 |
| 163 var retryButton = this.ownerDocument.createElement('button'); | 165 var retryButton = this.ownerDocument.createElement('button'); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 /** | 228 /** |
| 227 * Reloads Play Store. | 229 * Reloads Play Store. |
| 228 */ | 230 */ |
| 229 reloadPlayStore: function() { | 231 reloadPlayStore: function() { |
| 230 this.termsError = false; | 232 this.termsError = false; |
| 231 var termsView = $('arc-tos-view'); | 233 var termsView = $('arc-tos-view'); |
| 232 termsView.src = 'https://play.google.com/about/play-terms.html'; | 234 termsView.src = 'https://play.google.com/about/play-terms.html'; |
| 233 this.classList.remove('arc-tos-loaded'); | 235 this.classList.remove('arc-tos-loaded'); |
| 234 this.classList.remove('error'); | 236 this.classList.remove('error'); |
| 235 this.classList.add('arc-tos-loading'); | 237 this.classList.add('arc-tos-loading'); |
| 238 |
| 239 $('arc-tos-accept-button').disabled = true; |
| 240 $('arc-tos-skip-button').disabled = true; |
| 236 }, | 241 }, |
| 237 | 242 |
| 238 /** | 243 /** |
| 239 * Handles event when terms view is loaded. | 244 * Handles event when terms view is loaded. |
| 240 */ | 245 */ |
| 241 onTermsViewContentLoad: function() { | 246 onTermsViewContentLoad: function() { |
| 242 if (this.termsError) { | 247 if (this.termsError) { |
| 243 return; | 248 return; |
| 244 } | 249 } |
| 245 | 250 |
| 246 this.classList.remove('arc-tos-loading'); | 251 this.classList.remove('arc-tos-loading'); |
| 247 this.classList.remove('error'); | 252 this.classList.remove('error'); |
| 248 this.classList.add('arc-tos-loaded'); | 253 this.classList.add('arc-tos-loaded'); |
| 249 | 254 |
| 250 var acceptButton = $('arc-tos-accept-button'); | 255 var acceptButton = $('arc-tos-accept-button'); |
| 251 var skipButton = $('arc-tos-skip-button'); | 256 var skipButton = $('arc-tos-skip-button'); |
| 252 | 257 |
| 258 skipButton.disabled = false; |
| 253 acceptButton.disabled = false; | 259 acceptButton.disabled = false; |
| 254 if (document.activeElement != skipButton) { | 260 acceptButton.focus(); |
| 255 acceptButton.focus(); | |
| 256 } | |
| 257 | 261 |
| 258 var termsView = $('arc-tos-view'); | 262 var termsView = $('arc-tos-view'); |
| 259 var termsViewContainer = $('arc-tos-view-container'); | 263 var termsViewContainer = $('arc-tos-view-container'); |
| 260 var setTermsHeight = function() { | 264 var setTermsHeight = function() { |
| 261 // Reset terms-view height in order to stabilize style computation. | 265 // Reset terms-view height in order to stabilize style computation. |
| 262 // For some reason, child webview affects final result. | 266 // For some reason, child webview affects final result. |
| 263 termsView.style.height = '0px'; | 267 termsView.style.height = '0px'; |
| 264 var style = window.getComputedStyle(termsViewContainer, null); | 268 var style = window.getComputedStyle(termsViewContainer, null); |
| 265 var height = style.getPropertyValue('height'); | 269 var height = style.getPropertyValue('height'); |
| 266 termsView.style.height = height; | 270 termsView.style.height = height; |
| 267 }; | 271 }; |
| 268 setTimeout(setTermsHeight, 0); | 272 setTimeout(setTermsHeight, 0); |
| 269 }, | 273 }, |
| 270 | 274 |
| 271 /** | 275 /** |
| 272 * Handles event when terms view cannot be loaded. | 276 * Handles event when terms view cannot be loaded. |
| 273 */ | 277 */ |
| 274 onTermsViewErrorOccurred: function(details) { | 278 onTermsViewErrorOccurred: function(details) { |
| 275 this.termsError = true; | 279 this.termsError = true; |
| 276 this.classList.remove('arc-tos-loading'); | 280 this.classList.remove('arc-tos-loading'); |
| 277 this.classList.remove('arc-tos-loaded'); | 281 this.classList.remove('arc-tos-loaded'); |
| 278 this.classList.add('error'); | 282 this.classList.add('error'); |
| 283 |
| 284 $('arc-tos-retry-button').focus(); |
| 279 }, | 285 }, |
| 280 | 286 |
| 281 /** | 287 /** |
| 282 * Event handler that is invoked just before the screen is shown. | 288 * Event handler that is invoked just before the screen is shown. |
| 283 * @param {object} data Screen init payload. | 289 * @param {object} data Screen init payload. |
| 284 */ | 290 */ |
| 285 onBeforeShow: function(data) { | 291 onBeforeShow: function(data) { |
| 286 Oobe.getInstance().headerHidden = true; | 292 Oobe.getInstance().headerHidden = true; |
| 287 | 293 |
| 288 // Reload caption image in case it was not loaded during the | 294 // Reload caption image in case it was not loaded during the |
| (...skipping 18 matching lines...) Expand all Loading... |
| 307 }; | 313 }; |
| 308 | 314 |
| 309 var leanMoreLocationServiceText = | 315 var leanMoreLocationServiceText = |
| 310 loadTimeData.getString('arcLearnMoreLocationService'); | 316 loadTimeData.getString('arcLearnMoreLocationService'); |
| 311 $('learn-more-link-location-service').onclick = function() { | 317 $('learn-more-link-location-service').onclick = function() { |
| 312 self.showLearnMoreOverlay(leanMoreLocationServiceText); | 318 self.showLearnMoreOverlay(leanMoreLocationServiceText); |
| 313 }; | 319 }; |
| 314 } | 320 } |
| 315 }; | 321 }; |
| 316 }); | 322 }); |
| OLD | NEW |