| 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 <android/native_window_jni.h> | 7 #include <android/native_window_jni.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "chrome/browser/android/tab_android.h" | 21 #include "chrome/browser/android/tab_android.h" |
| 22 #include "chrome/browser/android/vr_shell/android_ui_gesture_target.h" | 22 #include "chrome/browser/android/vr_shell/android_ui_gesture_target.h" |
| 23 #include "chrome/browser/android/vr_shell/ui_interface.h" | 23 #include "chrome/browser/android/vr_shell/ui_interface.h" |
| 24 #include "chrome/browser/android/vr_shell/ui_scene_manager.h" | 24 #include "chrome/browser/android/vr_shell/ui_scene_manager.h" |
| 25 #include "chrome/browser/android/vr_shell/vr_compositor.h" | 25 #include "chrome/browser/android/vr_shell/vr_compositor.h" |
| 26 #include "chrome/browser/android/vr_shell/vr_controller_model.h" | 26 #include "chrome/browser/android/vr_shell/vr_controller_model.h" |
| 27 #include "chrome/browser/android/vr_shell/vr_gl_thread.h" | 27 #include "chrome/browser/android/vr_shell/vr_gl_thread.h" |
| 28 #include "chrome/browser/android/vr_shell/vr_input_manager.h" | 28 #include "chrome/browser/android/vr_shell/vr_input_manager.h" |
| 29 #include "chrome/browser/android/vr_shell/vr_shell_delegate.h" | 29 #include "chrome/browser/android/vr_shell/vr_shell_delegate.h" |
| 30 #include "chrome/browser/android/vr_shell/vr_shell_gl.h" | 30 #include "chrome/browser/android/vr_shell/vr_shell_gl.h" |
| 31 #include "chrome/browser/android/vr_shell/vr_tab_helper.h" |
| 31 #include "chrome/browser/android/vr_shell/vr_usage_monitor.h" | 32 #include "chrome/browser/android/vr_shell/vr_usage_monitor.h" |
| 32 #include "chrome/browser/android/vr_shell/vr_web_contents_observer.h" | 33 #include "chrome/browser/android/vr_shell/vr_web_contents_observer.h" |
| 33 #include "content/public/browser/browser_thread.h" | 34 #include "content/public/browser/browser_thread.h" |
| 34 #include "content/public/browser/navigation_controller.h" | 35 #include "content/public/browser/navigation_controller.h" |
| 35 #include "content/public/browser/render_view_host.h" | 36 #include "content/public/browser/render_view_host.h" |
| 36 #include "content/public/browser/render_widget_host.h" | 37 #include "content/public/browser/render_widget_host.h" |
| 37 #include "content/public/browser/render_widget_host_view.h" | 38 #include "content/public/browser/render_widget_host_view.h" |
| 38 #include "content/public/browser/web_contents.h" | 39 #include "content/public/browser/web_contents.h" |
| 39 #include "content/public/common/content_features.h" | 40 #include "content/public/common/content_features.h" |
| 40 #include "content/public/common/referrer.h" | 41 #include "content/public/common/referrer.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 56 | 57 |
| 57 using base::android::JavaParamRef; | 58 using base::android::JavaParamRef; |
| 58 using base::android::JavaRef; | 59 using base::android::JavaRef; |
| 59 | 60 |
| 60 namespace vr_shell { | 61 namespace vr_shell { |
| 61 | 62 |
| 62 namespace { | 63 namespace { |
| 63 vr_shell::VrShell* g_instance; | 64 vr_shell::VrShell* g_instance; |
| 64 | 65 |
| 65 void SetIsInVR(content::WebContents* contents, bool is_in_vr) { | 66 void SetIsInVR(content::WebContents* contents, bool is_in_vr) { |
| 66 if (contents && contents->GetRenderWidgetHostView()) | 67 if (contents && contents->GetRenderWidgetHostView()) { |
| 68 // TODO(asimjour) Contents should not be aware of VR mode. Instead, we |
| 69 // should add a flag for disabling specific UI such as the keyboard (see |
| 70 // VrTabHelper for details). |
| 67 contents->GetRenderWidgetHostView()->SetIsInVR(is_in_vr); | 71 contents->GetRenderWidgetHostView()->SetIsInVR(is_in_vr); |
| 72 |
| 73 VrTabHelper* vr_tab_helper = VrTabHelper::FromWebContents(contents); |
| 74 DCHECK(vr_tab_helper); |
| 75 vr_tab_helper->SetIsInVr(is_in_vr); |
| 76 } |
| 68 } | 77 } |
| 69 | 78 |
| 70 void LoadControllerModelTask( | 79 void LoadControllerModelTask( |
| 71 base::WeakPtr<VrShell> weak_vr_shell, | 80 base::WeakPtr<VrShell> weak_vr_shell, |
| 72 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner) { | 81 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner) { |
| 73 auto controller_model = VrControllerModel::LoadFromComponent(); | 82 auto controller_model = VrControllerModel::LoadFromComponent(); |
| 74 if (controller_model) { | 83 if (controller_model) { |
| 75 main_thread_task_runner->PostTask( | 84 main_thread_task_runner->PostTask( |
| 76 FROM_HERE, base::Bind(&VrShell::SubmitControllerModel, weak_vr_shell, | 85 FROM_HERE, base::Bind(&VrShell::SubmitControllerModel, weak_vr_shell, |
| 77 base::Passed(&controller_model))); | 86 base::Passed(&controller_model))); |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 jlong gvr_api, | 579 jlong gvr_api, |
| 571 jboolean reprojected_rendering) { | 580 jboolean reprojected_rendering) { |
| 572 return reinterpret_cast<intptr_t>(new VrShell( | 581 return reinterpret_cast<intptr_t>(new VrShell( |
| 573 env, obj, reinterpret_cast<ui::WindowAndroid*>(window_android), | 582 env, obj, reinterpret_cast<ui::WindowAndroid*>(window_android), |
| 574 for_web_vr, in_cct, | 583 for_web_vr, in_cct, |
| 575 VrShellDelegate::GetNativeVrShellDelegate(env, delegate), | 584 VrShellDelegate::GetNativeVrShellDelegate(env, delegate), |
| 576 reinterpret_cast<gvr_context*>(gvr_api), reprojected_rendering)); | 585 reinterpret_cast<gvr_context*>(gvr_api), reprojected_rendering)); |
| 577 } | 586 } |
| 578 | 587 |
| 579 } // namespace vr_shell | 588 } // namespace vr_shell |
| OLD | NEW |