| 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 4a52454f5efaa86c6767e0e5eabac6f7de0e6de7..c31850aabf90dc2a08ef9604cb4070275e797036 100644
|
| --- a/chrome/browser/resources/vr_shell/vr_shell_ui.js
|
| +++ b/chrome/browser/resources/vr_shell/vr_shell_ui.js
|
| @@ -7,6 +7,7 @@ var vrShellUi = (function() {
|
|
|
| let ui = new scene.Scene();
|
| let uiManager;
|
| + let nativeCommandHandler;
|
|
|
| let uiRootElement = document.querySelector('#ui');
|
| let uiStyle = window.getComputedStyle(uiRootElement);
|
| @@ -687,8 +688,12 @@ var vrShellUi = (function() {
|
| this.reloadUiButton = new ReloadUiButton();
|
| }
|
|
|
| - setMode(mode, fullscreen) {
|
| + setMode(mode) {
|
| this.mode = mode;
|
| + this.updateState();
|
| + }
|
| +
|
| + setFullscreen(fullscreen) {
|
| this.fullscreen = fullscreen;
|
| this.updateState();
|
| }
|
| @@ -706,6 +711,7 @@ var vrShellUi = (function() {
|
|
|
| api.doAction(api.Action.SET_CONTENT_PAUSED, {'paused': menuMode});
|
|
|
| + this.background.setEnabled(mode == api.Mode.STANDARD);
|
| this.contentQuad.setEnabled(mode == api.Mode.STANDARD);
|
| this.contentQuad.setFullscreen(this.fullscreen);
|
| this.contentQuad.setMenuMode(menuMode);
|
| @@ -736,51 +742,77 @@ var vrShellUi = (function() {
|
|
|
| function initialize() {
|
| uiManager = new UiManager();
|
| + nativeCommandHandler = new UiCommandHandler(uiManager);
|
| ui.flush();
|
|
|
| api.domLoaded();
|
| }
|
|
|
| - function command(dict) {
|
| - if ('mode' in dict) {
|
| - uiManager.setMode(dict['mode'], dict['fullscreen']);
|
| + class UiCommandHandler extends api.NativeCommandHandler {
|
| + constructor(uiManager) {
|
| + super();
|
| + this.manager = uiManager;
|
| }
|
| - if ('appButtonClicked' in dict) {
|
| - uiManager.handleAppButtonClicked();
|
| +
|
| + /** @override */
|
| + onSetMode(mode) {
|
| + this.manager.setMode(mode);
|
| }
|
| - if ('securityLevel' in dict) {
|
| - uiManager.setSecurityLevel(dict['securityLevel']);
|
| +
|
| + /** @override */
|
| + onSetFullscreen(fullscreen) {
|
| + this.manager.setFullscreen(fullscreen);
|
| }
|
| - if ('webVRSecureOrigin' in dict) {
|
| - uiManager.setWebVRSecureOrigin(dict['webVRSecureOrigin']);
|
| +
|
| + /** @override */
|
| + onAppButtonClicked() {
|
| + this.manager.handleAppButtonClicked();
|
| }
|
| - if ('enableReloadUi' in dict) {
|
| - uiManager.reloadUiButton.setDevMode(dict['enableReloadUi']);
|
| +
|
| + /** @override */
|
| + onSetSecurityLevel(level) {
|
| + this.manager.setSecurityLevel(level);
|
| }
|
| - if ('url' in dict) {
|
| - let url = dict['url'];
|
| - uiManager.urlIndicator.setURL(url['host'], url['path']);
|
| - uiManager.omnibox.setURL(url['host'] + url['path']);
|
| +
|
| + /** @override */
|
| + onSetWebVRSecureOrigin(secure) {
|
| + this.manager.setWebVRSecureOrigin(secure);
|
| }
|
| - if ('loading' in dict) {
|
| - uiManager.urlIndicator.setLoading(dict['loading']);
|
| +
|
| + /** @override */
|
| + onSetReloadUiCapabilityEnabled(enabled) {
|
| + this.manager.reloadUiButton.setDevMode(enabled);
|
| }
|
| - if ('loadProgress' in dict) {
|
| - uiManager.urlIndicator.setLoadProgress(dict['loadProgress']);
|
| +
|
| + /** @override */
|
| + onSetUrl(host, path) {
|
| + this.manager.urlIndicator.setURL(host, path);
|
| + this.manager.omnibox.setURL(host, path);
|
| }
|
| - if ('suggestions' in dict) {
|
| - uiManager.omnibox.setSuggestions(dict['suggestions']);
|
| +
|
| + /** @override */
|
| + onSetLoading(loading) {
|
| + this.manager.urlIndicator.setLoading(loading);
|
| }
|
| - if ('setTabs' in dict) {
|
| - console.log(dict['setTabs']);
|
| +
|
| + /** @override */
|
| + onSetLoadingProgress(progress) {
|
| + this.manager.urlIndicator.setLoadProgress(progress);
|
| }
|
| - if ('updateTab' in dict) {
|
| - console.log(dict['updateTab']);
|
| +
|
| + /** @override */
|
| + onSetOmniboxSuggestions(suggestions) {
|
| + this.manager.omnibox.setSuggestions(suggestions);
|
| }
|
| - if ('removeTab' in dict) {
|
| - console.log(dict['removeTab']);
|
| +
|
| + /** @override */
|
| + onCommandHandlerFinished() {
|
| + ui.flush();
|
| }
|
| - ui.flush();
|
| + }
|
| +
|
| + function command(dict) {
|
| + nativeCommandHandler.handleCommand(dict);
|
| }
|
|
|
| return {
|
|
|