| OLD | NEW | 
|    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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  118       this.configure(0.8, 0, 0); |  118       this.configure(0.8, 0, 0); | 
|  119     } |  119     } | 
|  120   }; |  120   }; | 
|  121  |  121  | 
|  122   class Controls { |  122   class Controls { | 
|  123     constructor(contentQuadId) { |  123     constructor(contentQuadId) { | 
|  124       this.buttons = []; |  124       this.buttons = []; | 
|  125       let descriptors = [ |  125       let descriptors = [ | 
|  126           ['#back', function() { |  126           ['#back', function() { | 
|  127             // If we are in cinema mode, revert to standard mode on back press. |  127             // If we are in cinema mode, revert to standard mode on back press. | 
|  128             if (sceneManager.mode == api.Mode.CINEMA) { |  128             if (sceneManager.cinemaMode) { | 
|  129               // TODO(crbug/644511): Send a message back to native to handle |  129               // TODO(crbug/644511): Send a message back to native to handle | 
|  130               // switching back to standard mode and out of full screen instead |  130               // switching back to standard mode and out of full screen instead | 
|  131               // of only changing the mode here. |  131               // of only changing the mode here. | 
|  132               sceneManager.setMode(api.Mode.STANDARD); |  132               sceneManager.setMode(sceneManager.mode, sceneManager.menuMode, | 
 |  133                 false /* Cinema Mode */); | 
|  133             } else { |  134             } else { | 
|  134               api.doAction(api.Action.HISTORY_BACK); |  135               api.doAction(api.Action.HISTORY_BACK); | 
|  135             } |  136             } | 
|  136           }], |  137           }], | 
|  137           ['#reload', function() { |  138           ['#reload', function() { | 
|  138             api.doAction(api.Action.RELOAD); |  139             api.doAction(api.Action.RELOAD); | 
|  139           }], |  140           }], | 
|  140           ['#forward', function() { |  141           ['#forward', function() { | 
|  141             api.doAction(api.Action.HISTORY_FORWARD); |  142             api.doAction(api.Action.HISTORY_FORWARD); | 
|  142           }], |  143           }], | 
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  383       let update = new api.UiElementUpdate(); |  384       let update = new api.UiElementUpdate(); | 
|  384       update.setVisible(visible); |  385       update.setVisible(visible); | 
|  385       scene.updateElement(this.domUiElement.uiElementId, update); |  386       scene.updateElement(this.domUiElement.uiElementId, update); | 
|  386       scene.flush(); |  387       scene.flush(); | 
|  387     } |  388     } | 
|  388   }; |  389   }; | 
|  389  |  390  | 
|  390   class SceneManager { |  391   class SceneManager { | 
|  391     constructor() { |  392     constructor() { | 
|  392       this.mode = api.Mode.UNKNOWN; |  393       this.mode = api.Mode.UNKNOWN; | 
 |  394       this.menuMode = false; | 
 |  395       this.cinemaMode = false; | 
|  393  |  396  | 
|  394       this.contentQuad = new ContentQuad(); |  397       this.contentQuad = new ContentQuad(); | 
|  395       let contentId = this.contentQuad.getElementId(); |  398       let contentId = this.contentQuad.getElementId(); | 
|  396  |  399  | 
|  397       this.controls = new Controls(contentId); |  400       this.controls = new Controls(contentId); | 
|  398       this.secureOriginWarnings = new SecureOriginWarnings(); |  401       this.secureOriginWarnings = new SecureOriginWarnings(); | 
|  399       this.omnibox = new Omnibox(contentId); |  402       this.omnibox = new Omnibox(contentId); | 
|  400     } |  403     } | 
|  401  |  404  | 
|  402     setMode(mode) { |  405     setMode(mode, menuMode, cinemaMode) { | 
|  403       this.mode = mode; |  406       this.mode = mode; | 
|  404       this.contentQuad.setEnabled( |  407       this.menuMode = menuMode; | 
|  405           mode == api.Mode.STANDARD || mode == api.Mode.CINEMA); |  408       this.cinemaMode = cinemaMode; | 
|  406       this.contentQuad.setCinemaMode(mode == api.Mode.CINEMA); |  409  | 
 |  410       this.contentQuad.setEnabled(mode == api.Mode.STANDARD && !menuMode); | 
 |  411       this.contentQuad.setCinemaMode(cinemaMode); | 
|  407       // TODO(crbug/643815): Set aspect ratio on content quad when available. |  412       // TODO(crbug/643815): Set aspect ratio on content quad when available. | 
|  408       // TODO(amp): Don't show controls in CINEMA mode once MENU mode lands. |  413       // TODO(amp): Don't show controls in CINEMA mode once MENU mode lands. | 
|  409       this.controls.setEnabled( |  414       this.controls.setEnabled(mode == api.Mode.STANDARD && !menuMode); | 
|  410           mode == api.Mode.STANDARD || mode == api.Mode.CINEMA); |  415       this.omnibox.setEnabled(mode == api.Mode.STANDARD && !menuMode); | 
|  411       this.omnibox.setEnabled( |  | 
|  412           mode == api.Mode.STANDARD || mode == api.Mode.CINEMA); |  | 
|  413       this.secureOriginWarnings.setEnabled(mode == api.Mode.WEB_VR); |  416       this.secureOriginWarnings.setEnabled(mode == api.Mode.WEB_VR); | 
|  414     } |  417     } | 
|  415  |  418  | 
|  416     setSecureOrigin(secure) { |  419     setSecureOrigin(secure) { | 
|  417       this.secureOriginWarnings.setSecureOrigin(secure); |  420       this.secureOriginWarnings.setSecureOrigin(secure); | 
|  418       this.omnibox.setSecureOrigin(secure); |  421       this.omnibox.setSecureOrigin(secure); | 
|  419     } |  422     } | 
|  420  |  423  | 
|  421     setReloadUiEnabled(enabled) { |  424     setReloadUiEnabled(enabled) { | 
|  422       this.controls.setReloadUiEnabled(enabled); |  425       this.controls.setReloadUiEnabled(enabled); | 
|  423     } |  426     } | 
|  424   }; |  427   }; | 
|  425  |  428  | 
|  426   function initialize() { |  429   function initialize() { | 
|  427     sceneManager = new SceneManager(); |  430     sceneManager = new SceneManager(); | 
|  428     scene.flush(); |  431     scene.flush(); | 
|  429  |  432  | 
|  430     api.domLoaded(); |  433     api.domLoaded(); | 
|  431   } |  434   } | 
|  432  |  435  | 
|  433   function command(dict) { |  436   function command(dict) { | 
|  434     if ('mode' in dict) { |  437     if ('mode' in dict) { | 
|  435       sceneManager.setMode(dict['mode']); |  438       sceneManager.setMode(dict['mode'], dict['menuMode'], dict['cinemaMode']); | 
|  436     } |  439     } | 
|  437     if ('secureOrigin' in dict) { |  440     if ('secureOrigin' in dict) { | 
|  438       sceneManager.setSecureOrigin(dict['secureOrigin']); |  441       sceneManager.setSecureOrigin(dict['secureOrigin']); | 
|  439     } |  442     } | 
|  440     if ('enableReloadUi' in dict) { |  443     if ('enableReloadUi' in dict) { | 
|  441       sceneManager.setReloadUiEnabled(dict['enableReloadUi']); |  444       sceneManager.setReloadUiEnabled(dict['enableReloadUi']); | 
|  442     } |  445     } | 
|  443     if ('url' in dict) { |  446     if ('url' in dict) { | 
|  444       let url = dict['url']; |  447       let url = dict['url']; | 
|  445       sceneManager.omnibox.setURL(url['host'], url['path']); |  448       sceneManager.omnibox.setURL(url['host'], url['path']); | 
|  446     } |  449     } | 
|  447     if ('loading' in dict) { |  450     if ('loading' in dict) { | 
|  448       sceneManager.omnibox.setLoading(dict['loading']); |  451       sceneManager.omnibox.setLoading(dict['loading']); | 
|  449     } |  452     } | 
|  450     scene.flush(); |  453     scene.flush(); | 
|  451   } |  454   } | 
|  452  |  455  | 
|  453   return { |  456   return { | 
|  454     initialize: initialize, |  457     initialize: initialize, | 
|  455     command: command, |  458     command: command, | 
|  456   }; |  459   }; | 
|  457 })(); |  460 })(); | 
|  458  |  461  | 
|  459 document.addEventListener('DOMContentLoaded', vrShellUi.initialize); |  462 document.addEventListener('DOMContentLoaded', vrShellUi.initialize); | 
| OLD | NEW |