diff options
author | jstritar@chromium.org <jstritar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-19 22:52:49 +0000 |
---|---|---|
committer | jstritar@chromium.org <jstritar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-19 22:52:49 +0000 |
commit | fe2dd774543cb94fb60feb94df60444fd5b73c34 (patch) | |
tree | 8dc1c91f4744debb680e94160c7015a441a81aba /chrome/browser | |
parent | 47317494db5a0041f8a32ce4a654f8209166e96e (diff) | |
download | chromium_src-fe2dd774543cb94fb60feb94df60444fd5b73c34.zip chromium_src-fe2dd774543cb94fb60feb94df60444fd5b73c34.tar.gz chromium_src-fe2dd774543cb94fb60feb94df60444fd5b73c34.tar.bz2 |
Add histograms to track permission use in extensions.
Updates the disabled extension prompt to use the new re-enable prompt text.
BUG=42672, 37963
TEST=about:histograms/Extensions
Review URL: http://codereview.chromium.org/6626024
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@82177 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
7 files changed, 60 insertions, 3 deletions
diff --git a/chrome/browser/extensions/crx_installer.cc b/chrome/browser/extensions/crx_installer.cc index d234ed0..234546f 100644 --- a/chrome/browser/extensions/crx_installer.cc +++ b/chrome/browser/extensions/crx_installer.cc @@ -400,6 +400,11 @@ void CrxInstaller::InstallUIProceed() { } void CrxInstaller::InstallUIAbort() { + // Technically, this can be called for other reasons than the user hitting + // cancel, but they're rare. + ExtensionService::RecordPermissionMessagesHistogram( + extension_, "Extensions.Permissions_InstallCancel"); + // Kill the theme loading bubble. NotificationService* service = NotificationService::current(); service->Notify(NotificationType::NO_THEME_DETECTED, diff --git a/chrome/browser/extensions/extension_disabled_infobar_delegate.cc b/chrome/browser/extensions/extension_disabled_infobar_delegate.cc index dc46f00..e334fd2 100644 --- a/chrome/browser/extensions/extension_disabled_infobar_delegate.cc +++ b/chrome/browser/extensions/extension_disabled_infobar_delegate.cc @@ -54,7 +54,7 @@ ExtensionDisabledDialogDelegate::ExtensionDisabledDialogDelegate( AddRef(); // Balanced in Proceed or Abort. install_ui_.reset(new ExtensionInstallUI(profile)); - install_ui_->ConfirmInstall(this, extension_); + install_ui_->ConfirmReEnable(this, extension_); } ExtensionDisabledDialogDelegate::~ExtensionDisabledDialogDelegate() { @@ -66,6 +66,9 @@ void ExtensionDisabledDialogDelegate::InstallUIProceed() { } void ExtensionDisabledDialogDelegate::InstallUIAbort() { + ExtensionService::RecordPermissionMessagesHistogram( + extension_, "Extensions.Permissions_ReEnableCancel"); + // Do nothing. The extension will remain disabled. Release(); } diff --git a/chrome/browser/extensions/extension_install_ui.cc b/chrome/browser/extensions/extension_install_ui.cc index ba1f144..bfed0be 100644 --- a/chrome/browser/extensions/extension_install_ui.cc +++ b/chrome/browser/extensions/extension_install_ui.cc @@ -203,7 +203,8 @@ void ExtensionInstallUI::OnImageLoaded( Source<ExtensionInstallUI>(this), NotificationService::NoDetails()); - std::vector<string16> warnings = extension_->GetPermissionMessages(); + std::vector<string16> warnings = + extension_->GetPermissionMessageStrings(); ShowExtensionInstallDialog( profile_, delegate_, extension_, &icon_, warnings, prompt_type_); break; diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc index 37ed6a2..f6b9583 100644 --- a/chrome/browser/extensions/extension_service.cc +++ b/chrome/browser/extensions/extension_service.cc @@ -671,6 +671,8 @@ bool ExtensionService::UninstallExtension(const std::string& extension_id, UMA_HISTOGRAM_ENUMERATION("Extensions.UninstallType", extension->GetType(), 100); + RecordPermissionMessagesHistogram( + extension, "Extensions.Permissions_Uninstall"); // Also copy the extension identifier since the reference might have been // obtained via Extension::id(). @@ -800,6 +802,8 @@ void ExtensionService::GrantPermissions(const Extension* extension) { void ExtensionService::GrantPermissionsAndEnableExtension( const Extension* extension) { CHECK(extension); + RecordPermissionMessagesHistogram( + extension, "Extensions.Permissions_ReEnable"); GrantPermissions(extension); extension_prefs_->SetDidExtensionEscalatePermissions(extension, false); EnableExtension(extension->id()); @@ -985,6 +989,9 @@ void ExtensionService::LoadAllExtensions() { ++page_action_count; if ((*ex)->browser_action() != NULL) ++browser_action_count; + + RecordPermissionMessagesHistogram( + ex->get(), "Extensions.Permissions_Load"); } UMA_HISTOGRAM_COUNTS_100("Extensions.LoadApp", app_count); UMA_HISTOGRAM_COUNTS_100("Extensions.LoadHostedApp", hosted_app_count); @@ -998,6 +1005,29 @@ void ExtensionService::LoadAllExtensions() { browser_action_count); } +// static +void ExtensionService::RecordPermissionMessagesHistogram( + const Extension* e, const char* histogram) { + // Since this is called from multiple sources, and since the Histogram macros + // use statics, we need to manually lookup the Histogram ourselves. + base::Histogram* counter = base::LinearHistogram::FactoryGet( + histogram, + 1, + Extension::PermissionMessage::ID_ENUM_BOUNDARY, + Extension::PermissionMessage::ID_ENUM_BOUNDARY + 1, + base::Histogram::kUmaTargetedHistogramFlag); + + std::vector<Extension::PermissionMessage> permissions = + e->GetPermissionMessages(); + if (permissions.empty()) { + counter->Add(Extension::PermissionMessage::ID_NONE); + } else { + std::vector<Extension::PermissionMessage>::iterator it; + for (it = permissions.begin(); it != permissions.end(); ++it) + counter->Add(it->message_id()); + } +} + void ExtensionService::LoadInstalledExtension(const ExtensionInfo& info, bool write_to_prefs) { std::string error; @@ -1651,6 +1681,10 @@ void ExtensionService::DisableIfPrivilegeIncrease(const Extension* extension) { // Extension has changed permissions significantly. Disable it. A // notification should be sent by the caller. if (is_privilege_increase) { + if (!extension_prefs_->DidExtensionEscalatePermissions(extension->id())) { + RecordPermissionMessagesHistogram( + extension, "Extensions.Permissions_AutoDisable"); + } extension_prefs_->SetExtensionState(extension, Extension::DISABLED); extension_prefs_->SetDidExtensionEscalatePermissions(extension, true); } @@ -1722,6 +1756,8 @@ void ExtensionService::OnExtensionInstalled(const Extension* extension) { UMA_HISTOGRAM_ENUMERATION("Extensions.InstallType", extension->GetType(), 100); + RecordPermissionMessagesHistogram( + extension, "Extensions.Permissions_Install"); ShownSectionsHandler::OnExtensionInstalled(profile_->GetPrefs(), extension); extension_prefs_->OnExtensionInstalled( extension, initial_enable ? Extension::ENABLED : Extension::DISABLED, diff --git a/chrome/browser/extensions/extension_service.h b/chrome/browser/extensions/extension_service.h index 600d12a..2eb5e4f 100644 --- a/chrome/browser/extensions/extension_service.h +++ b/chrome/browser/extensions/extension_service.h @@ -452,6 +452,13 @@ class ExtensionService // Gets the set of loaded app ids. Component apps are not included. ExtensionIdSet GetAppIds() const; + // Record a histogram using the PermissionMessage enum values for each + // permission in |e|. + // NOTE: If this is ever called with high frequency, the implementation may + // need to be made more efficient. + static void RecordPermissionMessagesHistogram( + const Extension* e, const char* histogram); + private: friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>; friend class DeleteTask<ExtensionService>; diff --git a/chrome/browser/extensions/extension_webstore_private_api.cc b/chrome/browser/extensions/extension_webstore_private_api.cc index ff8b374..8f042a3 100644 --- a/chrome/browser/extensions/extension_webstore_private_api.cc +++ b/chrome/browser/extensions/extension_webstore_private_api.cc @@ -364,7 +364,7 @@ void BeginInstallWithManifestFunction::OnParseSuccess( this, dummy_extension_.get(), &icon_, - dummy_extension_->GetPermissionMessages(), + dummy_extension_->GetPermissionMessageStrings(), ExtensionInstallUI::INSTALL_PROMPT); // Control flow finishes up in InstallUIProceed or InstallUIAbort. diff --git a/chrome/browser/ui/webui/app_launcher_handler.cc b/chrome/browser/ui/webui/app_launcher_handler.cc index 67ee56c..95621d5 100644 --- a/chrome/browser/ui/webui/app_launcher_handler.cc +++ b/chrome/browser/ui/webui/app_launcher_handler.cc @@ -585,6 +585,11 @@ void AppLauncherHandler::ExtensionDialogAccepted() { } void AppLauncherHandler::ExtensionDialogCanceled() { + const Extension* extension = + extensions_service_->GetExtensionById(extension_id_prompting_, true); + ExtensionService::RecordPermissionMessagesHistogram( + extension, "Extensions.Permissions_ReEnableCancel"); + extension_id_prompting_ = ""; } |