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

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

Issue 7795032: Add link URL and success/failure callback parameters to chrome.webstore.install() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review feedback Created 9 years, 3 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/extensions/webstore_inline_installer.cc
diff --git a/chrome/browser/extensions/webstore_inline_installer.cc b/chrome/browser/extensions/webstore_inline_installer.cc
index ad08d85df8e2cd3fb8d93f4201eed88c6f230e8a..7db39fbf8483915a44183819402ca1962984e64a 100644
--- a/chrome/browser/extensions/webstore_inline_installer.cc
+++ b/chrome/browser/extensions/webstore_inline_installer.cc
@@ -15,9 +15,9 @@
#include "chrome/common/chrome_utility_messages.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_constants.h"
+#include "chrome/common/extensions/url_pattern.h"
#include "content/browser/tab_contents/tab_contents.h"
#include "content/browser/utility_process_host.h"
-#include "googleurl/src/gurl.h"
#include "net/base/escape.h"
#include "net/url_request/url_request_status.h"
@@ -28,12 +28,17 @@ const char kLocalizedDescriptionKey[] = "localized_description";
const char kUsersKey[] = "users";
const char kAverageRatingKey[] = "average_rating";
const char kRatingCountKey[] = "rating_count";
+const char kVerifiedSiteKey[] = "verified_site";
-const char kInvalidWebstoreItemId[] = "Invalid webstore item ID";
-const char kWebstoreRequestError[] = "Could not fetch data from webstore";
-const char kInvalidWebstoreResponseError[] = "Invalid webstore reponse";
+const char kInvalidWebstoreItemId[] = "Invalid Chrome Web Store item ID";
+const char kWebstoreRequestError[] =
+ "Could not fetch data from the Chrome Web Store";
+const char kInvalidWebstoreResponseError[] = "Invalid Chrome Web Store reponse";
const char kInvalidManifestError[] = "Invalid manifest";
const char kUserCancelledError[] = "User cancelled install";
+const char kNotFromVerifiedSite[] =
+ "Installs can only be initiated by the Chrome Web Store item's verified "
+ "site";
class SafeWebstoreResponseParser : public UtilityProcessHost::Client {
public:
@@ -127,10 +132,14 @@ class SafeWebstoreResponseParser : public UtilityProcessHost::Client {
};
WebstoreInlineInstaller::WebstoreInlineInstaller(TabContents* tab_contents,
+ int install_id,
std::string webstore_item_id,
+ GURL requestor_url,
Delegate* delegate)
: tab_contents_(tab_contents),
+ install_id_(install_id),
id_(webstore_item_id),
+ requestor_url_(requestor_url),
delegate_(delegate) {}
WebstoreInlineInstaller::~WebstoreInlineInstaller() {
@@ -225,6 +234,26 @@ void WebstoreInlineInstaller::OnWebstoreResponseParseSuccess(
}
}
+ // Verified site is optional
+ if (webstore_data->HasKey(kVerifiedSiteKey)) {
+ std::string verified_site_domain;
+ if (!webstore_data->GetString(kVerifiedSiteKey, &verified_site_domain)) {
+ CompleteInstall(kInvalidWebstoreResponseError);
+ return;
+ }
+
+ URLPattern verified_site_pattern(URLPattern::SCHEME_ALL);
+ verified_site_pattern.SetScheme("*");
+ verified_site_pattern.SetHost(verified_site_domain);
+ verified_site_pattern.SetMatchSubdomains(true);
+ verified_site_pattern.SetPath("/*");
+
+ if (!verified_site_pattern.MatchesURL(requestor_url_)) {
+ CompleteInstall(kNotFromVerifiedSite);
+ return;
+ }
+ }
+
scoped_refptr<WebstoreInstallHelper> helper = new WebstoreInstallHelper(
this,
manifest,
@@ -312,9 +341,9 @@ void WebstoreInlineInstaller::InstallUIAbort(bool user_initiated) {
void WebstoreInlineInstaller::CompleteInstall(const std::string& error) {
if (error.empty()) {
- delegate_->OnInlineInstallSuccess();
+ delegate_->OnInlineInstallSuccess(install_id_);
} else {
- delegate_->OnInlineInstallFailure(error);
+ delegate_->OnInlineInstallFailure(install_id_, error);
}
Release(); // Matches the AddRef in BeginInstall.
}
« no previous file with comments | « chrome/browser/extensions/webstore_inline_installer.h ('k') | chrome/common/extensions/extension_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698