Index: chrome/browser/permissions/permission_manager.cc |
diff --git a/chrome/browser/permissions/permission_manager.cc b/chrome/browser/permissions/permission_manager.cc |
index c1a719a45241bd34562014df15d8fad512357426..440f18d175a372a03676ecef8fca2a18819120c5 100644 |
--- a/chrome/browser/permissions/permission_manager.cc |
+++ b/chrome/browser/permissions/permission_manager.cc |
@@ -12,6 +12,8 @@ |
#include "chrome/browser/permissions/permission_context.h" |
#include "chrome/browser/permissions/permission_context_base.h" |
#include "chrome/browser/permissions/permission_request_id.h" |
+#include "chrome/browser/permissions/permission_uma_util.h" |
+#include "chrome/browser/permissions/permission_util.h" |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/browser/tab_contents/tab_util.h" |
#include "components/content_settings/core/browser/host_content_settings_map.h" |
@@ -198,12 +200,11 @@ struct PermissionManager::Subscription { |
PermissionManager::PermissionManager(Profile* profile) |
: profile_(profile), |
weak_ptr_factory_(this) { |
+ HostContentSettingsMapFactory::GetForProfile(profile_)->AddObserver(this); |
} |
PermissionManager::~PermissionManager() { |
- if (!subscriptions_.IsEmpty()) |
- HostContentSettingsMapFactory::GetForProfile(profile_) |
- ->RemoveObserver(this); |
+ HostContentSettingsMapFactory::GetForProfile(profile_)->RemoveObserver(this); |
} |
int PermissionManager::RequestPermission( |
@@ -351,8 +352,6 @@ int PermissionManager::SubscribePermissionStatusChange( |
const GURL& requesting_origin, |
const GURL& embedding_origin, |
const base::Callback<void(PermissionStatus)>& callback) { |
- if (subscriptions_.IsEmpty()) |
- HostContentSettingsMapFactory::GetForProfile(profile_)->AddObserver(this); |
Subscription* subscription = new Subscription(); |
subscription->permission = permission; |
@@ -375,10 +374,6 @@ int PermissionManager::SubscribePermissionStatusChange( |
void PermissionManager::UnsubscribePermissionStatusChange(int subscription_id) { |
// Whether |subscription_id| is known will be checked by the Remove() call. |
subscriptions_.Remove(subscription_id); |
- |
- if (subscriptions_.IsEmpty()) |
- HostContentSettingsMapFactory::GetForProfile(profile_) |
- ->RemoveObserver(this); |
} |
bool PermissionManager::IsPermissionBubbleManagerMissing( |
@@ -429,3 +424,13 @@ void PermissionManager::OnContentSettingChanged( |
for (const auto& callback : callbacks) |
callback.Run(); |
} |
+ |
+void PermissionManager::OnContentSettingRevoked( |
+ const GURL& primary_url, |
+ const GURL& secondary_url, |
+ ContentSettingsType content_type, |
+ std::string resource_identifier) { |
+ PermissionType permission_type; |
+ if (PermissionUtil::GetPermissionType(content_type, &permission_type)) |
+ PermissionUmaUtil::PermissionRevoked(permission_type, primary_url); |
+} |