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> |
| (...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()); | |
|
amp
2017/05/08 21:45:24
I was going to say we should wire up exiting full
tiborg
2017/05/09 15:00:36
Also, isn't fullscreen automatically exited when y
amp
2017/05/09 16:38:07
Yes it should be, although I'm not sure where that
| |
| 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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 407 height)); | 412 height)); |
| 408 compositor_->SetWindowBounds(gfx::Size(width, height)); | 413 compositor_->SetWindowBounds(gfx::Size(width, height)); |
| 409 } | 414 } |
| 410 | 415 |
| 411 // Note that the following code is obsolete and is here as reference for the | 416 // Note that the following code is obsolete and is here as reference for the |
| 412 // actions that need to be implemented natively. | 417 // actions that need to be implemented natively. |
| 413 void VrShell::DoUiAction(const UiAction action, | 418 void VrShell::DoUiAction(const UiAction action, |
| 414 const base::DictionaryValue* arguments) { | 419 const base::DictionaryValue* arguments) { |
| 415 // Actions that can be handled natively. | 420 // Actions that can be handled natively. |
| 416 switch (action) { | 421 switch (action) { |
| 417 case HISTORY_BACK: | |
| 418 if (web_contents_ && web_contents_->IsFullscreen()) { | |
| 419 web_contents_->ExitFullscreen(false); | |
| 420 return; | |
| 421 } | |
| 422 // Otherwise handle in java. | |
| 423 break; | |
| 424 case EXIT_PRESENT: | 422 case EXIT_PRESENT: |
| 425 delegate_provider_->ExitWebVRPresent(); | 423 delegate_provider_->ExitWebVRPresent(); |
| 426 return; | 424 return; |
| 427 default: | 425 default: |
| 428 break; | 426 break; |
| 429 } | 427 } |
| 430 // Actions that are handled in java. | 428 // Actions that are handled in java. |
| 431 JNIEnv* env = base::android::AttachCurrentThread(); | 429 JNIEnv* env = base::android::AttachCurrentThread(); |
| 432 switch (action) { | 430 switch (action) { |
| 433 case SHOW_TAB: { | 431 case SHOW_TAB: { |
| 434 int id; | 432 int id; |
| 435 CHECK(arguments->GetInteger("id", &id)); | 433 CHECK(arguments->GetInteger("id", &id)); |
| 436 Java_VrShellImpl_showTab(env, j_vr_shell_.obj(), id); | 434 Java_VrShellImpl_showTab(env, j_vr_shell_.obj(), id); |
| 437 return; | 435 return; |
| 438 } | 436 } |
| 439 case OPEN_NEW_TAB: { | 437 case OPEN_NEW_TAB: { |
| 440 bool incognito; | 438 bool incognito; |
| 441 CHECK(arguments->GetBoolean("incognito", &incognito)); | 439 CHECK(arguments->GetBoolean("incognito", &incognito)); |
| 442 Java_VrShellImpl_openNewTab(env, j_vr_shell_.obj(), incognito); | 440 Java_VrShellImpl_openNewTab(env, j_vr_shell_.obj(), incognito); |
| 443 return; | 441 return; |
| 444 } | 442 } |
| 445 case HISTORY_BACK: | |
| 446 Java_VrShellImpl_navigateBack(env, j_vr_shell_.obj()); | |
| 447 break; | |
| 448 case HISTORY_FORWARD: | 443 case HISTORY_FORWARD: |
| 449 Java_VrShellImpl_navigateForward(env, j_vr_shell_.obj()); | 444 Java_VrShellImpl_navigateForward(env, j_vr_shell_.obj()); |
| 450 break; | 445 break; |
| 451 case RELOAD: | 446 case RELOAD: |
| 452 Java_VrShellImpl_reload(env, j_vr_shell_.obj()); | 447 Java_VrShellImpl_reload(env, j_vr_shell_.obj()); |
| 453 break; | 448 break; |
| 454 default: | 449 default: |
| 455 NOTREACHED(); | 450 NOTREACHED(); |
| 456 } | 451 } |
| 457 } | 452 } |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 550 jlong gvr_api, | 545 jlong gvr_api, |
| 551 jboolean reprojected_rendering) { | 546 jboolean reprojected_rendering) { |
| 552 return reinterpret_cast<intptr_t>(new VrShell( | 547 return reinterpret_cast<intptr_t>(new VrShell( |
| 553 env, obj, reinterpret_cast<ui::WindowAndroid*>(window_android), | 548 env, obj, reinterpret_cast<ui::WindowAndroid*>(window_android), |
| 554 for_web_vr, in_cct, | 549 for_web_vr, in_cct, |
| 555 VrShellDelegate::GetNativeVrShellDelegate(env, delegate), | 550 VrShellDelegate::GetNativeVrShellDelegate(env, delegate), |
| 556 reinterpret_cast<gvr_context*>(gvr_api), reprojected_rendering)); | 551 reinterpret_cast<gvr_context*>(gvr_api), reprojected_rendering)); |
| 557 } | 552 } |
| 558 | 553 |
| 559 } // namespace vr_shell | 554 } // namespace vr_shell |
| OLD | NEW |