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

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

Issue 10907104: Support an --install-from-webstore command line switch (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: updated comment Created 8 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 c833c7ab96e2dde827b9f97f02a47a53a2312419..84fb59aad1407697974ae6e12aff80db8b8f2713 100644
--- a/chrome/browser/extensions/webstore_inline_installer.cc
+++ b/chrome/browser/extensions/webstore_inline_installer.cc
@@ -148,19 +148,18 @@ class SafeWebstoreResponseParser : public UtilityProcessHostClient {
};
WebstoreInlineInstaller::WebstoreInlineInstaller(WebContents* web_contents,
- int install_id,
- int return_route_id,
std::string webstore_item_id,
+ bool require_verified_site,
GURL requestor_url,
- Delegate* delegate)
+ Callback callback)
: content::WebContentsObserver(web_contents),
- install_id_(install_id),
- return_route_id_(return_route_id),
id_(webstore_item_id),
+ require_verified_site_(require_verified_site),
requestor_url_(requestor_url),
- delegate_(delegate),
+ callback_(callback),
average_rating_(0.0),
rating_count_(0) {
+ CHECK(!callback.is_null());
}
void WebstoreInlineInstaller::BeginInstall() {
@@ -306,7 +305,7 @@ void WebstoreInlineInstaller::OnWebstoreResponseParseSuccess(
CompleteInstall(kNotFromVerifiedSiteError);
Mihai Parparita -not on Chrome 2012/09/07 22:01:36 Seems like you'd want to ignore this error if requ
asargent_no_longer_on_chrome 2012/09/14 23:24:35 Done.
return;
}
- } else {
+ } else if (require_verified_site_) {
CompleteInstall(kNoVerifiedSiteError);
return;
}
@@ -365,8 +364,7 @@ void WebstoreInlineInstaller::OnWebstoreParseSuccess(
return;
}
- install_ui_.reset(
- ExtensionInstallUI::CreateInstallPromptWithWebContents(web_contents()));
+ install_ui_.reset(new ExtensionInstallPrompt(NULL, web_contents(), profile));
install_ui_->ConfirmInlineInstall(this, dummy_extension_, &icon_, prompt);
// Control flow finishes up in InstallUIProceed or InstallUIAbort.
}
@@ -406,6 +404,7 @@ void WebstoreInlineInstaller::InstallUIAbort(bool user_initiated) {
}
void WebstoreInlineInstaller::WebContentsDestroyed(WebContents* web_contents) {
+ callback_.Reset();
// Abort any in-progress fetches.
if (webstore_data_url_fetcher_.get()) {
webstore_data_url_fetcher_.reset();
@@ -425,15 +424,8 @@ void WebstoreInlineInstaller::OnExtensionInstallFailure(
}
void WebstoreInlineInstaller::CompleteInstall(const std::string& error) {
- // Only bother responding if there's still a tab contents to send back the
- // response to.
- if (web_contents()) {
- if (error.empty()) {
- delegate_->OnInlineInstallSuccess(install_id_, return_route_id_);
- } else {
- delegate_->OnInlineInstallFailure(install_id_, return_route_id_, error);
- }
- }
+ if (!callback_.is_null())
+ callback_.Run(error.empty(), error);
Release(); // Matches the AddRef in BeginInstall.
}

Powered by Google App Engine
This is Rietveld 408576698