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

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

Issue 2384323003: Ensure that the web contents trying to access native VR Shell is the webcontents we created. (Closed)
Patch Set: Created 4 years, 2 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
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);
}
« no previous file with comments | « chrome/browser/android/vr_shell/vr_shell.h ('k') | chrome/browser/ui/webui/vr_shell/vr_shell_ui_message_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698