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

Add extension apps uninstall UMA in AppService.

BUG=1009248

Change-Id: Icb801fae7334a9563e2209edb000d542f866653f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1842975
Commit-Queue: Nancy Wang <nancylingwang@chromium.org>
Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Cr-Commit-Position: refs/heads/master@{#708090}
parent 53fc653e
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "ash/public/cpp/shelf_types.h" #include "ash/public/cpp/shelf_types.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/callback.h" #include "base/callback.h"
#include "base/metrics/histogram_macros.h"
#include "base/optional.h" #include "base/optional.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "chrome/browser/apps/app_service/app_icon_factory.h" #include "chrome/browser/apps/app_service/app_icon_factory.h"
...@@ -171,6 +172,28 @@ class ExtensionAppsEnableFlow : public ExtensionEnableFlowDelegate { ...@@ -171,6 +172,28 @@ class ExtensionAppsEnableFlow : public ExtensionEnableFlowDelegate {
DISALLOW_COPY_AND_ASSIGN(ExtensionAppsEnableFlow); DISALLOW_COPY_AND_ASSIGN(ExtensionAppsEnableFlow);
}; };
void ExtensionApps::RecordUninstallCanceledAction(Profile* profile,
const std::string& app_id) {
const extensions::Extension* extension =
extensions::ExtensionRegistry::Get(profile)->GetInstalledExtension(
app_id);
if (!extension) {
return;
}
if (extension->from_bookmark()) {
UMA_HISTOGRAM_ENUMERATION(
"Webapp.UninstallDialogAction",
extensions::ExtensionUninstallDialog::CLOSE_ACTION_CANCELED,
extensions::ExtensionUninstallDialog::CLOSE_ACTION_LAST);
} else {
UMA_HISTOGRAM_ENUMERATION(
"Extensions.UninstallDialogAction",
extensions::ExtensionUninstallDialog::CLOSE_ACTION_CANCELED,
extensions::ExtensionUninstallDialog::CLOSE_ACTION_LAST);
}
}
ExtensionApps::ExtensionApps( ExtensionApps::ExtensionApps(
const mojo::Remote<apps::mojom::AppService>& app_service, const mojo::Remote<apps::mojom::AppService>& app_service,
Profile* profile, Profile* profile,
...@@ -436,15 +459,24 @@ void ExtensionApps::Uninstall(const std::string& app_id, ...@@ -436,15 +459,24 @@ void ExtensionApps::Uninstall(const std::string& app_id,
base::string16 error; base::string16 error;
extensions::ExtensionSystem::Get(profile_) extensions::ExtensionSystem::Get(profile_)
->extension_service() ->extension_service()
->UninstallExtension( ->UninstallExtension(app_id, extensions::UNINSTALL_REASON_USER_INITIATED,
app_id, extensions::UninstallReason::UNINSTALL_REASON_USER_INITIATED, &error);
&error);
if (!clear_site_data) {
return;
}
if (extension->from_bookmark()) { if (extension->from_bookmark()) {
if (!clear_site_data) {
UMA_HISTOGRAM_ENUMERATION(
"Webapp.UninstallDialogAction",
extensions::ExtensionUninstallDialog::CLOSE_ACTION_UNINSTALL,
extensions::ExtensionUninstallDialog::CLOSE_ACTION_LAST);
return;
}
UMA_HISTOGRAM_ENUMERATION(
"Webapp.UninstallDialogAction",
extensions::ExtensionUninstallDialog::
CLOSE_ACTION_UNINSTALL_AND_CHECKBOX_CHECKED,
extensions::ExtensionUninstallDialog::CLOSE_ACTION_LAST);
constexpr bool kClearCookies = true; constexpr bool kClearCookies = true;
constexpr bool kClearStorage = true; constexpr bool kClearStorage = true;
constexpr bool kClearCache = true; constexpr bool kClearCache = true;
...@@ -460,6 +492,20 @@ void ExtensionApps::Uninstall(const std::string& app_id, ...@@ -460,6 +492,20 @@ void ExtensionApps::Uninstall(const std::string& app_id,
kClearCookies, kClearStorage, kClearCache, kAvoidClosingConnections, kClearCookies, kClearStorage, kClearCache, kAvoidClosingConnections,
base::DoNothing()); base::DoNothing());
} else { } else {
if (!report_abuse) {
UMA_HISTOGRAM_ENUMERATION(
"Extensions.UninstallDialogAction",
extensions::ExtensionUninstallDialog::CLOSE_ACTION_UNINSTALL,
extensions::ExtensionUninstallDialog::CLOSE_ACTION_LAST);
return;
}
UMA_HISTOGRAM_ENUMERATION(
"Extensions.UninstallDialogAction",
extensions::ExtensionUninstallDialog::
CLOSE_ACTION_UNINSTALL_AND_CHECKBOX_CHECKED,
extensions::ExtensionUninstallDialog::CLOSE_ACTION_LAST);
// If the extension specifies a custom uninstall page via // If the extension specifies a custom uninstall page via
// chrome.runtime.setUninstallURL, then at uninstallation its uninstall // chrome.runtime.setUninstallURL, then at uninstallation its uninstall
// page opens. To ensure that the CWS Report Abuse page is the active // page opens. To ensure that the CWS Report Abuse page is the active
......
...@@ -47,6 +47,10 @@ class ExtensionApps : public apps::mojom::Publisher, ...@@ -47,6 +47,10 @@ class ExtensionApps : public apps::mojom::Publisher,
public content_settings::Observer, public content_settings::Observer,
public ArcAppListPrefs::Observer { public ArcAppListPrefs::Observer {
public: public:
// Record uninstall dialog action for Web apps and Chrome apps.
static void RecordUninstallCanceledAction(Profile* profile,
const std::string& app_id);
ExtensionApps(const mojo::Remote<apps::mojom::AppService>& app_service, ExtensionApps(const mojo::Remote<apps::mojom::AppService>& app_service,
Profile* profile, Profile* profile,
apps::mojom::AppType app_type); apps::mojom::AppType app_type);
......
...@@ -4,8 +4,14 @@ ...@@ -4,8 +4,14 @@
#include "chrome/browser/apps/app_service/uninstall_dialog.h" #include "chrome/browser/apps/app_service/uninstall_dialog.h"
#include "base/metrics/histogram_macros.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/services/app_service/public/cpp/icon_loader.h" #include "chrome/services/app_service/public/cpp/icon_loader.h"
#include "extensions/browser/uninstall_reason.h"
#if defined(OS_CHROMEOS)
#include "chrome/browser/apps/app_service/extension_apps.h"
#endif // OS_CHROMEOS
namespace { namespace {
...@@ -43,6 +49,9 @@ UninstallDialog::UninstallDialog(Profile* profile, ...@@ -43,6 +49,9 @@ UninstallDialog::UninstallDialog(Profile* profile,
break; break;
case apps::mojom::AppType::kExtension: case apps::mojom::AppType::kExtension:
case apps::mojom::AppType::kWeb: case apps::mojom::AppType::kWeb:
UMA_HISTOGRAM_ENUMERATION("Extensions.UninstallSource",
extensions::UNINSTALL_SOURCE_APP_LIST,
extensions::NUM_UNINSTALL_SOURCES);
size_hint_in_dip = kUninstallIconSize; size_hint_in_dip = kUninstallIconSize;
break; break;
default: default:
...@@ -63,6 +72,13 @@ UninstallDialog::~UninstallDialog() = default; ...@@ -63,6 +72,13 @@ UninstallDialog::~UninstallDialog() = default;
void UninstallDialog::OnDialogClosed(bool uninstall, void UninstallDialog::OnDialogClosed(bool uninstall,
bool clear_site_data, bool clear_site_data,
bool report_abuse) { bool report_abuse) {
#if defined(OS_CHROMEOS)
if (!uninstall && (app_type_ == apps::mojom::AppType::kExtension ||
app_type_ == apps::mojom::AppType::kWeb)) {
ExtensionApps::RecordUninstallCanceledAction(profile_, app_id_);
}
#endif // OS_CHROMEOS
std::move(uninstall_callback_) std::move(uninstall_callback_)
.Run(uninstall, clear_site_data, report_abuse, this); .Run(uninstall, clear_site_data, report_abuse, this);
} }
......
...@@ -35,10 +35,6 @@ namespace apps { ...@@ -35,10 +35,6 @@ namespace apps {
// TODO(crbug.com/1009248): // TODO(crbug.com/1009248):
// 1. Add an interface to the uninstall, like what is done by // 1. Add an interface to the uninstall, like what is done by
// extension_uninstall_dialog_->ConfirmUninstallByExtension // extension_uninstall_dialog_->ConfirmUninstallByExtension
// 2. Add RecordDialogCreation to the appropriate place as what is done by
// extension_uninstall_dialog.
// 3. Add UMA to the appropriate place as what is done by
// extension_uninstall_dialog.
class UninstallDialog { class UninstallDialog {
public: public:
// The UiBase is the parent virtual class for the AppUninstallDialogView, // The UiBase is the parent virtual class for the AppUninstallDialogView,
......
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