Commit d71eb093 authored by nancy's avatar nancy Committed by Commit Bot

Add scoped_ptr for the extension in ExtensionApps::Uninstall.

When select 'Also clear data from Chrome...' for bookmark, the extension
is uninstalled first, then when clear data, it crashes when
GetFullLaunchURL from the extension, because the extension has been
uninstalled. So add scoped_ptr for the extension, which is the same
implementation from the ExtensionUninstallDialog:
https://cs.chromium.org/chromium/src/chrome/browser/extensions/extension_uninstall_dialog.h?l=160
https://cs.chromium.org/chromium/src/chrome/browser/extensions/extension_uninstall_dialog.cc?l=176

BUG=1047092

Change-Id: Idca8172a671f69efe2e9b9ce19fb2037d3f57fa7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2029475Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Commit-Queue: Nancy Wang <nancylingwang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#737088}
parent 9ecbcd72
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "base/callback.h" #include "base/callback.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "base/optional.h" #include "base/optional.h"
#include "base/scoped_observer.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "chrome/browser/apps/app_service/app_icon_factory.h" #include "chrome/browser/apps/app_service/app_icon_factory.h"
...@@ -510,10 +511,10 @@ void ExtensionApps::Uninstall(const std::string& app_id, ...@@ -510,10 +511,10 @@ void ExtensionApps::Uninstall(const std::string& app_id,
// TODO(crbug.com/1009248): We need to add the error code, which could be used // TODO(crbug.com/1009248): We need to add the error code, which could be used
// by ExtensionFunction, ManagementUninstallFunctionBase on the callback // by ExtensionFunction, ManagementUninstallFunctionBase on the callback
// OnExtensionUninstallDialogClosed // OnExtensionUninstallDialogClosed
const extensions::Extension* extension = scoped_refptr<const extensions::Extension> extension =
extensions::ExtensionRegistry::Get(profile_)->GetInstalledExtension( extensions::ExtensionRegistry::Get(profile_)->GetInstalledExtension(
app_id); app_id);
if (!extension) { if (!extension.get()) {
return; return;
} }
...@@ -549,7 +550,7 @@ void ExtensionApps::Uninstall(const std::string& app_id, ...@@ -549,7 +550,7 @@ void ExtensionApps::Uninstall(const std::string& app_id,
}, },
base::Unretained(profile_)), base::Unretained(profile_)),
url::Origin::Create( url::Origin::Create(
extensions::AppLaunchInfo::GetFullLaunchURL(extension)), extensions::AppLaunchInfo::GetFullLaunchURL(extension.get())),
kClearCookies, kClearStorage, kClearCache, kAvoidClosingConnections, kClearCookies, kClearStorage, kClearCache, kAvoidClosingConnections,
base::DoNothing()); base::DoNothing());
} else { } else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment