| 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" |
| 11 #include "chrome/browser/android/vr_shell/vr_compositor.h" | 11 #include "chrome/browser/android/vr_shell/vr_compositor.h" |
| 12 #include "chrome/browser/android/vr_shell/vr_controller.h" | 12 #include "chrome/browser/android/vr_shell/vr_controller.h" |
| 13 #include "chrome/browser/android/vr_shell/vr_gl_util.h" | 13 #include "chrome/browser/android/vr_shell/vr_gl_util.h" |
| 14 #include "chrome/browser/android/vr_shell/vr_input_manager.h" | 14 #include "chrome/browser/android/vr_shell/vr_input_manager.h" |
| 15 #include "chrome/browser/android/vr_shell/vr_shell_delegate.h" | 15 #include "chrome/browser/android/vr_shell/vr_shell_delegate.h" |
| 16 #include "chrome/browser/android/vr_shell/vr_shell_renderer.h" | 16 #include "chrome/browser/android/vr_shell/vr_shell_renderer.h" |
| 17 #include "chrome/browser/android/vr_shell/vr_web_contents_observer.h" |
| 17 #include "content/public/browser/navigation_controller.h" | 18 #include "content/public/browser/navigation_controller.h" |
| 18 #include "content/public/browser/render_view_host.h" | 19 #include "content/public/browser/render_view_host.h" |
| 19 #include "content/public/browser/render_widget_host.h" | 20 #include "content/public/browser/render_widget_host.h" |
| 20 #include "content/public/browser/render_widget_host_view.h" | 21 #include "content/public/browser/render_widget_host_view.h" |
| 21 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
| 22 #include "content/public/common/referrer.h" | 23 #include "content/public/common/referrer.h" |
| 23 #include "content/public/common/screen_info.h" | 24 #include "content/public/common/screen_info.h" |
| 24 #include "jni/VrShellImpl_jni.h" | 25 #include "jni/VrShellImpl_jni.h" |
| 25 #include "ui/android/view_android.h" | 26 #include "ui/android/view_android.h" |
| 26 #include "ui/android/window_android.h" | 27 #include "ui/android/window_android.h" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 main_contents_(main_contents), | 137 main_contents_(main_contents), |
| 137 ui_contents_(ui_contents), | 138 ui_contents_(ui_contents), |
| 138 weak_ptr_factory_(this) { | 139 weak_ptr_factory_(this) { |
| 139 DCHECK(g_instance == nullptr); | 140 DCHECK(g_instance == nullptr); |
| 140 g_instance = this; | 141 g_instance = this; |
| 141 j_vr_shell_.Reset(env, obj); | 142 j_vr_shell_.Reset(env, obj); |
| 142 scene_.reset(new UiScene); | 143 scene_.reset(new UiScene); |
| 143 html_interface_.reset(new UiInterface); | 144 html_interface_.reset(new UiInterface); |
| 144 content_compositor_.reset(new VrCompositor(content_window, false)); | 145 content_compositor_.reset(new VrCompositor(content_window, false)); |
| 145 ui_compositor_.reset(new VrCompositor(ui_window, true)); | 146 ui_compositor_.reset(new VrCompositor(ui_window, true)); |
| 147 vr_web_contents_observer_.reset( |
| 148 new VrWebContentsObserver(main_contents, html_interface_.get())); |
| 146 | 149 |
| 147 LoadUIContent(); | 150 LoadUIContent(); |
| 148 | 151 |
| 149 gvr::Mat4f identity; | 152 gvr::Mat4f identity; |
| 150 SetIdentityM(identity); | 153 SetIdentityM(identity); |
| 151 webvr_head_pose_.resize(kPoseRingBufferSize, identity); | 154 webvr_head_pose_.resize(kPoseRingBufferSize, identity); |
| 152 } | 155 } |
| 153 | 156 |
| 154 void VrShell::UpdateCompositorLayers(JNIEnv* env, | 157 void VrShell::UpdateCompositorLayers(JNIEnv* env, |
| 155 const JavaParamRef<jobject>& obj) { | 158 const JavaParamRef<jobject>& obj) { |
| (...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 base::WeakPtr<VrShell> VrShell::GetWeakPtr( | 686 base::WeakPtr<VrShell> VrShell::GetWeakPtr( |
| 684 const content::WebContents* web_contents) { | 687 const content::WebContents* web_contents) { |
| 685 // Ensure that the WebContents requesting the VrShell instance is the one | 688 // Ensure that the WebContents requesting the VrShell instance is the one |
| 686 // we created. | 689 // we created. |
| 687 if (g_instance != nullptr && g_instance->ui_contents_ == web_contents) | 690 if (g_instance != nullptr && g_instance->ui_contents_ == web_contents) |
| 688 return g_instance->weak_ptr_factory_.GetWeakPtr(); | 691 return g_instance->weak_ptr_factory_.GetWeakPtr(); |
| 689 return base::WeakPtr<VrShell>(nullptr); | 692 return base::WeakPtr<VrShell>(nullptr); |
| 690 } | 693 } |
| 691 | 694 |
| 692 void VrShell::OnDomContentsLoaded() { | 695 void VrShell::OnDomContentsLoaded() { |
| 696 html_interface_->SetURL(main_contents_->GetVisibleURL()); |
| 697 html_interface_->SetLoading(main_contents_->IsLoading()); |
| 693 html_interface_->OnDomContentsLoaded(); | 698 html_interface_->OnDomContentsLoaded(); |
| 694 } | 699 } |
| 695 | 700 |
| 696 void VrShell::SetWebVrMode(JNIEnv* env, | 701 void VrShell::SetWebVrMode(JNIEnv* env, |
| 697 const base::android::JavaParamRef<jobject>& obj, | 702 const base::android::JavaParamRef<jobject>& obj, |
| 698 bool enabled) { | 703 bool enabled) { |
| 699 webvr_mode_ = enabled; | 704 webvr_mode_ = enabled; |
| 700 if (enabled) { | 705 if (enabled) { |
| 701 html_interface_->SetMode(UiInterface::Mode::WEB_VR); | 706 html_interface_->SetMode(UiInterface::Mode::WEB_VR); |
| 702 } else { | 707 } else { |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 789 controller.GoForward(); | 794 controller.GoForward(); |
| 790 break; | 795 break; |
| 791 case RELOAD: | 796 case RELOAD: |
| 792 controller.Reload(false); | 797 controller.Reload(false); |
| 793 break; | 798 break; |
| 794 #if defined(ENABLE_VR_SHELL_UI_DEV) | 799 #if defined(ENABLE_VR_SHELL_UI_DEV) |
| 795 case RELOAD_UI: | 800 case RELOAD_UI: |
| 796 ui_contents_->GetController().Reload(false); | 801 ui_contents_->GetController().Reload(false); |
| 797 html_interface_.reset(new UiInterface); | 802 html_interface_.reset(new UiInterface); |
| 798 html_interface_->SetMode(UiInterface::Mode::STANDARD); | 803 html_interface_->SetMode(UiInterface::Mode::STANDARD); |
| 804 vr_web_contents_observer_->SetUiInterface(html_interface_.get()); |
| 799 break; | 805 break; |
| 800 #endif | 806 #endif |
| 801 case ZOOM_OUT: // Not handled yet. | 807 case ZOOM_OUT: // Not handled yet. |
| 802 case ZOOM_IN: // Not handled yet. | 808 case ZOOM_IN: // Not handled yet. |
| 803 break; | 809 break; |
| 804 default: | 810 default: |
| 805 NOTREACHED(); | 811 NOTREACHED(); |
| 806 } | 812 } |
| 807 } | 813 } |
| 808 | 814 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 822 const JavaParamRef<jobject>& ui_web_contents, | 828 const JavaParamRef<jobject>& ui_web_contents, |
| 823 jlong ui_window_android) { | 829 jlong ui_window_android) { |
| 824 return reinterpret_cast<intptr_t>(new VrShell( | 830 return reinterpret_cast<intptr_t>(new VrShell( |
| 825 env, obj, content::WebContents::FromJavaWebContents(content_web_contents), | 831 env, obj, content::WebContents::FromJavaWebContents(content_web_contents), |
| 826 reinterpret_cast<ui::WindowAndroid*>(content_window_android), | 832 reinterpret_cast<ui::WindowAndroid*>(content_window_android), |
| 827 content::WebContents::FromJavaWebContents(ui_web_contents), | 833 content::WebContents::FromJavaWebContents(ui_web_contents), |
| 828 reinterpret_cast<ui::WindowAndroid*>(ui_window_android))); | 834 reinterpret_cast<ui::WindowAndroid*>(ui_window_android))); |
| 829 } | 835 } |
| 830 | 836 |
| 831 } // namespace vr_shell | 837 } // namespace vr_shell |
| OLD | NEW |