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

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

Issue 2500283003: Allow the VR omnibox to be transient. (Closed)
Patch Set: Created 4 years, 1 month 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/resources/vr_shell/vr_shell_ui.html ('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 scene = new ui.Scene(); 8 let scene = new ui.Scene();
9 let sceneManager; 9 let sceneManager;
10 10
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 let update = new api.UiElementUpdate(); 244 let update = new api.UiElementUpdate();
245 update.setVisible(false); 245 update.setVisible(false);
246 scene.updateElement(this.transientWarning.uiElementId, update); 246 scene.updateElement(this.transientWarning.uiElementId, update);
247 this.secureOriginTimer = null; 247 this.secureOriginTimer = null;
248 scene.flush(); 248 scene.flush();
249 } 249 }
250 }; 250 };
251 251
252 class Omnibox { 252 class Omnibox {
253 constructor(contentQuadId) { 253 constructor(contentQuadId) {
254 this.setSecureOrigin(false); 254 /** @const */ var VISIBILITY_TIMEOUT_MS = 3000;
255 this.domUiElement = new DomUiElement('#omni'); 255
256 this.domUiElement = new DomUiElement('#omni-container');
257 this.enabled = false;
258 this.secure = false;
259 this.visibilityTimeout = VISIBILITY_TIMEOUT_MS;
260 this.visibilityTimer = null;
261 this.nativeState = {};
262
263 // Initially invisible.
256 let update = new api.UiElementUpdate(); 264 let update = new api.UiElementUpdate();
257 update.setVisible(false); 265 update.setVisible(false);
258 scene.updateElement(this.domUiElement.uiElementId, update); 266 scene.updateElement(this.domUiElement.uiElementId, update);
267 this.nativeState.visible = false;
268
269 // Listen to the end of transitions, so that the box can be natively
270 // hidden after it finishes hiding itself.
271 document.querySelector('#omni').addEventListener('transitionend',
272 this.onAnimationDone.bind(this));
259 } 273 }
260 274
261 show(visible) { 275 show(enabled) {
262 let update = new api.UiElementUpdate(); 276 this.enabled = enabled;
263 update.setVisible(visible); 277 this.kickVisibilityTimer();
264 scene.updateElement(this.domUiElement.uiElementId, update); 278 this.updateState();
265 } 279 }
266 280
267 setLoading(loading) { 281 setLoading(loading) {
268 this.domUiElement.domElement.className = loading ? 'loading' : 'idle'; 282 this.loading = loading;
283 this.kickVisibilityTimer();
284 this.updateState();
269 } 285 }
270 286
271 setURL(host, path) { 287 setURL(host, path) {
272 let omnibox = this.domUiElement.domElement; 288 let omnibox = this.domUiElement.domElement;
273 omnibox.querySelector('#domain').innerHTML = host; 289 omnibox.querySelector('#domain').innerHTML = host;
274 omnibox.querySelector('#path').innerHTML = path; 290 omnibox.querySelector('#path').innerHTML = path;
291 this.kickVisibilityTimer();
292 this.updateState();
275 } 293 }
276 294
277 setSecureOrigin(secure) { 295 setSecureOrigin(secure) {
296 this.secure = secure;
297 this.kickVisibilityTimer();
298 this.updateState();
299 }
300
301 kickVisibilityTimer() {
mthiesse 2016/11/15 19:42:48 nit: resetVisibilityTimer()?
cjgrant 2016/11/15 20:57:05 Done.
302 if (this.visibilityTimer) {
303 clearInterval(this.visibilityTimer);
304 this.visibilityTimer = null;
305 }
306 if (this.enabled && this.visibilityTimeout > 0) {
307 this.visibilityTimer = setTimeout(
308 this.onVisibilityTimer.bind(this), this.visibilityTimeout);
309 }
310 }
311
312 onVisibilityTimer() {
313 this.visibilityTimer = null;
314 this.updateState();
315 }
316
317 onAnimationDone(e) {
318 if (e.propertyName == 'opacity' && !this.visibleAfterTransition) {
319 this.setNativeVisibility(false);
320 }
321 }
322
323 updateState() {
mthiesse 2016/11/15 19:42:48 Why have an enabled boolean on top of the NativeVi
cjgrant 2016/11/15 20:57:05 this.enabled -> Whether or not there's an omnibox
324 if (!this.enabled) {
325 this.setNativeVisibility(false);
326 return;
327 }
328
278 document.querySelector('#omni-secure-icon').style.display = 329 document.querySelector('#omni-secure-icon').style.display =
279 (secure ? 'block' : 'none'); 330 (this.secure ? 'block' : 'none');
280 document.querySelector('#omni-insecure-icon').style.display = 331 document.querySelector('#omni-insecure-icon').style.display =
281 (!secure ? 'block' : 'none'); 332 (this.secure ? 'none' : 'block');
333
334 let state = 'idle';
335 this.visibleAfterTransition = true;
336 if (this.visibilityTimeout > 0 && !this.visibilityTimer) {
337 state = 'hide';
338 this.visibleAfterTransition = false;
339 } else if (this.loading) {
340 state = 'loading';
341 }
342 document.querySelector('#omni').className = state;
343
344 this.setNativeVisibility(true);
345 }
346
347 setNativeVisibility(visible) {
348 if (visible != this.nativeState.visible) {
349 this.nativeState.visible = visible;
350 let update = new api.UiElementUpdate();
351 update.setVisible(visible);
352 scene.updateElement(this.domUiElement.uiElementId, update);
353 scene.flush();
354 }
282 } 355 }
283 }; 356 };
284 357
285 class SceneManager { 358 class SceneManager {
286 constructor() { 359 constructor() {
287 this.mode = api.Mode.UNKNOWN; 360 this.mode = api.Mode.UNKNOWN;
288 361
289 this.contentQuad = new ContentQuad(); 362 this.contentQuad = new ContentQuad();
290 let contentId = this.contentQuad.getElementId(); 363 let contentId = this.contentQuad.getElementId();
291 364
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 scene.flush(); 412 scene.flush();
340 } 413 }
341 414
342 return { 415 return {
343 initialize: initialize, 416 initialize: initialize,
344 command: command, 417 command: command,
345 }; 418 };
346 })(); 419 })();
347 420
348 document.addEventListener('DOMContentLoaded', vrShellUi.initialize); 421 document.addEventListener('DOMContentLoaded', vrShellUi.initialize);
OLDNEW
« 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