Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Unified Diff: chrome/browser/android/vr_shell/vr_shell.cc

Issue 2661823002: NOT FOR REVIEW: A set of patches for Josh to work on top of. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/android/vr_shell/vr_shell.h ('k') | chrome/browser/browser_resources.grd » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/vr_shell/vr_shell.cc
diff --git a/chrome/browser/android/vr_shell/vr_shell.cc b/chrome/browser/android/vr_shell/vr_shell.cc
index 2704107f39f8ccb77ce9870fe9049ad93e3da1ef..bb2c5a7bcc5b6cbdac995612b48c457aefc6b4f8 100644
--- a/chrome/browser/android/vr_shell/vr_shell.cc
+++ b/chrome/browser/android/vr_shell/vr_shell.cc
@@ -6,6 +6,9 @@
#include <android/native_window_jni.h>
+#include <string>
+#include <utility>
+
#include "base/metrics/histogram_macros.h"
#include "base/threading/platform_thread.h"
#include "base/threading/thread.h"
@@ -234,7 +237,10 @@ void VrShell::SetSurface(JNIEnv* env,
}
void VrShell::SetIsInVR(bool is_in_vr) {
- main_contents_->GetRenderWidgetHostView()->SetIsInVR(is_in_vr);
+ if (main_contents_->GetRenderWidgetHostView() != nullptr)
+ main_contents_->GetRenderWidgetHostView()->SetIsInVR(is_in_vr);
+ if (ui_contents_->GetRenderWidgetHostView() != nullptr)
+ ui_contents_->GetRenderWidgetHostView()->SetIsInVR(is_in_vr);
}
base::WeakPtr<VrShell> VrShell::GetWeakPtr(
@@ -329,19 +335,7 @@ void VrShell::GvrDelegateReady() {
void VrShell::AppButtonPressed() {
#if defined(ENABLE_VR_SHELL)
- html_interface_->SetMenuMode(!html_interface_->GetMenuMode());
-
- // TODO(mthiesse): The page is no longer visible when in menu mode. We
- // should unfocus or otherwise let it know it's hidden.
- if (html_interface_->GetMode() == UiInterface::Mode::WEB_VR) {
- if (delegate_->device_provider()) {
- if (html_interface_->GetMenuMode()) {
- delegate_->device_provider()->OnDisplayBlur();
- } else {
- delegate_->device_provider()->OnDisplayFocus();
- }
- }
- }
+ html_interface_->HandleAppButtonClicked();
#endif
}
@@ -376,7 +370,8 @@ void VrShell::UpdateScene(const base::ListValue* args) {
base::Passed(args->CreateDeepCopy())));
}
-void VrShell::DoUiAction(const UiAction action) {
+void VrShell::DoUiAction(const UiAction action,
+ const base::DictionaryValue* arguments) {
content::NavigationController& controller = main_contents_->GetController();
switch (action) {
case HISTORY_BACK:
@@ -393,6 +388,34 @@ void VrShell::DoUiAction(const UiAction action) {
case RELOAD:
controller.Reload(content::ReloadType::NORMAL, false);
break;
+ case LOAD_URL: {
+ std::string url_string;
+ CHECK(arguments->GetString("url", &url_string));
+ GURL url(url_string);
+ // TODO(crbug.com/683344): Sanitize the URL and prefix, and pass the
+ // proper transition type down from the UI.
+ controller.LoadURL(url, content::Referrer(),
+ ui::PageTransition::PAGE_TRANSITION_AUTO_TOPLEVEL,
+ std::string(""));
+ break;
+ }
+ case OMNIBOX_CONTENT:
+ html_interface_->HandleOmniboxInput(*arguments);
+ break;
+ case KEY_EVENT: {
+ int char_value;
+ int modifiers;
+ CHECK(arguments->GetInteger("modifiers", &modifiers));
+ CHECK(arguments->GetInteger("charValue", &char_value));
+ ui_input_manager_->ProcessKeyboardEvent(char_value, modifiers);
+ break;
+ }
+ case SET_CONTENT_PAUSED: {
+ bool paused;
+ CHECK(arguments->GetBoolean("paused", &paused));
+ SetContentPaused(paused);
+ break;
+ }
#if defined(ENABLE_VR_SHELL_UI_DEV)
case RELOAD_UI:
ui_contents_->GetController().Reload(content::ReloadType::NORMAL, false);
@@ -412,6 +435,7 @@ void VrShell::DoUiAction(const UiAction action) {
void VrShell::RenderViewHostChanged(content::RenderViewHost* old_host,
content::RenderViewHost* new_host) {
new_host->GetWidget()->GetView()->SetBackgroundColor(SK_ColorTRANSPARENT);
+ SetIsInVR(true);
}
void VrShell::MainFrameWasResized(bool width_changed) {
@@ -468,6 +492,19 @@ void VrShell::SetUiCssSize(float width, float height, float dpr) {
Java_VrShellImpl_setUiCssSize(env, j_vr_shell_.obj(), width, height, dpr);
}
+void VrShell::SetContentPaused(bool paused) {
+ // TODO(mthiesse): The page is no longer visible when in menu mode. We
+ // should unfocus or otherwise let it know it's hidden.
+ if (delegate_->device_provider()) {
+ if (paused) {
+ delegate_->device_provider()->OnDisplayBlur();
+ } else {
+ delegate_->device_provider()->OnDisplayFocus();
+ }
+ }
+ content_paused_ = paused;
+}
+
// ----------------------------------------------------------------------------
// Native JNI methods
// ----------------------------------------------------------------------------
« no previous file with comments | « chrome/browser/android/vr_shell/vr_shell.h ('k') | chrome/browser/browser_resources.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698