[Extensions] Un-refcount ExtensionInstallPrompt::Prompt
There's no reason ExtensionInstallPrompt::Prompt needs to be refcounted, other
than that we were sloppy with passing it around. Un-refcount it and properly
pass ownership.
BUG=567845
[email protected] (mechanical ui/views/extensions changes)
Review URL: https://codereview.chromium.org/1513553002
Cr-Commit-Position: refs/heads/master@{#365342}
diff --git a/chrome/browser/extensions/external_install_error.cc b/chrome/browser/extensions/external_install_error.cc
index 912edda3..8b42cb1 100644
--- a/chrome/browser/extensions/external_install_error.cc
+++ b/chrome/browser/extensions/external_install_error.cc
@@ -75,8 +75,8 @@
// A global error that spawns a bubble when the menu item is clicked.
class ExternalInstallBubbleAlert : public GlobalErrorWithStandardBubble {
public:
- explicit ExternalInstallBubbleAlert(ExternalInstallError* error,
- ExtensionInstallPrompt::Prompt* prompt);
+ ExternalInstallBubbleAlert(ExternalInstallError* error,
+ ExtensionInstallPrompt::Prompt* prompt);
~ExternalInstallBubbleAlert() override;
private:
@@ -101,6 +101,7 @@
ExternalInstallError* error_;
// The Prompt with all information, which we then use to populate the bubble.
+ // Owned by |error|.
ExtensionInstallPrompt::Prompt* prompt_;
DISALLOW_COPY_AND_ASSIGN(ExternalInstallBubbleAlert);
@@ -280,8 +281,8 @@
error_service_(GlobalErrorServiceFactory::GetForProfile(
Profile::FromBrowserContext(browser_context_))),
weak_factory_(this) {
- prompt_ = new ExtensionInstallPrompt::Prompt(
- ExtensionInstallPrompt::EXTERNAL_INSTALL_PROMPT);
+ prompt_.reset(new ExtensionInstallPrompt::Prompt(
+ ExtensionInstallPrompt::EXTERNAL_INSTALL_PROMPT));
webstore_data_fetcher_.reset(new WebstoreDataFetcher(
this, browser_context_->GetRequestContext(), GURL(), extension_id_));
@@ -332,7 +333,7 @@
install_ui_show_params_.reset(
new ExtensionInstallPromptShowParams(web_contents));
ExtensionInstallPrompt::GetDefaultShowDialogCallback().Run(
- install_ui_show_params_.get(), this, prompt_);
+ install_ui_show_params_.get(), this, prompt_.Pass());
}
const Extension* ExternalInstallError::GetExtension() const {
@@ -381,7 +382,7 @@
install_ui_->ShowDialog(this, GetExtension(),
nullptr, // Force a fetch of the icon.
- prompt_,
+ prompt_.Pass(),
base::Bind(&ExternalInstallError::OnDialogReady,
weak_factory_.GetWeakPtr()));
}
@@ -389,9 +390,9 @@
void ExternalInstallError::OnDialogReady(
ExtensionInstallPromptShowParams* show_params,
ExtensionInstallPrompt::Delegate* prompt_delegate,
- scoped_refptr<ExtensionInstallPrompt::Prompt> prompt) {
+ scoped_ptr<ExtensionInstallPrompt::Prompt> prompt) {
DCHECK_EQ(this, prompt_delegate);
- prompt_ = prompt;
+ prompt_ = prompt.Pass();
if (alert_type_ == BUBBLE_ALERT) {
global_error_.reset(new ExternalInstallBubbleAlert(this, prompt_.get()));