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

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

Issue 2632493005: Disable Android virtual keyboard when in VR shell (Closed)
Patch Set: Disable Android virtual keyboard when in VR shell 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 unified diff | Download patch
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 "base/metrics/histogram_macros.h" 9 #include "base/metrics/histogram_macros.h"
10 #include "base/threading/platform_thread.h" 10 #include "base/threading/platform_thread.h"
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 gl_thread_->StartWithOptions(options); 142 gl_thread_->StartWithOptions(options);
143 143
144 if (for_web_vr) 144 if (for_web_vr)
145 metrics_helper_->SetWebVREnabled(true); 145 metrics_helper_->SetWebVREnabled(true);
146 html_interface_.reset(new UiInterface( 146 html_interface_.reset(new UiInterface(
147 for_web_vr ? UiInterface::Mode::WEB_VR : UiInterface::Mode::STANDARD, 147 for_web_vr ? UiInterface::Mode::WEB_VR : UiInterface::Mode::STANDARD,
148 main_contents_->IsFullscreen())); 148 main_contents_->IsFullscreen()));
149 vr_web_contents_observer_.reset(new VrWebContentsObserver( 149 vr_web_contents_observer_.reset(new VrWebContentsObserver(
150 main_contents, html_interface_.get(), this)); 150 main_contents, html_interface_.get(), this));
151 151
152 SetShowingOverscrollGlow(false); 152 SetIsInVR(true);
153 } 153 }
154 154
155 void VrShell::Destroy(JNIEnv* env, const JavaParamRef<jobject>& obj) { 155 void VrShell::Destroy(JNIEnv* env, const JavaParamRef<jobject>& obj) {
156 delete this; 156 delete this;
157 } 157 }
158 158
159 void VrShell::LoadUIContent(JNIEnv* env, const JavaParamRef<jobject>& obj) { 159 void VrShell::LoadUIContent(JNIEnv* env, const JavaParamRef<jobject>& obj) {
160 GURL url(kVrShellUIURL); 160 GURL url(kVrShellUIURL);
161 ui_contents_->GetController().LoadURL( 161 ui_contents_->GetController().LoadURL(
162 url, content::Referrer(), 162 url, content::Referrer(),
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 thread->GetVrShellGl())); 202 thread->GetVrShellGl()));
203 } 203 }
204 204
205 void VrShell::OnPause(JNIEnv* env, const JavaParamRef<jobject>& obj) { 205 void VrShell::OnPause(JNIEnv* env, const JavaParamRef<jobject>& obj) {
206 GLThread* thread = static_cast<GLThread*>(gl_thread_.get()); 206 GLThread* thread = static_cast<GLThread*>(gl_thread_.get());
207 thread->task_runner()->PostTask( 207 thread->task_runner()->PostTask(
208 FROM_HERE, base::Bind(&VrShellGl::OnPause, thread->GetVrShellGl())); 208 FROM_HERE, base::Bind(&VrShellGl::OnPause, thread->GetVrShellGl()));
209 209
210 // exit vr session 210 // exit vr session
211 metrics_helper_->SetVRActive(false); 211 metrics_helper_->SetVRActive(false);
212 SetShowingOverscrollGlow(true); 212 SetIsInVR(false);
213 } 213 }
214 214
215 void VrShell::OnResume(JNIEnv* env, const JavaParamRef<jobject>& obj) { 215 void VrShell::OnResume(JNIEnv* env, const JavaParamRef<jobject>& obj) {
216 GLThread* thread = static_cast<GLThread*>(gl_thread_.get()); 216 GLThread* thread = static_cast<GLThread*>(gl_thread_.get());
217 thread->task_runner()->PostTask( 217 thread->task_runner()->PostTask(
218 FROM_HERE, base::Bind(&VrShellGl::OnResume, thread->GetVrShellGl())); 218 FROM_HERE, base::Bind(&VrShellGl::OnResume, thread->GetVrShellGl()));
219 219
220 // exit vr session 220 // exit vr session
bshe 2017/01/17 12:26:15 nit: not related to your change, but do you mind r
221 metrics_helper_->SetVRActive(true); 221 metrics_helper_->SetVRActive(true);
222 SetShowingOverscrollGlow(false); 222 SetIsInVR(true);
223 } 223 }
224 224
225 void VrShell::SetSurface(JNIEnv* env, 225 void VrShell::SetSurface(JNIEnv* env,
226 const JavaParamRef<jobject>& obj, 226 const JavaParamRef<jobject>& obj,
227 const JavaParamRef<jobject>& surface) { 227 const JavaParamRef<jobject>& surface) {
228 CHECK(!reprojected_rendering_); 228 CHECK(!reprojected_rendering_);
229 GLThread* thread = static_cast<GLThread*>(gl_thread_.get()); 229 GLThread* thread = static_cast<GLThread*>(gl_thread_.get());
230 gfx::AcceleratedWidget window = 230 gfx::AcceleratedWidget window =
231 ANativeWindow_fromSurface(base::android::AttachCurrentThread(), surface); 231 ANativeWindow_fromSurface(base::android::AttachCurrentThread(), surface);
232 PostToGlThreadWhenReady(base::Bind(&VrShellGl::InitializeGl, 232 PostToGlThreadWhenReady(base::Bind(&VrShellGl::InitializeGl,
233 thread->GetVrShellGl(), 233 thread->GetVrShellGl(),
234 base::Unretained(window))); 234 base::Unretained(window)));
235 } 235 }
236 236
237 void VrShell::SetShowingOverscrollGlow(bool showing_glow) { 237 void VrShell::SetIsInVR(bool is_in_vr) {
238 main_contents_->GetRenderWidgetHostView()->SetShowingOverscrollGlow( 238 main_contents_->GetRenderWidgetHostView()->SetIsInVR(is_in_vr);
239 showing_glow);
240 } 239 }
241 240
242 base::WeakPtr<VrShell> VrShell::GetWeakPtr( 241 base::WeakPtr<VrShell> VrShell::GetWeakPtr(
243 const content::WebContents* web_contents) { 242 const content::WebContents* web_contents) {
244 // Ensure that the WebContents requesting the VrShell instance is the one 243 // Ensure that the WebContents requesting the VrShell instance is the one
245 // we created. 244 // we created.
246 if (g_instance != nullptr && g_instance->ui_contents_ == web_contents) 245 if (g_instance != nullptr && g_instance->ui_contents_ == web_contents)
247 return g_instance->weak_ptr_factory_.GetWeakPtr(); 246 return g_instance->weak_ptr_factory_.GetWeakPtr();
248 return base::WeakPtr<VrShell>(nullptr); 247 return base::WeakPtr<VrShell>(nullptr);
249 } 248 }
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 return reinterpret_cast<intptr_t>(new VrShell( 483 return reinterpret_cast<intptr_t>(new VrShell(
485 env, obj, content::WebContents::FromJavaWebContents(content_web_contents), 484 env, obj, content::WebContents::FromJavaWebContents(content_web_contents),
486 reinterpret_cast<ui::WindowAndroid*>(content_window_android), 485 reinterpret_cast<ui::WindowAndroid*>(content_window_android),
487 content::WebContents::FromJavaWebContents(ui_web_contents), 486 content::WebContents::FromJavaWebContents(ui_web_contents),
488 reinterpret_cast<ui::WindowAndroid*>(ui_window_android), 487 reinterpret_cast<ui::WindowAndroid*>(ui_window_android),
489 for_web_vr, VrShellDelegate::GetNativeDelegate(env, delegate), 488 for_web_vr, VrShellDelegate::GetNativeDelegate(env, delegate),
490 reinterpret_cast<gvr_context*>(gvr_api), reprojected_rendering)); 489 reinterpret_cast<gvr_context*>(gvr_api), reprojected_rendering));
491 } 490 }
492 491
493 } // namespace vr_shell 492 } // namespace vr_shell
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/vr_shell.h ('k') | chrome/browser/android/vr_shell/vr_web_contents_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698