| 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 var vrShellUi = (function() { | 5 var vrShellUi = (function() { |
| 6 'use strict'; | 6 'use strict'; |
| 7 | 7 |
| 8 let scene = new ui.Scene(); | 8 let scene = new ui.Scene(); |
| 9 let sceneManager; | 9 let sceneManager; |
| 10 | 10 |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 update.setVisible(false); | 281 update.setVisible(false); |
| 282 scene.updateElement(this.domUiElement.uiElementId, update); | 282 scene.updateElement(this.domUiElement.uiElementId, update); |
| 283 this.nativeState.visible = false; | 283 this.nativeState.visible = false; |
| 284 | 284 |
| 285 // Listen to the end of transitions, so that the box can be natively | 285 // Listen to the end of transitions, so that the box can be natively |
| 286 // hidden after it finishes hiding itself. | 286 // hidden after it finishes hiding itself. |
| 287 document.querySelector('#omni').addEventListener('transitionend', | 287 document.querySelector('#omni').addEventListener('transitionend', |
| 288 this.onAnimationDone.bind(this)); | 288 this.onAnimationDone.bind(this)); |
| 289 } | 289 } |
| 290 | 290 |
| 291 getSecurityIconElementId(level) { |
| 292 // See security_state.h and getSecurityIconResource() for this mapping. |
| 293 switch (level) { |
| 294 case 0: // NONE |
| 295 case 1: // HTTP_SHOW_WARNING |
| 296 case 4: // SECURITY_WARNING |
| 297 return '#omni-info-icon'; |
| 298 case 2: // SECURE: |
| 299 case 3: // EV_SECURE: |
| 300 return '#omni-lock-icon'; |
| 301 case 5: // SECURE_WITH_POLICY_INSTALLED_CERT (ChromeOS only) |
| 302 case 6: // DANGEROUS |
| 303 default: |
| 304 return '#omni-warning-icon'; |
| 305 } |
| 306 } |
| 307 |
| 291 setEnabled(enabled) { | 308 setEnabled(enabled) { |
| 292 this.enabled = enabled; | 309 this.enabled = enabled; |
| 293 this.resetVisibilityTimer(); | 310 this.resetVisibilityTimer(); |
| 294 this.updateState(); | 311 this.updateState(); |
| 295 } | 312 } |
| 296 | 313 |
| 297 setLoading(loading) { | 314 setLoading(loading) { |
| 298 this.loading = loading; | 315 this.loading = loading; |
| 299 this.resetVisibilityTimer(); | 316 this.resetVisibilityTimer(); |
| 300 this.updateState(); | 317 this.updateState(); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 if (e.propertyName == 'opacity' && !this.visibleAfterTransition) { | 357 if (e.propertyName == 'opacity' && !this.visibleAfterTransition) { |
| 341 this.setNativeVisibility(false); | 358 this.setNativeVisibility(false); |
| 342 } | 359 } |
| 343 } | 360 } |
| 344 | 361 |
| 345 updateState() { | 362 updateState() { |
| 346 if (!this.enabled) { | 363 if (!this.enabled) { |
| 347 this.setNativeVisibility(false); | 364 this.setNativeVisibility(false); |
| 348 return; | 365 return; |
| 349 } | 366 } |
| 350 let secure = this.level == 2 || this.level == 3; | 367 |
| 351 document.querySelector('#omni-secure-icon').style.display = | 368 document.querySelector('#omni-warning-icon').style.display = 'none'; |
| 352 (secure ? 'block' : 'none'); | 369 document.querySelector('#omni-info-icon').style.display = 'none'; |
| 353 document.querySelector('#omni-insecure-icon').style.display = | 370 document.querySelector('#omni-lock-icon').style.display = 'none'; |
| 354 (secure ? 'none' : 'block'); | 371 let icon = this.getSecurityIconElementId(this.level); |
| 372 document.querySelector(icon).style.display = 'block'; |
| 355 | 373 |
| 356 let state = 'idle'; | 374 let state = 'idle'; |
| 357 this.visibleAfterTransition = true; | 375 this.visibleAfterTransition = true; |
| 358 if (this.loading) { | 376 if (this.loading) { |
| 359 state = 'loading'; | 377 state = 'loading'; |
| 360 } else if (this.visibilityTimeout > 0 && !this.visibilityTimer) { | 378 } else if (this.visibilityTimeout > 0 && !this.visibilityTimer) { |
| 361 state = 'hide'; | 379 state = 'hide'; |
| 362 this.visibleAfterTransition = false; | 380 this.visibleAfterTransition = false; |
| 363 } | 381 } |
| 364 document.querySelector('#omni').className = state; | 382 document.querySelector('#omni').className = state; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 scene.flush(); | 476 scene.flush(); |
| 459 } | 477 } |
| 460 | 478 |
| 461 return { | 479 return { |
| 462 initialize: initialize, | 480 initialize: initialize, |
| 463 command: command, | 481 command: command, |
| 464 }; | 482 }; |
| 465 })(); | 483 })(); |
| 466 | 484 |
| 467 document.addEventListener('DOMContentLoaded', vrShellUi.initialize); | 485 document.addEventListener('DOMContentLoaded', vrShellUi.initialize); |
| OLD | NEW |