| 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 #ifndef CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_ |
| 6 #define CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_ | 6 #define CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_ |
| 7 | 7 |
| 8 #include <jni.h> | 8 #include <jni.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 | 11 |
| 12 #include "base/android/jni_weak_ref.h" | 12 #include "base/android/jni_weak_ref.h" |
| 13 #include "base/callback.h" | 13 #include "base/callback.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "base/single_thread_task_runner.h" | 16 #include "base/single_thread_task_runner.h" |
| 17 #include "content/public/browser/web_contents_observer.h" | 17 #include "content/public/browser/web_contents_observer.h" |
| 18 #include "device/vr/android/gvr/gvr_delegate.h" | 18 #include "device/vr/android/gvr/gvr_delegate.h" |
| 19 #include "third_party/gvr-android-sdk/src/libraries/headers/vr/gvr/capi/include/
gvr.h" | 19 #include "third_party/gvr-android-sdk/src/libraries/headers/vr/gvr/capi/include/
gvr.h" |
| 20 #include "third_party/gvr-android-sdk/src/libraries/headers/vr/gvr/capi/include/
gvr_types.h" | 20 #include "third_party/gvr-android-sdk/src/libraries/headers/vr/gvr/capi/include/
gvr_types.h" |
| 21 | 21 |
| 22 namespace base { | 22 namespace base { |
| 23 class ListValue; | 23 class ListValue; |
| 24 class Thread; | 24 class Thread; |
| 25 } | 25 } |
| 26 | 26 |
| 27 namespace blink { |
| 28 class WebInputEvent; |
| 29 } |
| 30 |
| 27 namespace content { | 31 namespace content { |
| 28 class WebContents; | 32 class WebContents; |
| 29 } | 33 } |
| 30 | 34 |
| 31 namespace ui { | 35 namespace ui { |
| 32 class WindowAndroid; | 36 class WindowAndroid; |
| 33 } | 37 } |
| 34 | 38 |
| 35 namespace vr_shell { | 39 namespace vr_shell { |
| 36 | 40 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 58 public: | 62 public: |
| 59 VrShell(JNIEnv* env, jobject obj, | 63 VrShell(JNIEnv* env, jobject obj, |
| 60 content::WebContents* main_contents, | 64 content::WebContents* main_contents, |
| 61 ui::WindowAndroid* content_window, | 65 ui::WindowAndroid* content_window, |
| 62 content::WebContents* ui_contents, | 66 content::WebContents* ui_contents, |
| 63 ui::WindowAndroid* ui_window, | 67 ui::WindowAndroid* ui_window, |
| 64 bool for_web_vr, | 68 bool for_web_vr, |
| 65 VrShellDelegate* delegate, | 69 VrShellDelegate* delegate, |
| 66 gvr_context* gvr_api, | 70 gvr_context* gvr_api, |
| 67 bool reprojected_rendering); | 71 bool reprojected_rendering); |
| 68 | 72 void SwapContents(JNIEnv* env, |
| 73 const base::android::JavaParamRef<jobject>& obj, |
| 74 const base::android::JavaParamRef<jobject>& web_contents); |
| 69 void LoadUIContent(JNIEnv* env, | 75 void LoadUIContent(JNIEnv* env, |
| 70 const base::android::JavaParamRef<jobject>& obj); | 76 const base::android::JavaParamRef<jobject>& obj); |
| 71 void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); | 77 void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); |
| 72 void OnTriggerEvent(JNIEnv* env, | 78 void OnTriggerEvent(JNIEnv* env, |
| 73 const base::android::JavaParamRef<jobject>& obj); | 79 const base::android::JavaParamRef<jobject>& obj); |
| 74 void OnPause(JNIEnv* env, | 80 void OnPause(JNIEnv* env, |
| 75 const base::android::JavaParamRef<jobject>& obj); | 81 const base::android::JavaParamRef<jobject>& obj); |
| 76 void OnResume(JNIEnv* env, | 82 void OnResume(JNIEnv* env, |
| 77 const base::android::JavaParamRef<jobject>& obj); | 83 const base::android::JavaParamRef<jobject>& obj); |
| 78 void SetSurface(JNIEnv* env, | 84 void SetSurface(JNIEnv* env, |
| 79 const base::android::JavaParamRef<jobject>& obj, | 85 const base::android::JavaParamRef<jobject>& obj, |
| 80 const base::android::JavaParamRef<jobject>& surface); | 86 const base::android::JavaParamRef<jobject>& surface); |
| 81 void SetWebVrMode(JNIEnv* env, | 87 void SetWebVrMode(JNIEnv* env, |
| 82 const base::android::JavaParamRef<jobject>& obj, | 88 const base::android::JavaParamRef<jobject>& obj, |
| 83 bool enabled); | 89 bool enabled); |
| 84 void OnLoadProgressChanged(JNIEnv* env, | 90 void OnLoadProgressChanged(JNIEnv* env, |
| 85 const base::android::JavaParamRef<jobject>& obj, | 91 const base::android::JavaParamRef<jobject>& obj, |
| 86 double progress); | 92 double progress); |
| 87 | 93 |
| 88 void ContentWebContentsDestroyed(); | 94 void ContentWebContentsDestroyed(); |
| 89 // Called when our WebContents have been hidden. Usually a sign that something | 95 // Called when our WebContents have been hidden. Usually a sign that something |
| 90 // like another tab placed in front of it. | 96 // like another tab placed in front of it. |
| 91 void ContentWasHidden(); | 97 void ContentWasHidden(); |
| 98 void ContentWasShown(); |
| 92 | 99 |
| 93 // html/js UI hooks. | 100 // html/js UI hooks. |
| 94 static base::WeakPtr<VrShell> GetWeakPtr( | 101 static base::WeakPtr<VrShell> GetWeakPtr( |
| 95 const content::WebContents* web_contents); | 102 const content::WebContents* web_contents); |
| 96 | 103 |
| 97 // TODO(mthiesse): Clean up threading around UiInterface. | 104 // TODO(mthiesse): Clean up threading around UiInterface. |
| 98 UiInterface* GetUiInterface(); | 105 UiInterface* GetUiInterface(); |
| 99 void OnDomContentsLoaded(); | 106 void OnDomContentsLoaded(); |
| 100 | 107 |
| 101 // device::GvrDelegate implementation | 108 // device::GvrDelegate implementation |
| (...skipping 27 matching lines...) Expand all Loading... |
| 129 // Perform a UI action triggered by the javascript API. | 136 // Perform a UI action triggered by the javascript API. |
| 130 void DoUiAction(const UiAction action); | 137 void DoUiAction(const UiAction action); |
| 131 | 138 |
| 132 void SetContentCssSize(float width, float height, float dpr); | 139 void SetContentCssSize(float width, float height, float dpr); |
| 133 void SetUiCssSize(float width, float height, float dpr); | 140 void SetUiCssSize(float width, float height, float dpr); |
| 134 | 141 |
| 135 void ContentFrameWasResized(bool width_changed); | 142 void ContentFrameWasResized(bool width_changed); |
| 136 | 143 |
| 137 void ForceExitVr(); | 144 void ForceExitVr(); |
| 138 | 145 |
| 146 void ProcessUIGesture(std::unique_ptr<blink::WebInputEvent> event); |
| 147 void ProcessContentGesture(std::unique_ptr<blink::WebInputEvent> event); |
| 148 |
| 139 private: | 149 private: |
| 140 ~VrShell() override; | 150 ~VrShell() override; |
| 141 void SetIsInVR(bool is_in_vr); | |
| 142 void PostToGlThreadWhenReady(const base::Closure& task); | 151 void PostToGlThreadWhenReady(const base::Closure& task); |
| 143 | 152 |
| 144 // content::WebContentsObserver implementation. All called on UI thread. | 153 // content::WebContentsObserver implementation. All called on UI thread. |
| 145 void RenderViewHostChanged(content::RenderViewHost* old_host, | 154 void RenderViewHostChanged(content::RenderViewHost* old_host, |
| 146 content::RenderViewHost* new_host) override; | 155 content::RenderViewHost* new_host) override; |
| 147 void MainFrameWasResized(bool width_changed) override; | 156 void MainFrameWasResized(bool width_changed) override; |
| 148 void WebContentsDestroyed() override; | 157 void WebContentsDestroyed() override; |
| 149 | 158 |
| 150 std::unique_ptr<UiInterface> html_interface_; | 159 std::unique_ptr<UiInterface> html_interface_; |
| 151 | 160 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 170 base::WeakPtrFactory<VrShell> weak_ptr_factory_; | 179 base::WeakPtrFactory<VrShell> weak_ptr_factory_; |
| 171 | 180 |
| 172 DISALLOW_COPY_AND_ASSIGN(VrShell); | 181 DISALLOW_COPY_AND_ASSIGN(VrShell); |
| 173 }; | 182 }; |
| 174 | 183 |
| 175 bool RegisterVrShell(JNIEnv* env); | 184 bool RegisterVrShell(JNIEnv* env); |
| 176 | 185 |
| 177 } // namespace vr_shell | 186 } // namespace vr_shell |
| 178 | 187 |
| 179 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_ | 188 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_ |
| OLD | NEW |