Chromium Code Reviews| Index: chrome/browser/extensions/extension_service.cc |
| diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc |
| index 5cd1701ae6e46d653b9cd655b455503bcbea199c..8f4788c59f0d3e11a9bb0f575b96c7342ba13989 100644 |
| --- a/chrome/browser/extensions/extension_service.cc |
| +++ b/chrome/browser/extensions/extension_service.cc |
| @@ -81,6 +81,7 @@ |
| #include "extensions/common/manifest_handlers/background_info.h" |
| #include "extensions/common/manifest_url_handlers.h" |
| #include "extensions/common/one_shot_event.h" |
| +#include "extensions/common/permissions/api_permission.h" |
| #include "extensions/common/permissions/permission_message_provider.h" |
| #include "extensions/common/permissions/permissions_data.h" |
| @@ -98,6 +99,7 @@ |
| using content::BrowserContext; |
| using content::BrowserThread; |
| using content::DevToolsAgentHost; |
| +using extensions::APIPermission; |
| using extensions::CrxInstaller; |
| using extensions::Extension; |
| using extensions::ExtensionIdSet; |
| @@ -108,6 +110,8 @@ using extensions::FeatureSwitch; |
| using extensions::InstallVerifier; |
| using extensions::ManagementPolicy; |
| using extensions::Manifest; |
| +using extensions::PermissionID; |
| +using extensions::PermissionIDSet; |
| using extensions::PermissionMessage; |
| using extensions::PermissionMessageIDs; |
| using extensions::PermissionSet; |
| @@ -740,8 +744,7 @@ bool ExtensionService::UninstallExtension( |
| UMA_HISTOGRAM_ENUMERATION("Extensions.UninstallType", |
| extension->GetType(), 100); |
| - RecordPermissionMessagesHistogram(extension.get(), |
| - "Extensions.Permissions_Uninstall2"); |
| + RecordPermissionMessagesHistogram(extension.get(), "Uninstall"); |
| // Unload before doing more cleanup to ensure that nothing is hanging on to |
| // any of these resources. |
| @@ -994,8 +997,7 @@ void ExtensionService::UnblockAllExtensions() { |
| void ExtensionService::GrantPermissionsAndEnableExtension( |
| const Extension* extension) { |
| GrantPermissions(extension); |
| - RecordPermissionMessagesHistogram(extension, |
| - "Extensions.Permissions_ReEnable2"); |
| + RecordPermissionMessagesHistogram(extension, "ReEnable"); |
| extension_prefs_->SetDidExtensionEscalatePermissions(extension, false); |
| EnableExtension(extension->id()); |
| } |
| @@ -1010,20 +1012,40 @@ void ExtensionService::RecordPermissionMessagesHistogram( |
| const Extension* extension, 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::HistogramBase* counter = base::LinearHistogram::FactoryGet( |
| - histogram, |
| + std::string histogram_name_base = |
|
Devlin
2015/04/27 17:58:03
Is there a reason to record both 2 and 3? (It doe
Marc Treib
2015/04/28 12:31:32
I just didn't want to break the existing ones unti
Devlin
2015/04/28 16:16:36
Yeah, I understand the motivation, but I'm not sur
Marc Treib
2015/04/29 11:24:02
What do you mean by "pollute"? The old histograms
Devlin
2015/04/29 15:42:24
Ah, misread part of this. Nevermind; should be fi
|
| + std::string("Extensions.Permissions_") + histogram; |
|
Devlin
2015/04/27 17:58:03
nit: + string concatenation is pretty slow - let's
Marc Treib
2015/04/28 12:31:32
Okay, done. Is "+"-style concatenation really that
Devlin
2015/04/28 16:16:36
Depends on whom you ask. ;) It's tremendously wor
|
| + base::HistogramBase* legacy_counter = base::LinearHistogram::FactoryGet( |
| + histogram_name_base + "2", |
| 1, |
| PermissionMessage::kEnumBoundary, |
| PermissionMessage::kEnumBoundary + 1, |
| base::HistogramBase::kUmaTargetedHistogramFlag); |
| - PermissionMessageIDs permissions = |
| + PermissionMessageIDs legacy_permissions = |
| extension->permissions_data()->GetLegacyPermissionMessageIDs(); |
| + if (legacy_permissions.empty()) { |
| + legacy_counter->Add(PermissionMessage::kNone); |
| + } else { |
| + for (PermissionMessage::ID id : legacy_permissions) |
| + legacy_counter->Add(id); |
| + } |
| + |
| + base::HistogramBase* counter = base::LinearHistogram::FactoryGet( |
| + histogram_name_base + "3", |
| + 1, |
| + APIPermission::kEnumBoundary, |
| + APIPermission::kEnumBoundary + 1, |
| + base::HistogramBase::kUmaTargetedHistogramFlag); |
| + |
| + PermissionIDSet permissions = |
| + extensions::PermissionMessageProvider::Get()->GetAllPermissionIDs( |
| + extension->permissions_data()->active_permissions().get(), |
| + extension->GetType()); |
| if (permissions.empty()) { |
| - counter->Add(PermissionMessage::kNone); |
| + counter->Add(APIPermission::kNone); |
| } else { |
| - for (PermissionMessage::ID id : permissions) |
| - counter->Add(id); |
| + for (const PermissionID& id : permissions) |
| + counter->Add(id.id()); |
| } |
| } |
| @@ -1665,8 +1687,7 @@ void ExtensionService::CheckPermissionsIncrease(const Extension* extension, |
| } else if (is_privilege_increase) { |
| disable_reasons |= Extension::DISABLE_PERMISSIONS_INCREASE; |
| if (!extension_prefs_->DidExtensionEscalatePermissions(extension->id())) { |
| - RecordPermissionMessagesHistogram(extension, |
| - "Extensions.Permissions_AutoDisable2"); |
| + RecordPermissionMessagesHistogram(extension, "AutoDisable"); |
| } |
| extension_prefs_->SetExtensionState(extension->id(), Extension::DISABLED); |
| extension_prefs_->SetDidExtensionEscalatePermissions(extension, true); |
| @@ -1789,8 +1810,7 @@ void ExtensionService::OnExtensionInstalled( |
| extension->GetType(), 100); |
| UMA_HISTOGRAM_ENUMERATION("Extensions.InstallSource", |
| extension->location(), Manifest::NUM_LOCATIONS); |
| - RecordPermissionMessagesHistogram(extension, |
| - "Extensions.Permissions_Install2"); |
| + RecordPermissionMessagesHistogram(extension, "Install"); |
| } else { |
| UMA_HISTOGRAM_ENUMERATION("Extensions.UpdateType", |
| extension->GetType(), 100); |