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

Side by Side Diff: chrome/browser/resources/vr_shell/vr_shell_ui.js

Issue 2536223002: Omnibox improvements and fixes. (Closed)
Patch Set: Separate omnibox icon selection from webVR warning toggle. Created 4 years 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 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 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 update.setVisible(false); 229 update.setVisible(false);
230 update.setLockToFieldOfView(true); 230 update.setLockToFieldOfView(true);
231 scene.updateElement(this.transientWarning.uiElementId, update); 231 scene.updateElement(this.transientWarning.uiElementId, update);
232 } 232 }
233 233
234 setEnabled(enabled) { 234 setEnabled(enabled) {
235 this.enabled = enabled; 235 this.enabled = enabled;
236 this.updateState(); 236 this.updateState();
237 } 237 }
238 238
239 setSecureOrigin(secure) { 239 setSecure(secure) {
240 this.isSecureOrigin = secure; 240 this.secure = secure;
241 this.updateState(); 241 this.updateState();
242 } 242 }
243 243
244 updateState() { 244 updateState() {
245 /** @const */ var TRANSIENT_TIMEOUT_MS = 30000; 245 /** @const */ var TRANSIENT_TIMEOUT_MS = 30000;
246 246
247 let visible = (this.enabled && !this.isSecureOrigin); 247 let visible = (this.enabled && !this.secure);
248 if (this.secureOriginTimer) { 248 if (this.secureOriginTimer) {
249 clearInterval(this.secureOriginTimer); 249 clearInterval(this.secureOriginTimer);
250 this.secureOriginTimer = null; 250 this.secureOriginTimer = null;
251 } 251 }
252 if (visible) { 252 if (visible) {
253 this.secureOriginTimer = setTimeout( 253 this.secureOriginTimer = setTimeout(
254 this.onTransientTimer.bind(this), TRANSIENT_TIMEOUT_MS); 254 this.onTransientTimer.bind(this), TRANSIENT_TIMEOUT_MS);
255 } 255 }
256 this.showOrHideWarnings(visible); 256 this.showOrHideWarnings(visible);
257 } 257 }
(...skipping 11 matching lines...) Expand all
269 let update = new api.UiElementUpdate(); 269 let update = new api.UiElementUpdate();
270 update.setVisible(false); 270 update.setVisible(false);
271 scene.updateElement(this.transientWarning.uiElementId, update); 271 scene.updateElement(this.transientWarning.uiElementId, update);
272 this.secureOriginTimer = null; 272 this.secureOriginTimer = null;
273 scene.flush(); 273 scene.flush();
274 } 274 }
275 }; 275 };
276 276
277 class Omnibox { 277 class Omnibox {
278 constructor(contentQuadId) { 278 constructor(contentQuadId) {
279 /** @const */ var VISIBILITY_TIMEOUT_MS = 3000;
280
281 this.domUiElement = new DomUiElement('#omni-container'); 279 this.domUiElement = new DomUiElement('#omni-container');
282 this.enabled = false; 280 this.enabled = false;
283 this.secure = false; 281 this.level = 0;
284 this.visibilityTimeout = VISIBILITY_TIMEOUT_MS; 282 this.visibilityTimeout = 0;
285 this.visibilityTimer = null; 283 this.visibilityTimer = null;
286 this.nativeState = {}; 284 this.nativeState = {};
287 285
288 // Initially invisible. 286 // Initially invisible.
289 let update = new api.UiElementUpdate(); 287 let update = new api.UiElementUpdate();
290 update.setVisible(false); 288 update.setVisible(false);
291 scene.updateElement(this.domUiElement.uiElementId, update); 289 scene.updateElement(this.domUiElement.uiElementId, update);
292 this.nativeState.visible = false; 290 this.nativeState.visible = false;
293 291
294 // Listen to the end of transitions, so that the box can be natively 292 // Listen to the end of transitions, so that the box can be natively
(...skipping 15 matching lines...) Expand all
310 } 308 }
311 309
312 setURL(host, path) { 310 setURL(host, path) {
313 let omnibox = this.domUiElement.domElement; 311 let omnibox = this.domUiElement.domElement;
314 omnibox.querySelector('#domain').innerHTML = host; 312 omnibox.querySelector('#domain').innerHTML = host;
315 omnibox.querySelector('#path').innerHTML = path; 313 omnibox.querySelector('#path').innerHTML = path;
316 this.resetVisibilityTimer(); 314 this.resetVisibilityTimer();
317 this.updateState(); 315 this.updateState();
318 } 316 }
319 317
320 setSecureOrigin(secure) { 318 setSecurityLevel(level) {
321 this.secure = secure; 319 this.level = level;
322 this.resetVisibilityTimer(); 320 this.resetVisibilityTimer();
323 this.updateState(); 321 this.updateState();
324 } 322 }
325 323
326 setVisibilityTimeout(milliseconds) { 324 setVisibilityTimeout(milliseconds) {
327 this.visibilityTimeout = milliseconds; 325 this.visibilityTimeout = milliseconds;
328 this.resetVisibilityTimer(); 326 this.resetVisibilityTimer();
329 this.updateState(); 327 this.updateState();
330 } 328 }
331 329
(...skipping 17 matching lines...) Expand all
349 if (e.propertyName == 'opacity' && !this.visibleAfterTransition) { 347 if (e.propertyName == 'opacity' && !this.visibleAfterTransition) {
350 this.setNativeVisibility(false); 348 this.setNativeVisibility(false);
351 } 349 }
352 } 350 }
353 351
354 updateState() { 352 updateState() {
355 if (!this.enabled) { 353 if (!this.enabled) {
356 this.setNativeVisibility(false); 354 this.setNativeVisibility(false);
357 return; 355 return;
358 } 356 }
359 357 let secure = this.level == 2 || this.level == 3;
360 document.querySelector('#omni-secure-icon').style.display = 358 document.querySelector('#omni-secure-icon').style.display =
361 (this.secure ? 'block' : 'none'); 359 (secure ? 'block' : 'none');
362 document.querySelector('#omni-insecure-icon').style.display = 360 document.querySelector('#omni-insecure-icon').style.display =
363 (this.secure ? 'none' : 'block'); 361 (secure ? 'none' : 'block');
364 362
365 let state = 'idle'; 363 let state = 'idle';
366 this.visibleAfterTransition = true; 364 this.visibleAfterTransition = true;
367 if (this.loading) { 365 if (this.loading) {
368 state = 'loading'; 366 state = 'loading';
369 } else if (this.visibilityTimeout > 0 && !this.visibilityTimer) { 367 } else if (this.visibilityTimeout > 0 && !this.visibilityTimer) {
370 state = 'hide'; 368 state = 'hide';
371 this.visibleAfterTransition = false; 369 this.visibleAfterTransition = false;
372 } 370 }
373 document.querySelector('#omni').className = state; 371 document.querySelector('#omni').className = state;
(...skipping 19 matching lines...) Expand all
393 391
394 this.contentQuad = new ContentQuad(); 392 this.contentQuad = new ContentQuad();
395 let contentId = this.contentQuad.getElementId(); 393 let contentId = this.contentQuad.getElementId();
396 394
397 this.controls = new Controls(contentId); 395 this.controls = new Controls(contentId);
398 this.secureOriginWarnings = new SecureOriginWarnings(); 396 this.secureOriginWarnings = new SecureOriginWarnings();
399 this.omnibox = new Omnibox(contentId); 397 this.omnibox = new Omnibox(contentId);
400 } 398 }
401 399
402 setMode(mode) { 400 setMode(mode) {
401 /** @const */ var OMNIBOX_VISIBILITY_TIMEOUT_MS = 5000;
402
403 this.mode = mode; 403 this.mode = mode;
404 this.contentQuad.setEnabled( 404 this.contentQuad.setEnabled(
405 mode == api.Mode.STANDARD || mode == api.Mode.CINEMA); 405 mode == api.Mode.STANDARD || mode == api.Mode.CINEMA);
406 this.contentQuad.setCinemaMode(mode == api.Mode.CINEMA); 406 this.contentQuad.setCinemaMode(mode == api.Mode.CINEMA);
407 // TODO(crbug/643815): Set aspect ratio on content quad when available. 407 // TODO(crbug/643815): Set aspect ratio on content quad when available.
408 // TODO(amp): Don't show controls in CINEMA mode once MENU mode lands. 408 // TODO(amp): Don't show controls in CINEMA mode once MENU mode lands.
409 this.controls.setEnabled( 409 this.controls.setEnabled(
410 mode == api.Mode.STANDARD || mode == api.Mode.CINEMA); 410 mode == api.Mode.STANDARD || mode == api.Mode.CINEMA);
411 this.omnibox.setEnabled( 411 this.omnibox.setEnabled(
412 mode == api.Mode.STANDARD || mode == api.Mode.CINEMA); 412 mode == api.Mode.STANDARD || mode == api.Mode.CINEMA);
413 this.omnibox.setVisibilityTimeout(
414 (mode == api.Mode.STANDARD || mode == api.Mode.CINEMA) ?
415 0 : OMNIBOX_VISIBILITY_TIMEOUT_MS);
413 this.secureOriginWarnings.setEnabled(mode == api.Mode.WEB_VR); 416 this.secureOriginWarnings.setEnabled(mode == api.Mode.WEB_VR);
414 } 417 }
415 418
416 setSecureOrigin(secure) { 419 setSecurityLevel(level) {
417 this.secureOriginWarnings.setSecureOrigin(secure); 420 this.omnibox.setSecurityLevel(level);
418 this.omnibox.setSecureOrigin(secure); 421 }
422
423 setWebVRSecureOrigin(secure) {
424 this.secureOriginWarnings.setSecure(secure);
419 } 425 }
420 426
421 setReloadUiEnabled(enabled) { 427 setReloadUiEnabled(enabled) {
422 this.controls.setReloadUiEnabled(enabled); 428 this.controls.setReloadUiEnabled(enabled);
423 } 429 }
424 }; 430 };
425 431
426 function initialize() { 432 function initialize() {
427 sceneManager = new SceneManager(); 433 sceneManager = new SceneManager();
428 scene.flush(); 434 scene.flush();
429 435
430 api.domLoaded(); 436 api.domLoaded();
431 } 437 }
432 438
433 function command(dict) { 439 function command(dict) {
434 if ('mode' in dict) { 440 if ('mode' in dict) {
435 sceneManager.setMode(dict['mode']); 441 sceneManager.setMode(dict['mode']);
436 } 442 }
437 if ('secureOrigin' in dict) { 443 if ('securityLevel' in dict) {
438 sceneManager.setSecureOrigin(dict['secureOrigin']); 444 sceneManager.setSecurityLevel(dict['securityLevel']);
445 }
446 if ('webVRSecureOrigin' in dict) {
447 sceneManager.setWebVRSecureOrigin(dict['webVRSecureOrigin']);
439 } 448 }
440 if ('enableReloadUi' in dict) { 449 if ('enableReloadUi' in dict) {
441 sceneManager.setReloadUiEnabled(dict['enableReloadUi']); 450 sceneManager.setReloadUiEnabled(dict['enableReloadUi']);
442 } 451 }
443 if ('url' in dict) { 452 if ('url' in dict) {
444 let url = dict['url']; 453 let url = dict['url'];
445 sceneManager.omnibox.setURL(url['host'], url['path']); 454 sceneManager.omnibox.setURL(url['host'], url['path']);
446 } 455 }
447 if ('loading' in dict) { 456 if ('loading' in dict) {
448 sceneManager.omnibox.setLoading(dict['loading']); 457 sceneManager.omnibox.setLoading(dict['loading']);
449 } 458 }
450 scene.flush(); 459 scene.flush();
451 } 460 }
452 461
453 return { 462 return {
454 initialize: initialize, 463 initialize: initialize,
455 command: command, 464 command: command,
456 }; 465 };
457 })(); 466 })();
458 467
459 document.addEventListener('DOMContentLoaded', vrShellUi.initialize); 468 document.addEventListener('DOMContentLoaded', vrShellUi.initialize);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698