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

Side by Side Diff: chrome/browser/android/vr_shell/vr_shell.cc

Issue 2736083002: Suppress the Android keyboard when selecting VR UI input fields. (Closed)
Patch Set: Reorder class forward declarations. Created 3 years, 9 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/android/vr_shell/vr_shell.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 56
57 static const char kVrShellUIURL[] = "chrome://vr-shell-ui"; 57 static const char kVrShellUIURL[] = "chrome://vr-shell-ui";
58 58
59 void SetIsInVR(content::WebContents* contents, bool is_in_vr) { 59 void SetIsInVR(content::WebContents* contents, bool is_in_vr) {
60 if (contents && contents->GetRenderWidgetHostView()) 60 if (contents && contents->GetRenderWidgetHostView())
61 contents->GetRenderWidgetHostView()->SetIsInVR(is_in_vr); 61 contents->GetRenderWidgetHostView()->SetIsInVR(is_in_vr);
62 } 62 }
63 63
64 } // namespace 64 } // namespace
65 65
66 class UiWebContentsObserver : public content::WebContentsObserver {
cjgrant 2017/03/07 20:34:47 This class could live in a separate file, but give
mthiesse 2017/03/07 20:49:24 VrShell is already an observer of the UI web conte
cjgrant 2017/03/07 21:08:46 Done. Wow, need to check eyes.
67 public:
68 explicit UiWebContentsObserver(content::WebContents* web_contents)
69 : WebContentsObserver(web_contents) {}
70
71 private:
72 void RenderViewHostChanged(content::RenderViewHost* old_host,
73 content::RenderViewHost* new_host) override {
74 new_host->GetWidget()->GetView()->SetIsInVR(true);
75 }
76
77 DISALLOW_COPY_AND_ASSIGN(UiWebContentsObserver);
78 };
79
66 VrShell::VrShell(JNIEnv* env, 80 VrShell::VrShell(JNIEnv* env,
67 jobject obj, 81 jobject obj,
68 ui::WindowAndroid* content_window, 82 ui::WindowAndroid* content_window,
69 content::WebContents* ui_contents, 83 content::WebContents* ui_contents,
70 ui::WindowAndroid* ui_window, 84 ui::WindowAndroid* ui_window,
71 bool for_web_vr, 85 bool for_web_vr,
72 VrShellDelegate* delegate, 86 VrShellDelegate* delegate,
73 gvr_context* gvr_api, 87 gvr_context* gvr_api,
74 bool reprojected_rendering) 88 bool reprojected_rendering)
75 : WebContentsObserver(ui_contents), 89 : WebContentsObserver(ui_contents),
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 j_motion_event_synthesizer_.obj(), 145 j_motion_event_synthesizer_.obj(),
132 Java_VrShellImpl_getNativePageScrollRatio(env, j_vr_shell_.obj())); 146 Java_VrShellImpl_getNativePageScrollRatio(env, j_vr_shell_.obj()));
133 content_input_manager_ = nullptr; 147 content_input_manager_ = nullptr;
134 vr_web_contents_observer_ = nullptr; 148 vr_web_contents_observer_ = nullptr;
135 metrics_helper_ = nullptr; 149 metrics_helper_ = nullptr;
136 return; 150 return;
137 } 151 }
138 content_input_manager_ = base::MakeUnique<VrInputManager>(main_contents_); 152 content_input_manager_ = base::MakeUnique<VrInputManager>(main_contents_);
139 vr_web_contents_observer_ = base::MakeUnique<VrWebContentsObserver>( 153 vr_web_contents_observer_ = base::MakeUnique<VrWebContentsObserver>(
140 main_contents_, html_interface_.get(), this); 154 main_contents_, html_interface_.get(), this);
155 ui_web_contents_observer_ =
156 base::MakeUnique<UiWebContentsObserver>(ui_contents_);
141 // TODO(billorr): Make VrMetricsHelper tab-aware and able to track multiple 157 // TODO(billorr): Make VrMetricsHelper tab-aware and able to track multiple
142 // tabs. crbug.com/684661 158 // tabs. crbug.com/684661
143 metrics_helper_ = base::MakeUnique<VrMetricsHelper>(main_contents_); 159 metrics_helper_ = base::MakeUnique<VrMetricsHelper>(main_contents_);
144 metrics_helper_->SetVRActive(true); 160 metrics_helper_->SetVRActive(true);
145 metrics_helper_->SetWebVREnabled(webvr_mode_); 161 metrics_helper_->SetWebVREnabled(webvr_mode_);
146 } 162 }
147 163
148 void VrShell::SetUiState() { 164 void VrShell::SetUiState() {
149 if (!main_contents_) { 165 if (!main_contents_) {
150 // TODO(mthiesse): Properly handle native page URLs. 166 // TODO(mthiesse): Properly handle native page URLs.
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 jboolean reprojected_rendering) { 703 jboolean reprojected_rendering) {
688 return reinterpret_cast<intptr_t>(new VrShell( 704 return reinterpret_cast<intptr_t>(new VrShell(
689 env, obj, reinterpret_cast<ui::WindowAndroid*>(content_window_android), 705 env, obj, reinterpret_cast<ui::WindowAndroid*>(content_window_android),
690 content::WebContents::FromJavaWebContents(ui_web_contents), 706 content::WebContents::FromJavaWebContents(ui_web_contents),
691 reinterpret_cast<ui::WindowAndroid*>(ui_window_android), for_web_vr, 707 reinterpret_cast<ui::WindowAndroid*>(ui_window_android), for_web_vr,
692 VrShellDelegate::GetNativeVrShellDelegate(env, delegate), 708 VrShellDelegate::GetNativeVrShellDelegate(env, delegate),
693 reinterpret_cast<gvr_context*>(gvr_api), reprojected_rendering)); 709 reinterpret_cast<gvr_context*>(gvr_api), reprojected_rendering));
694 } 710 }
695 711
696 } // namespace vr_shell 712 } // namespace vr_shell
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/vr_shell.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698