| 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 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 return; | 218 return; |
| 219 | 219 |
| 220 // TODO(mthiesse): The page is no longer visible when in menu mode. We | 220 // TODO(mthiesse): The page is no longer visible when in menu mode. We |
| 221 // should unfocus or otherwise let it know it's hidden. | 221 // should unfocus or otherwise let it know it's hidden. |
| 222 if (paused) | 222 if (paused) |
| 223 delegate_provider_->device_provider()->Device()->OnBlur(); | 223 delegate_provider_->device_provider()->Device()->OnBlur(); |
| 224 else | 224 else |
| 225 delegate_provider_->device_provider()->Device()->OnFocus(); | 225 delegate_provider_->device_provider()->Device()->OnFocus(); |
| 226 } | 226 } |
| 227 | 227 |
| 228 void VrShell::NavigateBack() { |
| 229 JNIEnv* env = base::android::AttachCurrentThread(); |
| 230 Java_VrShellImpl_navigateBack(env, j_vr_shell_.obj()); |
| 231 } |
| 232 |
| 228 void VrShell::OnTriggerEvent(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 233 void VrShell::OnTriggerEvent(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| 229 gl_thread_->task_runner()->PostTask( | 234 gl_thread_->task_runner()->PostTask( |
| 230 FROM_HERE, | 235 FROM_HERE, |
| 231 base::Bind(&VrShellGl::OnTriggerEvent, gl_thread_->GetVrShellGl())); | 236 base::Bind(&VrShellGl::OnTriggerEvent, gl_thread_->GetVrShellGl())); |
| 232 } | 237 } |
| 233 | 238 |
| 234 void VrShell::OnPause(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 239 void VrShell::OnPause(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| 235 gl_thread_->task_runner()->PostTask( | 240 gl_thread_->task_runner()->PostTask( |
| 236 FROM_HERE, base::Bind(&VrShellGl::OnPause, gl_thread_->GetVrShellGl())); | 241 FROM_HERE, base::Bind(&VrShellGl::OnPause, gl_thread_->GetVrShellGl())); |
| 237 | 242 |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 height)); | 418 height)); |
| 414 compositor_->SetWindowBounds(gfx::Size(width, height)); | 419 compositor_->SetWindowBounds(gfx::Size(width, height)); |
| 415 } | 420 } |
| 416 | 421 |
| 417 // Note that the following code is obsolete and is here as reference for the | 422 // Note that the following code is obsolete and is here as reference for the |
| 418 // actions that need to be implemented natively. | 423 // actions that need to be implemented natively. |
| 419 void VrShell::DoUiAction(const UiAction action, | 424 void VrShell::DoUiAction(const UiAction action, |
| 420 const base::DictionaryValue* arguments) { | 425 const base::DictionaryValue* arguments) { |
| 421 // Actions that can be handled natively. | 426 // Actions that can be handled natively. |
| 422 switch (action) { | 427 switch (action) { |
| 423 case HISTORY_BACK: | |
| 424 if (web_contents_ && web_contents_->IsFullscreen()) { | |
| 425 web_contents_->ExitFullscreen(false); | |
| 426 return; | |
| 427 } | |
| 428 // Otherwise handle in java. | |
| 429 break; | |
| 430 case EXIT_PRESENT: | 428 case EXIT_PRESENT: |
| 431 delegate_provider_->ExitWebVRPresent(); | 429 delegate_provider_->ExitWebVRPresent(); |
| 432 return; | 430 return; |
| 433 default: | 431 default: |
| 434 break; | 432 break; |
| 435 } | 433 } |
| 436 // Actions that are handled in java. | 434 // Actions that are handled in java. |
| 437 JNIEnv* env = base::android::AttachCurrentThread(); | 435 JNIEnv* env = base::android::AttachCurrentThread(); |
| 438 switch (action) { | 436 switch (action) { |
| 439 case SHOW_TAB: { | 437 case SHOW_TAB: { |
| 440 int id; | 438 int id; |
| 441 CHECK(arguments->GetInteger("id", &id)); | 439 CHECK(arguments->GetInteger("id", &id)); |
| 442 Java_VrShellImpl_showTab(env, j_vr_shell_.obj(), id); | 440 Java_VrShellImpl_showTab(env, j_vr_shell_.obj(), id); |
| 443 return; | 441 return; |
| 444 } | 442 } |
| 445 case OPEN_NEW_TAB: { | 443 case OPEN_NEW_TAB: { |
| 446 bool incognito; | 444 bool incognito; |
| 447 CHECK(arguments->GetBoolean("incognito", &incognito)); | 445 CHECK(arguments->GetBoolean("incognito", &incognito)); |
| 448 Java_VrShellImpl_openNewTab(env, j_vr_shell_.obj(), incognito); | 446 Java_VrShellImpl_openNewTab(env, j_vr_shell_.obj(), incognito); |
| 449 return; | 447 return; |
| 450 } | 448 } |
| 451 case HISTORY_BACK: | |
| 452 Java_VrShellImpl_navigateBack(env, j_vr_shell_.obj()); | |
| 453 break; | |
| 454 case HISTORY_FORWARD: | 449 case HISTORY_FORWARD: |
| 455 Java_VrShellImpl_navigateForward(env, j_vr_shell_.obj()); | 450 Java_VrShellImpl_navigateForward(env, j_vr_shell_.obj()); |
| 456 break; | 451 break; |
| 457 case RELOAD: | 452 case RELOAD: |
| 458 Java_VrShellImpl_reload(env, j_vr_shell_.obj()); | 453 Java_VrShellImpl_reload(env, j_vr_shell_.obj()); |
| 459 break; | 454 break; |
| 460 default: | 455 default: |
| 461 NOTREACHED(); | 456 NOTREACHED(); |
| 462 } | 457 } |
| 463 } | 458 } |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 jlong gvr_api, | 551 jlong gvr_api, |
| 557 jboolean reprojected_rendering) { | 552 jboolean reprojected_rendering) { |
| 558 return reinterpret_cast<intptr_t>(new VrShell( | 553 return reinterpret_cast<intptr_t>(new VrShell( |
| 559 env, obj, reinterpret_cast<ui::WindowAndroid*>(window_android), | 554 env, obj, reinterpret_cast<ui::WindowAndroid*>(window_android), |
| 560 for_web_vr, in_cct, | 555 for_web_vr, in_cct, |
| 561 VrShellDelegate::GetNativeVrShellDelegate(env, delegate), | 556 VrShellDelegate::GetNativeVrShellDelegate(env, delegate), |
| 562 reinterpret_cast<gvr_context*>(gvr_api), reprojected_rendering)); | 557 reinterpret_cast<gvr_context*>(gvr_api), reprojected_rendering)); |
| 563 } | 558 } |
| 564 | 559 |
| 565 } // namespace vr_shell | 560 } // namespace vr_shell |
| OLD | NEW |