1 // Copyright 2017 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_VR_MODEL_MODEL_H_ 6 #define CHROME_BROWSER_VR_MODEL_MODEL_H_ 7 8 #include <memory> 9 #include <vector> 10 11 #include "chrome/browser/vr/gl_texture_location.h" 12 #include "chrome/browser/vr/model/capturing_state_model.h" 13 #include "chrome/browser/vr/model/color_scheme.h" 14 #include "chrome/browser/vr/model/controller_model.h" 15 #include "chrome/browser/vr/model/hosted_platform_ui.h" 16 #include "chrome/browser/vr/model/location_bar_state.h" 17 #include "chrome/browser/vr/model/modal_prompt_type.h" 18 #include "chrome/browser/vr/model/omnibox_suggestions.h" 19 #include "chrome/browser/vr/model/platform_toast.h" 20 #include "chrome/browser/vr/model/reticle_model.h" 21 #include "chrome/browser/vr/model/speech_recognition_model.h" 22 #include "chrome/browser/vr/model/text_input_info.h" 23 #include "chrome/browser/vr/model/ui_mode.h" 24 #include "chrome/browser/vr/model/web_vr_model.h" 25 #include "chrome/browser/vr/vr_ui_export.h" 26 #include "ui/gfx/transform.h" 27 28 namespace vr { 29 30 struct VR_UI_EXPORT Model { 31 Model(); 32 ~Model(); 33 34 // VR browsing state. 35 bool loading = false; 36 float load_progress = 0.0f; 37 bool incognito = false; 38 bool can_navigate_back = false; 39 bool can_navigate_forward = false; 40 LocationBarState location_bar_state; 41 std::vector<OmniboxSuggestion> omnibox_suggestions; 42 SpeechRecognitionModel speech; 43 const ColorScheme& color_scheme() const; 44 gfx::Transform projection_matrix; 45 unsigned int content_texture_id = 0; 46 unsigned int content_overlay_texture_id = 0; 47 bool content_overlay_texture_non_empty = false; 48 GlTextureLocation content_location = kGlTextureLocationLocal; 49 GlTextureLocation content_overlay_location = kGlTextureLocationLocal; 50 bool waiting_for_background = false; 51 bool background_loaded = false; 52 bool supports_selection = true; 53 bool needs_keyboard_update = false; 54 bool overflow_menu_enabled = false; 55 bool regular_tabs_open = false; 56 bool incognito_tabs_open = false; 57 bool standalone_vr_device = false; 58 bool menu_button_long_pressed = false; 59 float floor_height = 0.0f; 60 bool gvr_input_support = false; 61 base::TimeTicks current_time; 62 63 // WebVR state. 64 WebVrModel web_vr; 65 66 std::vector<UiMode> ui_modes; 67 void push_mode(UiMode mode); 68 void pop_mode(); 69 void pop_mode(UiMode mode); 70 void toggle_mode(UiMode mode); 71 UiMode get_mode() const; 72 UiMode get_last_opaque_mode() const; 73 bool has_mode_in_stack(UiMode mode) const; 74 bool browsing_enabled() const; 75 bool default_browsing_enabled() const; 76 bool voice_search_available() const; 77 bool voice_search_active() const; 78 bool omnibox_editing_enabled() const; 79 bool editing_enabled() const; 80 bool fullscreen_enabled() const; 81 bool web_vr_enabled() const; 82 bool reposition_window_enabled() const; 83 bool reposition_window_permitted() const; 84 85 // Helper methods which update the text field state 86 // as well as 'touched' field, to ensure bindings are 87 // run even if the text state has not changed. 88 void set_omnibox_text_field_info(EditedText text); 89 void set_web_input_text_field_info(EditedText text); 90 91 // Focused text state. 92 bool editing_input = false; 93 bool editing_web_input = false; 94 // Editable text field state. 95 EditedText omnibox_text_field_info; 96 base::TimeTicks omnibox_text_field_touched; 97 EditedText web_input_text_field_info; 98 base::TimeTicks web_input_text_field_touched; 99 100 // Controller state. 101 const ControllerModel& primary_controller() const; 102 ControllerModel& mutable_primary_controller(); // For tests 103 std::vector<ControllerModel> controllers; 104 ReticleModel reticle; 105 106 // State affecting both VR browsing and WebVR. 107 ModalPromptType active_modal_prompt_type = kModalPromptTypeNone; 108 CapturingStateModel active_capturing; 109 CapturingStateModel background_capturing; 110 CapturingStateModel potential_capturing; 111 bool skips_redraw_when_not_dirty = false; 112 HostedPlatformUi hosted_platform_ui; 113 114 std::unique_ptr<const PlatformToast> platform_toast; 115 }; 116 117 } // namespace vr 118 119 #endif // CHROME_BROWSER_VR_MODEL_MODEL_H_ 120