| Index: chrome/browser/resources/vr_shell/vr_shell_ui_api.js
|
| diff --git a/chrome/browser/resources/vr_shell/vr_shell_ui_api.js b/chrome/browser/resources/vr_shell/vr_shell_ui_api.js
|
| index db4c757d24719cc9b2359f3863142cb19b165555..4bbb4830b5fba55947d6a859c79fb71feb8ade7b 100644
|
| --- a/chrome/browser/resources/vr_shell/vr_shell_ui_api.js
|
| +++ b/chrome/browser/resources/vr_shell/vr_shell_ui_api.js
|
| @@ -437,3 +437,141 @@ api.Animation = class {
|
| this.to.x = opacity;
|
| }
|
| };
|
| +
|
| +/**
|
| + * Abstract class handling webui command calls from native. The UI must
|
| + * subclass this and override the handlers.
|
| + */
|
| +api.NativeCommandHandler = class {
|
| + /**
|
| + * @param {api.Mode} mode
|
| + */
|
| + onSetMode(mode) {}
|
| +
|
| + /**
|
| + * Handles entering or exiting full-screen mode.
|
| + * @param {boolean} fullscreen
|
| + */
|
| + onSetFullscreen(fullscreen) {}
|
| +
|
| + /**
|
| + * A controller app button click has happened.
|
| + */
|
| + onAppButtonClicked() {}
|
| +
|
| + /**
|
| + * Handles a change in the visible page's security level.
|
| + * @param {number} level
|
| + */
|
| + onSetSecurityLevel(level) {}
|
| +
|
| + /**
|
| + * Handles a change in the WebVR-specific secure-origin state. If |secure| is
|
| + * false, the UI must convey appropriate security warnings.
|
| + * @param {boolean} secure
|
| + */
|
| + onSetWebVRSecureOrigin(secure) {}
|
| +
|
| + /**
|
| + * Handles enabling of a development-oriented control to reload the UI.
|
| + * @param {boolean} enabled
|
| + */
|
| + onSetReloadUiCapabilityEnabled(enabled) {}
|
| +
|
| + /**
|
| + * Handles a new URL, specifying the host and path compoments.
|
| + * @param {string} host
|
| + * @param {string} path
|
| + */
|
| + onSetUrl(host, path) {}
|
| +
|
| + /**
|
| + * Handle a change in loading state (used to show a spinner or other loading
|
| + * indicator).
|
| + * @param {boolean} loading
|
| + */
|
| + onSetLoading(loading) {}
|
| +
|
| + /**
|
| + * Handle a change in loading progress. Progress is supplied as a number
|
| + * between 0.0 and 1.0.
|
| + * @param {boolean} progress
|
| + */
|
| + onSetLoadingProgress(progress) {}
|
| +
|
| + /**
|
| + * Handle a change in the set of omnibox suggestions.
|
| + * @param {Array<Object>} suggestions Array of suggestions with string members
|
| + * |description| and |url|.
|
| + */
|
| + onSetOmniboxSuggestions(suggestions) {}
|
| +
|
| + /**
|
| + * Handle a new set of tabs, overwriting the previous state.
|
| + * @param {Array<Object>} tabs Array of tab states.
|
| + */
|
| + onSetTabs(tabs) {}
|
| +
|
| + /**
|
| + * Update (or add if not present) a tab.
|
| + * @param {Object} tab
|
| + */
|
| + onUpdateTab(tab) {}
|
| +
|
| + /**
|
| + * Remove a tab.
|
| + * @param {Object} tab
|
| + */
|
| + onRemoveTab(tab) {}
|
| +
|
| + /**
|
| + * This function is executed after command parsing completes.
|
| + */
|
| + onCommandHandlerFinished() {}
|
| +
|
| + /** @final */
|
| + handleCommand(dict) {
|
| + if ('mode' in dict) {
|
| + this.onSetMode(dict['mode']);
|
| + }
|
| + if ('fullscreen' in dict) {
|
| + this.onSetFullscreen(dict['fullscreen'])
|
| + }
|
| + if ('appButtonClicked' in dict) {
|
| + this.onAppButtonClicked();
|
| + }
|
| + if ('securityLevel' in dict) {
|
| + this.onSetSecurityLevel(dict['securityLevel']);
|
| + }
|
| + if ('webVRSecureOrigin' in dict) {
|
| + this.onSetWebVRSecureOrigin(dict['webVRSecureOrigin']);
|
| + }
|
| + if ('enableReloadUi' in dict) {
|
| + this.onSetReloadUiCapabilityEnabled(dict['enableReloadUi']);
|
| + }
|
| + if ('url' in dict) {
|
| + let url = dict['url'];
|
| + this.onSetUrl(url['host'], url['path']);
|
| + }
|
| + if ('loading' in dict) {
|
| + this.onSetLoading(dict['loading']);
|
| + }
|
| + if ('loadProgress' in dict) {
|
| + this.onSetLoadingProgress(dict['loadProgress']);
|
| + }
|
| + if ('suggestions' in dict) {
|
| + this.onSetOmniboxSuggestions(dict['suggestions']);
|
| + }
|
| + if ('setTabs' in dict) {
|
| + this.onSetTabs(dict['setTabs']);
|
| + }
|
| + if ('updateTab' in dict) {
|
| + this.onUpdateTab(dict['updateTabs']);
|
| + }
|
| + if ('removeTab' in dict) {
|
| + this.onRemoveTab(dict['removeTab']);
|
| + }
|
| +
|
| + this.onCommandHandlerFinished()
|
| + }
|
| +};
|
|
|