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

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

Issue 908063002: Prevent inline CRX installs in popup windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Open the popup from the test file rather than using browser navigation Created 5 years, 10 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
« no previous file with comments | « no previous file | chrome/browser/extensions/webstore_inline_installer_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 d22d3d28f195f30a72e70bd0c8221de9a2805557..045d996465d3616d7cded6e997339c801ebfa203 100644
--- a/chrome/browser/extensions/webstore_inline_installer.cc
+++ b/chrome/browser/extensions/webstore_inline_installer.cc
@@ -6,22 +6,26 @@
#include "base/strings/stringprintf.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/browser_finder.h"
#include "content/public/browser/web_contents.h"
using content::WebContents;
namespace extensions {
-const char kInvalidWebstoreResponseError[] = "Invalid Chrome Web Store reponse";
+const char kInvalidWebstoreResponseError[] =
+ "Invalid Chrome Web Store response.";
const char kNoVerifiedSitesError[] =
"Inline installs can only be initiated for Chrome Web Store items that "
- "have one or more verified sites";
+ "have one or more verified sites.";
const char kNotFromVerifiedSitesError[] =
"Installs can only be initiated by one of the Chrome Web Store item's "
- "verified sites";
+ "verified sites.";
const char kInlineInstallSupportedError[] =
"Inline installation is not supported for this item. The user will be "
"redirected to the Chrome Web Store.";
+const char kInitiatedFromPopupError[] =
+ "Inline installs can not be initiated from pop-up windows.";
WebstoreInlineInstaller::WebstoreInlineInstaller(
content::WebContents* web_contents,
@@ -126,6 +130,12 @@ WebContents* WebstoreInlineInstaller::GetWebContents() const {
bool WebstoreInlineInstaller::CheckInlineInstallPermitted(
const base::DictionaryValue& webstore_data,
std::string* error) const {
+ Browser* browser = chrome::FindBrowserWithWebContents(web_contents());
+ DCHECK(browser);
+ if (browser->is_type_popup()) {
+ *error = kInitiatedFromPopupError;
+ return false;
+ }
// The store may not support inline installs for this item, in which case
// we open the store-provided redirect URL in a new tab and abort the
// installation process.
@@ -152,7 +162,6 @@ bool WebstoreInlineInstaller::CheckInlineInstallPermitted(
*error = kInlineInstallSupportedError;
return false;
}
-
*error = "";
return true;
}
« no previous file with comments | « no previous file | chrome/browser/extensions/webstore_inline_installer_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698