Chromium Code Reviews| 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. |
| } |