Chromium Code Reviews| 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/prefs/scoped_user_pref_update.h" | 9 #include "base/prefs/scoped_user_pref_update.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 306 return; | 306 return; |
| 307 | 307 |
| 308 // The settings for ephemeral apps will be persisted across cache evictions. | 308 // The settings for ephemeral apps will be persisted across cache evictions. |
| 309 if (extensions::util::IsEphemeralApp(extension->id(), profile_)) | 309 if (extensions::util::IsEphemeralApp(extension->id(), profile_)) |
| 310 return; | 310 return; |
| 311 | 311 |
| 312 SetNotifierEnabled(notifier_id, true); | 312 SetNotifierEnabled(notifier_id, true); |
| 313 #endif | 313 #endif |
| 314 } | 314 } |
| 315 | 315 |
| 316 // Unlike other permission types, granting a notification for a given origin | |
| 317 // will grant it even if it is embedded as an iframe in other domains. | |
|
Peter Beverloo
2014/09/23 15:58:47
This is phrased a bit ambiguously, what about the
Bernhard Bauer
2014/09/23 16:13:02
I would point out in the comment that the embeddin
Miguel Garcia
2014/09/23 16:53:38
Acknowledged.
Miguel Garcia
2014/09/23 16:53:39
Done.
| |
| 318 void DesktopNotificationService::UpdateContentSetting( | |
| 319 const GURL& requesting_origin, | |
| 320 const GURL& embedder_origin, | |
| 321 bool allowed) { | |
| 322 if (allowed) | |
|
Bernhard Bauer
2014/09/23 16:13:02
Braces can only be omitted for single-line bodies.
Miguel Garcia
2014/09/23 16:53:39
Done.
| |
| 323 DesktopNotificationProfileUtil::GrantPermission( | |
| 324 profile_, requesting_origin); | |
| 325 else | |
| 326 DesktopNotificationProfileUtil::DenyPermission(profile_, requesting_origin); | |
| 327 } | |
| 328 | |
|
Peter Beverloo
2014/09/23 15:58:47
nit: only a single blank line.
Miguel Garcia
2014/09/23 16:53:39
Done.
| |
| 329 | |
| 330 | |
| 316 void DesktopNotificationService::OnNotificationPermissionRequested( | 331 void DesktopNotificationService::OnNotificationPermissionRequested( |
| 317 const NotificationPermissionCallback& callback, bool allowed) { | 332 const NotificationPermissionCallback& callback, bool allowed) { |
| 318 blink::WebNotificationPermission permission = allowed ? | 333 blink::WebNotificationPermission permission = allowed ? |
| 319 blink::WebNotificationPermissionAllowed : | 334 blink::WebNotificationPermissionAllowed : |
| 320 blink::WebNotificationPermissionDenied; | 335 blink::WebNotificationPermissionDenied; |
| 321 | 336 |
| 322 callback.Run(permission); | 337 callback.Run(permission); |
| 323 } | 338 } |
| 324 | 339 |
| 325 void DesktopNotificationService::FirePermissionLevelChangedEvent( | 340 void DesktopNotificationService::FirePermissionLevelChangedEvent( |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 341 // Tell the IO thread that this extension's permission for notifications | 356 // Tell the IO thread that this extension's permission for notifications |
| 342 // has changed. | 357 // has changed. |
| 343 extensions::InfoMap* extension_info_map = | 358 extensions::InfoMap* extension_info_map = |
| 344 extensions::ExtensionSystem::Get(profile_)->info_map(); | 359 extensions::ExtensionSystem::Get(profile_)->info_map(); |
| 345 BrowserThread::PostTask( | 360 BrowserThread::PostTask( |
| 346 BrowserThread::IO, FROM_HERE, | 361 BrowserThread::IO, FROM_HERE, |
| 347 base::Bind(&extensions::InfoMap::SetNotificationsDisabled, | 362 base::Bind(&extensions::InfoMap::SetNotificationsDisabled, |
| 348 extension_info_map, notifier_id.id, !enabled)); | 363 extension_info_map, notifier_id.id, !enabled)); |
| 349 #endif | 364 #endif |
| 350 } | 365 } |
| OLD | NEW |