Chromium Code Reviews

Unified Diff: chrome/browser/extensions/webstore_inline_installer.cc

Issue 1403293008: Don't allow inline install if frame is deleted before user accepts (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Index: chrome/browser/extensions/webstore_inline_installer.cc
diff --git a/chrome/browser/extensions/webstore_inline_installer.cc b/chrome/browser/extensions/webstore_inline_installer.cc
index 045d996465d3616d7cded6e997339c801ebfa203..1092e278f5c734352e5cbdc4e03116bceb1b3d3a 100644
--- a/chrome/browser/extensions/webstore_inline_installer.cc
+++ b/chrome/browser/extensions/webstore_inline_installer.cc
@@ -29,6 +29,7 @@ const char kInitiatedFromPopupError[] =
WebstoreInlineInstaller::WebstoreInlineInstaller(
content::WebContents* web_contents,
+ content::RenderFrameHost* host,
const std::string& webstore_item_id,
const GURL& requestor_url,
const Callback& callback)
@@ -37,8 +38,8 @@ WebstoreInlineInstaller::WebstoreInlineInstaller(
Profile::FromBrowserContext(web_contents->GetBrowserContext()),
callback),
content::WebContentsObserver(web_contents),
- requestor_url_(requestor_url) {
-}
+ host_(host),
+ requestor_url_(requestor_url) {}
WebstoreInlineInstaller::~WebstoreInlineInstaller() {}
@@ -91,8 +92,8 @@ bool WebstoreInlineInstaller::IsRequestorPermitted(
}
bool WebstoreInlineInstaller::CheckRequestorAlive() const {
- // The tab may have gone away - cancel installation in that case.
- return web_contents() != NULL;
+ // The frame or tab may have gone away - cancel installation in that case.
+ return host_ != nullptr && web_contents() != nullptr;
}
const GURL& WebstoreInlineInstaller::GetRequestorURL() const {
@@ -176,6 +177,18 @@ bool WebstoreInlineInstaller::CheckRequestorPermitted(
// Private implementation.
//
+void WebstoreInlineInstaller::FrameDeleted(
Devlin 2015/11/05 17:40:40 There's been a ton of confusion over which [Render
asargent_no_longer_on_chrome 2015/11/18 21:42:44 Yep, that works.
+ content::RenderFrameHost* render_frame_host) {
+ if (render_frame_host == host_)
+ host_ = nullptr;
+}
+
+void WebstoreInlineInstaller::RenderFrameHostChanged(
+ content::RenderFrameHost* old_host,
+ content::RenderFrameHost* new_host) {
+ FrameDeleted(old_host);
+}
+
void WebstoreInlineInstaller::WebContentsDestroyed() {
AbortInstall();
}

Powered by Google App Engine