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

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

Issue 2620383007: Tie VR omnibox to page load progress through TabObserver. (Closed)
Patch Set: Rebase to ToT. Created 3 years, 11 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
« no previous file with comments | « chrome/browser/android/vr_shell/vr_shell.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 ui = new scene.Scene(); 8 let ui = new scene.Scene();
9 let uiManager; 9 let uiManager;
10 10
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 ui.flush(); 287 ui.flush();
288 } 288 }
289 }; 289 };
290 290
291 class Omnibox { 291 class Omnibox {
292 constructor() { 292 constructor() {
293 this.domUiElement = new DomUiElement('#omnibox-container'); 293 this.domUiElement = new DomUiElement('#omnibox-container');
294 this.enabled = false; 294 this.enabled = false;
295 this.hidden = false; 295 this.hidden = false;
296 this.loading = false; 296 this.loading = false;
297 this.loadingProgress = 0; 297 this.loadProgress = 0;
298 this.level = 0; 298 this.level = 0;
299 this.visibilityTimeout = 0; 299 this.visibilityTimeout = 0;
300 this.visibilityTimer = null; 300 this.visibilityTimer = null;
301 this.nativeState = {}; 301 this.nativeState = {};
302 302
303 // Initially invisible. 303 // Initially invisible.
304 let update = new api.UiElementUpdate(); 304 let update = new api.UiElementUpdate();
305 update.setVisible(false); 305 update.setVisible(false);
306 ui.updateElement(this.domUiElement.uiElementId, update); 306 ui.updateElement(this.domUiElement.uiElementId, update);
307 this.nativeState.visible = false; 307 this.nativeState.visible = false;
(...skipping 28 matching lines...) Expand all
336 } 336 }
337 337
338 setEnabled(enabled) { 338 setEnabled(enabled) {
339 this.enabled = enabled; 339 this.enabled = enabled;
340 this.resetVisibilityTimer(); 340 this.resetVisibilityTimer();
341 this.updateState(); 341 this.updateState();
342 } 342 }
343 343
344 setLoading(loading) { 344 setLoading(loading) {
345 this.loading = loading; 345 this.loading = loading;
346 this.loadingProgress = 0; 346 this.loadProgress = 0;
347 this.resetVisibilityTimer(); 347 this.resetVisibilityTimer();
348 this.updateState(); 348 this.updateState();
349 } 349 }
350 350
351 setLoadingProgress(progress) { 351 setLoadProgress(progress) {
352 this.loadingProgress = progress; 352 this.loadProgress = progress;
353 this.updateState(); 353 this.updateState();
354 } 354 }
355 355
356 setURL(host, path) { 356 setURL(host, path) {
357 let omnibox = this.domUiElement.domElement; 357 let omnibox = this.domUiElement.domElement;
358 omnibox.querySelector('#domain').innerHTML = host; 358 omnibox.querySelector('#domain').innerHTML = host;
359 omnibox.querySelector('#path').innerHTML = path; 359 omnibox.querySelector('#path').innerHTML = path;
360 this.resetVisibilityTimer(); 360 this.resetVisibilityTimer();
361 this.updateState(); 361 this.updateState();
362 } 362 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 this.setNativeVisibility(this.enabled); 398 this.setNativeVisibility(this.enabled);
399 399
400 if (!this.enabled) { 400 if (!this.enabled) {
401 return; 401 return;
402 } 402 }
403 403
404 let indicator = document.querySelector('#omnibox-border'); 404 let indicator = document.querySelector('#omnibox-border');
405 if (this.loading) { 405 if (this.loading) {
406 // Remap load progress range 0-100 as 5-95 percent, to avoid the 406 // Remap load progress range 0-100 as 5-95 percent, to avoid the
407 // extremities of the rounded ends of the omnibox. 407 // extremities of the rounded ends of the omnibox.
408 let percent = Math.round((this.loadingProgress * 0.9 + 0.05) * 100); 408 let percent = Math.round((this.loadProgress * 0.9 + 0.05) * 100);
409 let gradient = 'linear-gradient(to right, ' + this.statusBarColor + 409 let gradient = 'linear-gradient(to right, ' + this.statusBarColor +
410 ' 0%, ' + this.statusBarColor + ' ' + percent + '%, ' + 410 ' 0%, ' + this.statusBarColor + ' ' + percent + '%, ' +
411 this.backgroundColor + ' ' + percent + '%, ' + 411 this.backgroundColor + ' ' + percent + '%, ' +
412 this.backgroundColor + ' 100%)'; 412 this.backgroundColor + ' 100%)';
413 indicator.style.background = gradient; 413 indicator.style.background = gradient;
414 } else { 414 } else {
415 indicator.style.background = this.backgroundColor; 415 indicator.style.background = this.backgroundColor;
416 } 416 }
417 417
418 let shouldBeHidden = 418 let shouldBeHidden =
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 if ('enableReloadUi' in dict) { 524 if ('enableReloadUi' in dict) {
525 uiManager.setReloadUiEnabled(dict['enableReloadUi']); 525 uiManager.setReloadUiEnabled(dict['enableReloadUi']);
526 } 526 }
527 if ('url' in dict) { 527 if ('url' in dict) {
528 let url = dict['url']; 528 let url = dict['url'];
529 uiManager.omnibox.setURL(url['host'], url['path']); 529 uiManager.omnibox.setURL(url['host'], url['path']);
530 } 530 }
531 if ('loading' in dict) { 531 if ('loading' in dict) {
532 uiManager.omnibox.setLoading(dict['loading']); 532 uiManager.omnibox.setLoading(dict['loading']);
533 } 533 }
534 if ('loadingProgress' in dict) { 534 if ('loadProgress' in dict) {
535 uiManager.omnibox.setLoadingProgress(dict['loadingProgress']); 535 uiManager.omnibox.setLoadProgress(dict['loadProgress']);
536 } 536 }
537 ui.flush(); 537 ui.flush();
538 } 538 }
539 539
540 return { 540 return {
541 initialize: initialize, 541 initialize: initialize,
542 command: command, 542 command: command,
543 }; 543 };
544 })(); 544 })();
545 545
546 document.addEventListener('DOMContentLoaded', vrShellUi.initialize); 546 document.addEventListener('DOMContentLoaded', vrShellUi.initialize);
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/vr_shell.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698