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

Unified Diff: chrome/browser/resources/vr_shell/vr_shell_ui.js

Issue 2773533002: Add a progress indicator to the VR omnibox (Closed)
Patch Set: Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/resources/vr_shell/vr_shell_ui.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/vr_shell/vr_shell_ui.js
diff --git a/chrome/browser/resources/vr_shell/vr_shell_ui.js b/chrome/browser/resources/vr_shell/vr_shell_ui.js
index b7d3a8d33bee2115e5742aab25f7cd94b148f82d..7203c2c9dbe58c76c98e1f4aa737e4ffca505a28 100644
--- a/chrome/browser/resources/vr_shell/vr_shell_ui.js
+++ b/chrome/browser/resources/vr_shell/vr_shell_ui.js
@@ -26,6 +26,16 @@ var vrShellUi = (function() {
return !str || 0 === str.length ? '' : str;
}
+ // Generate a two-color progress bar style background using a gradient.
+ function makeProgressBackground(loading, percentage, color, background) {
+ if (!loading) {
+ return background;
+ }
+ return 'linear-gradient(to right, ' + color + ' 0%, ' + color + ' ' +
+ percentage * 100.0 + '%, ' + background + ' ' + percentage * 100 +
+ '%, ' + background + ' 100%)';
+ }
+
class ContentQuad {
constructor() {
/** @const */ this.SCREEN_HEIGHT = 1.375;
@@ -672,18 +682,9 @@ var vrShellUi = (function() {
}
let indicator = document.querySelector('#url-indicator-border');
- if (this.loading) {
- // Remap load progress range 0-100 as 5-95 percent, to avoid the
- // extremities of the rounded ends of the indicator.
- let percent = Math.round((this.loadProgress * 0.9 + 0.05) * 100);
- let gradient = 'linear-gradient(to right, ' + this.statusBarColor +
- ' 0%, ' + this.statusBarColor + ' ' + percent + '%, ' +
- this.backgroundColor + ' ' + percent + '%, ' +
- this.backgroundColor + ' 100%)';
- indicator.style.background = gradient;
- } else {
- indicator.style.background = this.backgroundColor;
- }
+ indicator.style.background = makeProgressBackground(
+ this.loading, this.loadProgress, this.statusBarColor,
+ this.backgroundColor);
let shouldBeHidden =
!this.loading && this.visibilityTimeout > 0 && !this.visibilityTimer;
@@ -831,9 +832,16 @@ var vrShellUi = (function() {
this.enabled = false;
let root = document.querySelector('#omnibox-ui-element');
- this.domUiElement = new DomUiElement('#omnibox-url-element');
+ this.domUiElement = new DomUiElement('#omnibox-border');
this.inputField = root.querySelector('#omnibox-input-field');
+ let style = window.getComputedStyle(this.domUiElement.domElement);
+ this.statusBarColor = getStyleString(style, '--statusBarColor');
+ this.backgroundColor = style.backgroundColor;
+ this.loading = false;
+ this.loadProgress = 0;
+ this.updateLoadingState();
+
// Initially invisible.
let update = new api.UiElementUpdate();
update.setVisible(false);
@@ -907,6 +915,24 @@ var vrShellUi = (function() {
this.updateSuggestions();
}
+ setLoading(loading) {
+ this.loading = loading;
+ this.loadProgress = 0;
+ this.updateLoadingState();
+ }
+
+ setLoadProgress(progress) {
+ this.loadProgress = progress;
+ this.updateLoadingState();
+ }
+
+ updateLoadingState() {
+ let indicator = document.querySelector('#omnibox-border');
+ indicator.style.background = makeProgressBackground(
+ this.loading, this.loadProgress, this.statusBarColor,
+ this.backgroundColor);
+ }
+
updateSuggestions() {
for (var i = 0; i < this.maxSuggestions; i++) {
let element = document.querySelector('#suggestion-' + i);
@@ -1262,11 +1288,13 @@ var vrShellUi = (function() {
/** @override */
onSetLoading(loading) {
this.manager.urlIndicator.setLoading(loading);
+ this.manager.omnibox.setLoading(loading);
}
/** @override */
onSetLoadingProgress(progress) {
this.manager.urlIndicator.setLoadProgress(progress);
+ this.manager.omnibox.setLoadProgress(progress);
}
/** @override */
« no previous file with comments | « chrome/browser/resources/vr_shell/vr_shell_ui.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698