| 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 9e9b090a4b6aa4a9a5f82f0a0159b504a4301d1a..364b65b8ed4a3b061f54e859cab8a98ac2fa9575 100644
|
| --- a/chrome/browser/android/vr_shell/vr_shell.cc
|
| +++ b/chrome/browser/android/vr_shell/vr_shell.cc
|
| @@ -488,9 +488,12 @@ void VrShell::OnResume(JNIEnv* env, const JavaParamRef<jobject>& obj) {
|
| gvr_api_->ResumeTracking();
|
| }
|
|
|
| -base::WeakPtr<VrShell> VrShell::GetWeakPtr() {
|
| - // TODO: Ensure that only ui webcontents can request this weak ptr.
|
| - if (g_instance != nullptr)
|
| +base::WeakPtr<VrShell> VrShell::GetWeakPtr(
|
| + const content::WebContents* web_contents) {
|
| + // Ensure that the WebContents requesting the VrShell instance is the one
|
| + // we created.
|
| + if (g_instance != nullptr &&
|
| + g_instance->ui_cvc_->GetWebContents() == web_contents)
|
| return g_instance->weak_ptr_factory_.GetWeakPtr();
|
| return base::WeakPtr<VrShell>(nullptr);
|
| }
|
|
|