| 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 #include "chrome/browser/android/vr_shell/vr_shell.h" | 5 #include "chrome/browser/android/vr_shell/vr_shell.h" |
| 6 | 6 |
| 7 #include "base/metrics/histogram_macros.h" | 7 #include "base/metrics/histogram_macros.h" |
| 8 #include "chrome/browser/android/vr_shell/ui_elements.h" | 8 #include "chrome/browser/android/vr_shell/ui_elements.h" |
| 9 #include "chrome/browser/android/vr_shell/ui_interface.h" | 9 #include "chrome/browser/android/vr_shell/ui_interface.h" |
| 10 #include "chrome/browser/android/vr_shell/ui_scene.h" | 10 #include "chrome/browser/android/vr_shell/ui_scene.h" |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()), | 163 main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()), |
| 164 weak_ptr_factory_(this) { | 164 weak_ptr_factory_(this) { |
| 165 DCHECK(g_instance == nullptr); | 165 DCHECK(g_instance == nullptr); |
| 166 g_instance = this; | 166 g_instance = this; |
| 167 j_vr_shell_.Reset(env, obj); | 167 j_vr_shell_.Reset(env, obj); |
| 168 scene_.reset(new UiScene); | 168 scene_.reset(new UiScene); |
| 169 | 169 |
| 170 if (for_web_vr) | 170 if (for_web_vr) |
| 171 metrics_helper_->SetWebVREnabled(true); | 171 metrics_helper_->SetWebVREnabled(true); |
| 172 html_interface_.reset(new UiInterface( | 172 html_interface_.reset(new UiInterface( |
| 173 for_web_vr ? UiInterface::Mode::WEB_VR : UiInterface::Mode::STANDARD)); | 173 for_web_vr ? UiInterface::Mode::WEB_VR : UiInterface::Mode::STANDARD, |
| 174 main_contents_->IsFullscreen())); |
| 174 content_compositor_.reset(new VrCompositor(content_window, false)); | 175 content_compositor_.reset(new VrCompositor(content_window, false)); |
| 175 ui_compositor_.reset(new VrCompositor(ui_window, true)); | 176 ui_compositor_.reset(new VrCompositor(ui_window, true)); |
| 176 vr_web_contents_observer_.reset( | 177 vr_web_contents_observer_.reset( |
| 177 new VrWebContentsObserver(main_contents, html_interface_.get())); | 178 new VrWebContentsObserver(main_contents, html_interface_.get())); |
| 178 | 179 |
| 179 LoadUIContent(); | 180 LoadUIContent(); |
| 180 | 181 |
| 181 gvr::Mat4f identity; | 182 gvr::Mat4f identity; |
| 182 SetIdentityM(identity); | 183 SetIdentityM(identity); |
| 183 webvr_head_pose_.resize(kPoseRingBufferSize, identity); | 184 webvr_head_pose_.resize(kPoseRingBufferSize, identity); |
| (...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 959 bool enabled) { | 960 bool enabled) { |
| 960 metrics_helper_->SetWebVREnabled(enabled); | 961 metrics_helper_->SetWebVREnabled(enabled); |
| 961 if (enabled) { | 962 if (enabled) { |
| 962 html_interface_->SetMode(UiInterface::Mode::WEB_VR); | 963 html_interface_->SetMode(UiInterface::Mode::WEB_VR); |
| 963 } else { | 964 } else { |
| 964 html_interface_->SetMode(UiInterface::Mode::STANDARD); | 965 html_interface_->SetMode(UiInterface::Mode::STANDARD); |
| 965 } | 966 } |
| 966 } | 967 } |
| 967 | 968 |
| 968 void VrShell::SetWebVRSecureOrigin(bool secure_origin) { | 969 void VrShell::SetWebVRSecureOrigin(bool secure_origin) { |
| 969 html_interface_->SetSecureOrigin(secure_origin); | 970 // TODO(cjgrant): Align this state with the logic that drives the omnibox. |
| 971 html_interface_->SetWebVRSecureOrigin(secure_origin); |
| 970 } | 972 } |
| 971 | 973 |
| 972 void VrShell::SubmitWebVRFrame() {} | 974 void VrShell::SubmitWebVRFrame() {} |
| 973 | 975 |
| 974 void VrShell::UpdateWebVRTextureBounds(const gvr::Rectf& left_bounds, | 976 void VrShell::UpdateWebVRTextureBounds(const gvr::Rectf& left_bounds, |
| 975 const gvr::Rectf& right_bounds) { | 977 const gvr::Rectf& right_bounds) { |
| 976 webvr_left_viewport_->SetSourceUv(left_bounds); | 978 webvr_left_viewport_->SetSourceUv(left_bounds); |
| 977 webvr_right_viewport_->SetSourceUv(right_bounds); | 979 webvr_right_viewport_->SetSourceUv(right_bounds); |
| 978 } | 980 } |
| 979 | 981 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1036 } | 1038 } |
| 1037 for (auto &task : tasks) { | 1039 for (auto &task : tasks) { |
| 1038 task.Run(); | 1040 task.Run(); |
| 1039 } | 1041 } |
| 1040 } | 1042 } |
| 1041 | 1043 |
| 1042 void VrShell::DoUiAction(const UiAction action) { | 1044 void VrShell::DoUiAction(const UiAction action) { |
| 1043 content::NavigationController& controller = main_contents_->GetController(); | 1045 content::NavigationController& controller = main_contents_->GetController(); |
| 1044 switch (action) { | 1046 switch (action) { |
| 1045 case HISTORY_BACK: | 1047 case HISTORY_BACK: |
| 1046 if (controller.CanGoBack()) | 1048 if (main_contents_->IsFullscreen()) { |
| 1049 main_contents_->ExitFullscreen(true /* will_cause_resize */); |
| 1050 } else if (controller.CanGoBack()) { |
| 1047 controller.GoBack(); | 1051 controller.GoBack(); |
| 1052 } |
| 1048 break; | 1053 break; |
| 1049 case HISTORY_FORWARD: | 1054 case HISTORY_FORWARD: |
| 1050 if (controller.CanGoForward()) | 1055 if (controller.CanGoForward()) |
| 1051 controller.GoForward(); | 1056 controller.GoForward(); |
| 1052 break; | 1057 break; |
| 1053 case RELOAD: | 1058 case RELOAD: |
| 1054 controller.Reload(false); | 1059 controller.Reload(false); |
| 1055 break; | 1060 break; |
| 1056 #if defined(ENABLE_VR_SHELL_UI_DEV) | 1061 #if defined(ENABLE_VR_SHELL_UI_DEV) |
| 1057 case RELOAD_UI: | 1062 case RELOAD_UI: |
| 1058 ui_contents_->GetController().Reload(false); | 1063 ui_contents_->GetController().Reload(false); |
| 1059 html_interface_.reset(new UiInterface(UiInterface::Mode::STANDARD)); | 1064 html_interface_.reset(new UiInterface(UiInterface::Mode::STANDARD, |
| 1065 main_contents_->IsFullscreen())); |
| 1060 vr_web_contents_observer_->SetUiInterface(html_interface_.get()); | 1066 vr_web_contents_observer_->SetUiInterface(html_interface_.get()); |
| 1061 break; | 1067 break; |
| 1062 #endif | 1068 #endif |
| 1063 case ZOOM_OUT: // Not handled yet. | 1069 case ZOOM_OUT: // Not handled yet. |
| 1064 case ZOOM_IN: // Not handled yet. | 1070 case ZOOM_IN: // Not handled yet. |
| 1065 break; | 1071 break; |
| 1066 default: | 1072 default: |
| 1067 NOTREACHED(); | 1073 NOTREACHED(); |
| 1068 } | 1074 } |
| 1069 } | 1075 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1105 jboolean for_web_vr) { | 1111 jboolean for_web_vr) { |
| 1106 return reinterpret_cast<intptr_t>(new VrShell( | 1112 return reinterpret_cast<intptr_t>(new VrShell( |
| 1107 env, obj, content::WebContents::FromJavaWebContents(content_web_contents), | 1113 env, obj, content::WebContents::FromJavaWebContents(content_web_contents), |
| 1108 reinterpret_cast<ui::WindowAndroid*>(content_window_android), | 1114 reinterpret_cast<ui::WindowAndroid*>(content_window_android), |
| 1109 content::WebContents::FromJavaWebContents(ui_web_contents), | 1115 content::WebContents::FromJavaWebContents(ui_web_contents), |
| 1110 reinterpret_cast<ui::WindowAndroid*>(ui_window_android), | 1116 reinterpret_cast<ui::WindowAndroid*>(ui_window_android), |
| 1111 for_web_vr)); | 1117 for_web_vr)); |
| 1112 } | 1118 } |
| 1113 | 1119 |
| 1114 } // namespace vr_shell | 1120 } // namespace vr_shell |
| OLD | NEW |