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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
246 content_setting == CONTENT_SETTING_BLOCK); | 246 content_setting == CONTENT_SETTING_BLOCK); |
247 | 247 |
248 if (content_setting == CONTENT_SETTING_ALLOW) { | 248 if (content_setting == CONTENT_SETTING_ALLOW) { |
249 DesktopNotificationProfileUtil::GrantPermission( | 249 DesktopNotificationProfileUtil::GrantPermission( |
250 profile_, requesting_origin); | 250 profile_, requesting_origin); |
251 } else { | 251 } else { |
252 DesktopNotificationProfileUtil::DenyPermission(profile_, requesting_origin); | 252 DesktopNotificationProfileUtil::DenyPermission(profile_, requesting_origin); |
253 } | 253 } |
254 } | 254 } |
255 | 255 |
256 bool DesktopNotificationService::RestrictToSecureOrigins() const { | |
257 return false; | |
ddorwin
2015/05/26 17:31:31
Are notifications really not restricted? Looking a
mlamouri (slow - plz ping)
2015/05/29 14:35:15
They are not HTTPS-only.
| |
258 } | |
259 | |
256 void DesktopNotificationService::FirePermissionLevelChangedEvent( | 260 void DesktopNotificationService::FirePermissionLevelChangedEvent( |
257 const NotifierId& notifier_id, bool enabled) { | 261 const NotifierId& notifier_id, bool enabled) { |
258 #if defined(ENABLE_EXTENSIONS) | 262 #if defined(ENABLE_EXTENSIONS) |
259 DCHECK_EQ(NotifierId::APPLICATION, notifier_id.type); | 263 DCHECK_EQ(NotifierId::APPLICATION, notifier_id.type); |
260 extensions::api::notifications::PermissionLevel permission = | 264 extensions::api::notifications::PermissionLevel permission = |
261 enabled ? extensions::api::notifications::PERMISSION_LEVEL_GRANTED | 265 enabled ? extensions::api::notifications::PERMISSION_LEVEL_GRANTED |
262 : extensions::api::notifications::PERMISSION_LEVEL_DENIED; | 266 : extensions::api::notifications::PERMISSION_LEVEL_DENIED; |
263 scoped_ptr<base::ListValue> args(new base::ListValue()); | 267 scoped_ptr<base::ListValue> args(new base::ListValue()); |
264 args->Append(new base::StringValue( | 268 args->Append(new base::StringValue( |
265 extensions::api::notifications::ToString(permission))); | 269 extensions::api::notifications::ToString(permission))); |
266 scoped_ptr<extensions::Event> event(new extensions::Event( | 270 scoped_ptr<extensions::Event> event(new extensions::Event( |
267 extensions::api::notifications::OnPermissionLevelChanged::kEventName, | 271 extensions::api::notifications::OnPermissionLevelChanged::kEventName, |
268 args.Pass())); | 272 args.Pass())); |
269 extensions::EventRouter::Get(profile_) | 273 extensions::EventRouter::Get(profile_) |
270 ->DispatchEventToExtension(notifier_id.id, event.Pass()); | 274 ->DispatchEventToExtension(notifier_id.id, event.Pass()); |
271 | 275 |
272 // Tell the IO thread that this extension's permission for notifications | 276 // Tell the IO thread that this extension's permission for notifications |
273 // has changed. | 277 // has changed. |
274 extensions::InfoMap* extension_info_map = | 278 extensions::InfoMap* extension_info_map = |
275 extensions::ExtensionSystem::Get(profile_)->info_map(); | 279 extensions::ExtensionSystem::Get(profile_)->info_map(); |
276 BrowserThread::PostTask( | 280 BrowserThread::PostTask( |
277 BrowserThread::IO, FROM_HERE, | 281 BrowserThread::IO, FROM_HERE, |
278 base::Bind(&extensions::InfoMap::SetNotificationsDisabled, | 282 base::Bind(&extensions::InfoMap::SetNotificationsDisabled, |
279 extension_info_map, notifier_id.id, !enabled)); | 283 extension_info_map, notifier_id.id, !enabled)); |
280 #endif | 284 #endif |
281 } | 285 } |
OLD | NEW |