Chromium Code Reviews| 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 |
| 11 let uiRootElement = document.querySelector('#ui'); | 11 let uiRootElement = document.querySelector('#ui'); |
| 12 let uiStyle = window.getComputedStyle(uiRootElement); | 12 let uiStyle = window.getComputedStyle(uiRootElement); |
| 13 /** @const */ var ANIM_DURATION = 150; | 13 /** @const */ var ANIM_DURATION = 150; |
| 14 | 14 |
| 15 // This value should match the one in VrShellImpl.java | 15 // This value should match the one in VrShellImpl.java |
| 16 /** @const */ var UI_DPR = 1.2; | 16 /** @const */ var UI_DPR = 1.2; |
| 17 | 17 |
| 18 function getStyleFloat(style, property) { | 18 function getStyleFloat(style, property) { |
| 19 let value = parseFloat(style.getPropertyValue(property)); | 19 let value = parseFloat(style.getPropertyValue(property)); |
| 20 return isNaN(value) ? 0 : value; | 20 return isNaN(value) ? 0 : value; |
| 21 } | 21 } |
| 22 | 22 |
| 23 function getSecurityIcon(level) { | |
| 24 // See security_state.h and getSecurityIconResource() for this mapping. | |
| 25 let path = 'images/'; | |
| 26 switch (level) { | |
| 27 case 0: // NONE | |
| 28 case 1: // HTTP_SHOW_WARNING | |
| 29 case 4: // SECURITY_WARNING | |
| 30 return path + 'info.svg'; | |
| 31 case 2: // SECURE: | |
| 32 case 3: // EV_SECURE: | |
| 33 return path + 'lock.svg'; | |
| 34 case 5: // SECURE_WITH_POLICY_INSTALLED_CERT (ChromeOS only) | |
| 35 case 6: // DANGEROUS | |
| 36 default: | |
| 37 return path + 'warning.svg'; | |
| 38 } | |
| 39 } | |
| 40 | |
| 23 class ContentQuad { | 41 class ContentQuad { |
| 24 constructor() { | 42 constructor() { |
| 25 /** @const */ this.SCREEN_HEIGHT = 1.6; | 43 /** @const */ this.SCREEN_HEIGHT = 1.6; |
| 26 /** @const */ this.SCREEN_RATIO = 16 / 9; | 44 /** @const */ this.SCREEN_RATIO = 16 / 9; |
| 27 /** @const */ this.BROWSING_SCREEN_DISTANCE = 2.0; | 45 /** @const */ this.BROWSING_SCREEN_DISTANCE = 2.0; |
| 28 /** @const */ this.FULLSCREEN_DISTANCE = 3.0; | 46 /** @const */ this.FULLSCREEN_DISTANCE = 3.0; |
| 29 | 47 |
| 30 let element = new api.UiElement(0, 0, 0, 0); | 48 let element = new api.UiElement(0, 0, 0, 0); |
| 31 element.setIsContentQuad(); | 49 element.setIsContentQuad(); |
| 32 element.setVisible(false); | 50 element.setVisible(false); |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 340 if (e.propertyName == 'opacity' && !this.visibleAfterTransition) { | 358 if (e.propertyName == 'opacity' && !this.visibleAfterTransition) { |
| 341 this.setNativeVisibility(false); | 359 this.setNativeVisibility(false); |
| 342 } | 360 } |
| 343 } | 361 } |
| 344 | 362 |
| 345 updateState() { | 363 updateState() { |
| 346 if (!this.enabled) { | 364 if (!this.enabled) { |
| 347 this.setNativeVisibility(false); | 365 this.setNativeVisibility(false); |
| 348 return; | 366 return; |
| 349 } | 367 } |
| 350 let secure = this.level == 2 || this.level == 3; | 368 |
| 351 document.querySelector('#omni-secure-icon').style.display = | 369 document.querySelector('#omni-icon').src = getSecurityIcon(this.level); |
|
Dan Beam
2016/12/13 03:56:59
nit: $('omni-icon').src if you're using util.js
cjgrant
2016/12/19 21:19:09
I can incorporate util.js, but we should be consis
| |
| 352 (secure ? 'block' : 'none'); | |
| 353 document.querySelector('#omni-insecure-icon').style.display = | |
| 354 (secure ? 'none' : 'block'); | |
| 355 | 370 |
| 356 let state = 'idle'; | 371 let state = 'idle'; |
| 357 this.visibleAfterTransition = true; | 372 this.visibleAfterTransition = true; |
| 358 if (this.loading) { | 373 if (this.loading) { |
| 359 state = 'loading'; | 374 state = 'loading'; |
| 360 } else if (this.visibilityTimeout > 0 && !this.visibilityTimer) { | 375 } else if (this.visibilityTimeout > 0 && !this.visibilityTimer) { |
| 361 state = 'hide'; | 376 state = 'hide'; |
| 362 this.visibleAfterTransition = false; | 377 this.visibleAfterTransition = false; |
| 363 } | 378 } |
| 364 document.querySelector('#omni').className = state; | 379 document.querySelector('#omni').className = state; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 458 scene.flush(); | 473 scene.flush(); |
| 459 } | 474 } |
| 460 | 475 |
| 461 return { | 476 return { |
| 462 initialize: initialize, | 477 initialize: initialize, |
| 463 command: command, | 478 command: command, |
| 464 }; | 479 }; |
| 465 })(); | 480 })(); |
| 466 | 481 |
| 467 document.addEventListener('DOMContentLoaded', vrShellUi.initialize); | 482 document.addEventListener('DOMContentLoaded', vrShellUi.initialize); |
| OLD | NEW |