Chromium Code Reviews| 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> |
| 11 | 11 |
| 12 #include "base/android/jni_string.h" | 12 #include "base/android/jni_string.h" |
| 13 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
| 14 #include "base/metrics/histogram_macros.h" | 14 #include "base/metrics/histogram_macros.h" |
| 15 #include "base/threading/platform_thread.h" | 15 #include "base/threading/platform_thread.h" |
| 16 #include "base/threading/thread.h" | 16 #include "base/threading/thread.h" |
| 17 #include "base/threading/thread_restrictions.h" | 17 #include "base/threading/thread_restrictions.h" |
| 18 #include "base/threading/thread_task_runner_handle.h" | 18 #include "base/threading/thread_task_runner_handle.h" |
| 19 #include "base/trace_event/trace_event.h" | 19 #include "base/trace_event/trace_event.h" |
| 20 #include "base/values.h" | 20 #include "base/values.h" |
| 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/vr_compositor.h" | 25 #include "chrome/browser/android/vr_shell/vr_compositor.h" |
| 25 #include "chrome/browser/android/vr_shell/vr_controller_model.h" | 26 #include "chrome/browser/android/vr_shell/vr_controller_model.h" |
| 26 #include "chrome/browser/android/vr_shell/vr_gl_thread.h" | 27 #include "chrome/browser/android/vr_shell/vr_gl_thread.h" |
| 27 #include "chrome/browser/android/vr_shell/vr_input_manager.h" | 28 #include "chrome/browser/android/vr_shell/vr_input_manager.h" |
| 28 #include "chrome/browser/android/vr_shell/vr_shell_delegate.h" | 29 #include "chrome/browser/android/vr_shell/vr_shell_delegate.h" |
| 29 #include "chrome/browser/android/vr_shell/vr_shell_gl.h" | 30 #include "chrome/browser/android/vr_shell/vr_shell_gl.h" |
| 30 #include "chrome/browser/android/vr_shell/vr_usage_monitor.h" | 31 #include "chrome/browser/android/vr_shell/vr_usage_monitor.h" |
| 31 #include "chrome/browser/android/vr_shell/vr_web_contents_observer.h" | 32 #include "chrome/browser/android/vr_shell/vr_web_contents_observer.h" |
| 32 #include "content/public/browser/browser_thread.h" | 33 #include "content/public/browser/browser_thread.h" |
| 33 #include "content/public/browser/navigation_controller.h" | 34 #include "content/public/browser/navigation_controller.h" |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 296 const base::android::JavaParamRef<jobject>& obj, | 297 const base::android::JavaParamRef<jobject>& obj, |
| 297 bool enabled) { | 298 bool enabled) { |
| 298 webvr_mode_ = enabled; | 299 webvr_mode_ = enabled; |
| 299 if (metrics_helper_) | 300 if (metrics_helper_) |
| 300 metrics_helper_->SetWebVREnabled(enabled); | 301 metrics_helper_->SetWebVREnabled(enabled); |
| 301 PostToGlThreadWhenReady(base::Bind(&VrShellGl::SetWebVrMode, | 302 PostToGlThreadWhenReady(base::Bind(&VrShellGl::SetWebVrMode, |
| 302 gl_thread_->GetVrShellGl(), enabled)); | 303 gl_thread_->GetVrShellGl(), enabled)); |
| 303 | 304 |
| 304 html_interface_->SetMode(enabled ? UiInterface::Mode::WEB_VR | 305 html_interface_->SetMode(enabled ? UiInterface::Mode::WEB_VR |
| 305 : UiInterface::Mode::STANDARD); | 306 : UiInterface::Mode::STANDARD); |
| 307 PostToGlThreadWhenReady(base::Bind(&UiSceneManager::SetWebVRMode, | |
|
cjgrant
2017/04/11 14:54:30
This is what clang-format does; not how I would ha
| |
| 308 gl_thread_->GetSceneManager(), enabled)); | |
| 306 } | 309 } |
| 307 | 310 |
| 308 void VrShell::OnLoadProgressChanged(JNIEnv* env, | 311 void VrShell::OnLoadProgressChanged(JNIEnv* env, |
| 309 const JavaParamRef<jobject>& obj, | 312 const JavaParamRef<jobject>& obj, |
| 310 double progress) { | 313 double progress) { |
| 311 html_interface_->SetLoadProgress(progress); | 314 html_interface_->SetLoadProgress(progress); |
| 312 } | 315 } |
| 313 | 316 |
| 314 void VrShell::OnTabListCreated(JNIEnv* env, | 317 void VrShell::OnTabListCreated(JNIEnv* env, |
| 315 const JavaParamRef<jobject>& obj, | 318 const JavaParamRef<jobject>& obj, |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 345 void VrShell::OnTabRemoved(JNIEnv* env, | 348 void VrShell::OnTabRemoved(JNIEnv* env, |
| 346 const JavaParamRef<jobject>& obj, | 349 const JavaParamRef<jobject>& obj, |
| 347 jboolean incognito, | 350 jboolean incognito, |
| 348 jint id) { | 351 jint id) { |
| 349 html_interface_->RemoveTab(incognito, id); | 352 html_interface_->RemoveTab(incognito, id); |
| 350 } | 353 } |
| 351 | 354 |
| 352 void VrShell::SetWebVRSecureOrigin(bool secure_origin) { | 355 void VrShell::SetWebVRSecureOrigin(bool secure_origin) { |
| 353 // TODO(cjgrant): Align this state with the logic that drives the omnibox. | 356 // TODO(cjgrant): Align this state with the logic that drives the omnibox. |
| 354 html_interface_->SetWebVRSecureOrigin(secure_origin); | 357 html_interface_->SetWebVRSecureOrigin(secure_origin); |
| 358 PostToGlThreadWhenReady(base::Bind(&UiSceneManager::SetWebVRSecureOrigin, | |
| 359 gl_thread_->GetSceneManager(), | |
| 360 secure_origin)); | |
| 355 } | 361 } |
| 356 | 362 |
| 357 void VrShell::SubmitWebVRFrame(int16_t frame_index, | 363 void VrShell::SubmitWebVRFrame(int16_t frame_index, |
| 358 const gpu::MailboxHolder& mailbox) { | 364 const gpu::MailboxHolder& mailbox) { |
| 359 TRACE_EVENT1("gpu", "SubmitWebVRFrame", "frame", frame_index); | 365 TRACE_EVENT1("gpu", "SubmitWebVRFrame", "frame", frame_index); |
| 360 | 366 |
| 361 PostToGlThreadWhenReady(base::Bind(&VrShellGl::SubmitWebVRFrame, | 367 PostToGlThreadWhenReady(base::Bind(&VrShellGl::SubmitWebVRFrame, |
| 362 gl_thread_->GetVrShellGl(), frame_index, | 368 gl_thread_->GetVrShellGl(), frame_index, |
| 363 mailbox)); | 369 mailbox)); |
| 364 } | 370 } |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 461 gl_thread_->GetVrShellGl(), width, | 467 gl_thread_->GetVrShellGl(), width, |
| 462 height)); | 468 height)); |
| 463 ui_compositor_->SetWindowBounds(gfx::Size(width, height)); | 469 ui_compositor_->SetWindowBounds(gfx::Size(width, height)); |
| 464 } | 470 } |
| 465 | 471 |
| 466 UiInterface* VrShell::GetUiInterface() { | 472 UiInterface* VrShell::GetUiInterface() { |
| 467 return html_interface_.get(); | 473 return html_interface_.get(); |
| 468 } | 474 } |
| 469 | 475 |
| 470 void VrShell::UpdateScene(const base::ListValue* args) { | 476 void VrShell::UpdateScene(const base::ListValue* args) { |
| 471 PostToGlThreadWhenReady(base::Bind(&VrShellGl::UpdateScene, | 477 PostToGlThreadWhenReady(base::Bind(&UiSceneManager::UpdateScene, |
| 472 gl_thread_->GetVrShellGl(), | 478 gl_thread_->GetSceneManager(), |
| 473 base::Passed(args->CreateDeepCopy()))); | 479 base::Passed(args->CreateDeepCopy()))); |
| 474 } | 480 } |
| 475 | 481 |
| 476 void VrShell::DoUiAction(const UiAction action, | 482 void VrShell::DoUiAction(const UiAction action, |
| 477 const base::DictionaryValue* arguments) { | 483 const base::DictionaryValue* arguments) { |
| 478 // Actions that can be handled natively. | 484 // Actions that can be handled natively. |
| 479 switch (action) { | 485 switch (action) { |
| 480 case OMNIBOX_CONTENT: | 486 case OMNIBOX_CONTENT: |
| 481 html_interface_->HandleOmniboxInput(*arguments); | 487 html_interface_->HandleOmniboxInput(*arguments); |
| 482 return; | 488 return; |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 686 jboolean reprojected_rendering) { | 692 jboolean reprojected_rendering) { |
| 687 return reinterpret_cast<intptr_t>(new VrShell( | 693 return reinterpret_cast<intptr_t>(new VrShell( |
| 688 env, obj, reinterpret_cast<ui::WindowAndroid*>(content_window_android), | 694 env, obj, reinterpret_cast<ui::WindowAndroid*>(content_window_android), |
| 689 content::WebContents::FromJavaWebContents(ui_web_contents), | 695 content::WebContents::FromJavaWebContents(ui_web_contents), |
| 690 reinterpret_cast<ui::WindowAndroid*>(ui_window_android), for_web_vr, | 696 reinterpret_cast<ui::WindowAndroid*>(ui_window_android), for_web_vr, |
| 691 VrShellDelegate::GetNativeVrShellDelegate(env, delegate), | 697 VrShellDelegate::GetNativeVrShellDelegate(env, delegate), |
| 692 reinterpret_cast<gvr_context*>(gvr_api), reprojected_rendering)); | 698 reinterpret_cast<gvr_context*>(gvr_api), reprojected_rendering)); |
| 693 } | 699 } |
| 694 | 700 |
| 695 } // namespace vr_shell | 701 } // namespace vr_shell |
| OLD | NEW |