| 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 14 matching lines...) Expand all Loading... |
| 55 | 56 |
| 56 using base::android::JavaParamRef; | 57 using base::android::JavaParamRef; |
| 57 using base::android::JavaRef; | 58 using base::android::JavaRef; |
| 58 | 59 |
| 59 namespace vr_shell { | 60 namespace vr_shell { |
| 60 | 61 |
| 61 namespace { | 62 namespace { |
| 62 vr_shell::VrShell* g_instance; | 63 vr_shell::VrShell* g_instance; |
| 63 | 64 |
| 64 void SetIsInVR(content::WebContents* contents, bool is_in_vr) { | 65 void SetIsInVR(content::WebContents* contents, bool is_in_vr) { |
| 65 if (contents && contents->GetRenderWidgetHostView()) | 66 if (contents && contents->GetRenderWidgetHostView()) { |
| 67 // TODO(asimjour) Contents should not be aware of VR mode. Instead, we |
| 68 // should add a flag for disabling specific UI such as the keyboard (see |
| 69 // VrTabHelper for details). |
| 66 contents->GetRenderWidgetHostView()->SetIsInVR(is_in_vr); | 70 contents->GetRenderWidgetHostView()->SetIsInVR(is_in_vr); |
| 71 |
| 72 VrTabHelper* vr_tab_helper = VrTabHelper::FromWebContents(contents); |
| 73 DCHECK(vr_tab_helper); |
| 74 vr_tab_helper->set_is_in_vr(is_in_vr); |
| 75 } |
| 67 } | 76 } |
| 68 | 77 |
| 69 void LoadControllerModelTask( | 78 void LoadControllerModelTask( |
| 70 base::WeakPtr<VrShell> weak_vr_shell, | 79 base::WeakPtr<VrShell> weak_vr_shell, |
| 71 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner) { | 80 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner) { |
| 72 auto controller_model = VrControllerModel::LoadFromComponent(); | 81 auto controller_model = VrControllerModel::LoadFromComponent(); |
| 73 if (controller_model) { | 82 if (controller_model) { |
| 74 main_thread_task_runner->PostTask( | 83 main_thread_task_runner->PostTask( |
| 75 FROM_HERE, base::Bind(&VrShell::SubmitControllerModel, weak_vr_shell, | 84 FROM_HERE, base::Bind(&VrShell::SubmitControllerModel, weak_vr_shell, |
| 76 base::Passed(&controller_model))); | 85 base::Passed(&controller_model))); |
| (...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 jboolean for_web_vr, | 574 jboolean for_web_vr, |
| 566 jlong gvr_api, | 575 jlong gvr_api, |
| 567 jboolean reprojected_rendering) { | 576 jboolean reprojected_rendering) { |
| 568 return reinterpret_cast<intptr_t>(new VrShell( | 577 return reinterpret_cast<intptr_t>(new VrShell( |
| 569 env, obj, reinterpret_cast<ui::WindowAndroid*>(window_android), | 578 env, obj, reinterpret_cast<ui::WindowAndroid*>(window_android), |
| 570 for_web_vr, VrShellDelegate::GetNativeVrShellDelegate(env, delegate), | 579 for_web_vr, VrShellDelegate::GetNativeVrShellDelegate(env, delegate), |
| 571 reinterpret_cast<gvr_context*>(gvr_api), reprojected_rendering)); | 580 reinterpret_cast<gvr_context*>(gvr_api), reprojected_rendering)); |
| 572 } | 581 } |
| 573 | 582 |
| 574 } // namespace vr_shell | 583 } // namespace vr_shell |
| OLD | NEW |