OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/notifications/desktop_notification_service.h" | 5 #include "chrome/browser/notifications/desktop_notification_service.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
10 #include "base/prefs/scoped_user_pref_update.h" | 10 #include "base/prefs/scoped_user_pref_update.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 for (extensions::ExtensionSet::const_iterator iter = extensions.begin(); | 109 for (extensions::ExtensionSet::const_iterator iter = extensions.begin(); |
110 iter != extensions.end(); ++iter) { | 110 iter != extensions.end(); ++iter) { |
111 if (IsNotifierEnabled(NotifierId( | 111 if (IsNotifierEnabled(NotifierId( |
112 NotifierId::APPLICATION, (*iter)->id()))) { | 112 NotifierId::APPLICATION, (*iter)->id()))) { |
113 extension = iter->get(); | 113 extension = iter->get(); |
114 break; | 114 break; |
115 } | 115 } |
116 } | 116 } |
117 } | 117 } |
118 if (IsExtensionWithPermissionOrSuggestInConsole( | 118 if (IsExtensionWithPermissionOrSuggestInConsole( |
119 extensions::APIPermission::kNotifications, | 119 extensions::APIPermission::kNotifications, extension, web_contents)) { |
120 extension, | |
121 web_contents->GetRenderViewHost())) { | |
122 result_callback.Run(CONTENT_SETTING_ALLOW); | 120 result_callback.Run(CONTENT_SETTING_ALLOW); |
123 return; | 121 return; |
124 } | 122 } |
125 #endif | 123 #endif |
126 | 124 |
127 // Track whether the requesting and embedding origins are different when | 125 // Track whether the requesting and embedding origins are different when |
128 // permission to display Web Notifications is being requested. | 126 // permission to display Web Notifications is being requested. |
129 UMA_HISTOGRAM_BOOLEAN("Notifications.DifferentRequestingEmbeddingOrigins", | 127 UMA_HISTOGRAM_BOOLEAN("Notifications.DifferentRequestingEmbeddingOrigins", |
130 requesting_origin.GetOrigin() != | 128 requesting_origin.GetOrigin() != |
131 web_contents->GetLastCommittedURL().GetOrigin()); | 129 web_contents->GetLastCommittedURL().GetOrigin()); |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 // Tell the IO thread that this extension's permission for notifications | 274 // Tell the IO thread that this extension's permission for notifications |
277 // has changed. | 275 // has changed. |
278 extensions::InfoMap* extension_info_map = | 276 extensions::InfoMap* extension_info_map = |
279 extensions::ExtensionSystem::Get(profile_)->info_map(); | 277 extensions::ExtensionSystem::Get(profile_)->info_map(); |
280 BrowserThread::PostTask( | 278 BrowserThread::PostTask( |
281 BrowserThread::IO, FROM_HERE, | 279 BrowserThread::IO, FROM_HERE, |
282 base::Bind(&extensions::InfoMap::SetNotificationsDisabled, | 280 base::Bind(&extensions::InfoMap::SetNotificationsDisabled, |
283 extension_info_map, notifier_id.id, !enabled)); | 281 extension_info_map, notifier_id.id, !enabled)); |
284 #endif | 282 #endif |
285 } | 283 } |
OLD | NEW |