OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/platform_notification_service_impl.h" | 5 #include "chrome/browser/notifications/platform_notification_service_impl.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
9 #include "base/metrics/user_metrics_action.h" | 9 #include "base/metrics/user_metrics_action.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 new NotificationObjectProxy(browser_context, delegate.Pass()); | 255 new NotificationObjectProxy(browser_context, delegate.Pass()); |
256 Notification notification = CreateNotificationFromData( | 256 Notification notification = CreateNotificationFromData( |
257 profile, origin, icon, notification_data, proxy); | 257 profile, origin, icon, notification_data, proxy); |
258 | 258 |
259 GetNotificationUIManager()->Add(notification, profile); | 259 GetNotificationUIManager()->Add(notification, profile); |
260 if (cancel_callback) | 260 if (cancel_callback) |
261 *cancel_callback = | 261 *cancel_callback = |
262 base::Bind(&CancelNotification, | 262 base::Bind(&CancelNotification, |
263 notification.delegate_id(), | 263 notification.delegate_id(), |
264 NotificationUIManager::GetProfileID(profile)); | 264 NotificationUIManager::GetProfileID(profile)); |
265 | |
266 HostContentSettingsMapFactory::GetForProfile(profile)->UpdateLastUsage( | |
267 origin, origin, CONTENT_SETTINGS_TYPE_NOTIFICATIONS); | |
268 } | 265 } |
269 | 266 |
270 void PlatformNotificationServiceImpl::DisplayPersistentNotification( | 267 void PlatformNotificationServiceImpl::DisplayPersistentNotification( |
271 BrowserContext* browser_context, | 268 BrowserContext* browser_context, |
272 int64_t persistent_notification_id, | 269 int64_t persistent_notification_id, |
273 const GURL& origin, | 270 const GURL& origin, |
274 const SkBitmap& icon, | 271 const SkBitmap& icon, |
275 const content::PlatformNotificationData& notification_data) { | 272 const content::PlatformNotificationData& notification_data) { |
276 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 273 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
277 | 274 |
(...skipping 10 matching lines...) Expand all Loading... |
288 Notification notification = CreateNotificationFromData( | 285 Notification notification = CreateNotificationFromData( |
289 profile, origin, icon, notification_data, delegate); | 286 profile, origin, icon, notification_data, delegate); |
290 | 287 |
291 // TODO(peter): Remove this mapping when we have reliable id generation for | 288 // TODO(peter): Remove this mapping when we have reliable id generation for |
292 // the message_center::Notification objects. | 289 // the message_center::Notification objects. |
293 persistent_notifications_[persistent_notification_id] = notification.id(); | 290 persistent_notifications_[persistent_notification_id] = notification.id(); |
294 | 291 |
295 GetNotificationUIManager()->Add(notification, profile); | 292 GetNotificationUIManager()->Add(notification, profile); |
296 content::RecordAction( | 293 content::RecordAction( |
297 base::UserMetricsAction("Notifications.Persistent.Shown")); | 294 base::UserMetricsAction("Notifications.Persistent.Shown")); |
298 | |
299 HostContentSettingsMapFactory::GetForProfile(profile)->UpdateLastUsage( | |
300 origin, origin, CONTENT_SETTINGS_TYPE_NOTIFICATIONS); | |
301 } | 295 } |
302 | 296 |
303 void PlatformNotificationServiceImpl::ClosePersistentNotification( | 297 void PlatformNotificationServiceImpl::ClosePersistentNotification( |
304 BrowserContext* browser_context, | 298 BrowserContext* browser_context, |
305 int64_t persistent_notification_id) { | 299 int64_t persistent_notification_id) { |
306 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 300 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
307 | 301 |
308 Profile* profile = Profile::FromBrowserContext(browser_context); | 302 Profile* profile = Profile::FromBrowserContext(browser_context); |
309 DCHECK(profile); | 303 DCHECK(profile); |
310 | 304 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 extensions::ExtensionRegistry::Get(profile)->GetExtensionById( | 428 extensions::ExtensionRegistry::Get(profile)->GetExtensionById( |
435 origin.host(), extensions::ExtensionRegistry::EVERYTHING); | 429 origin.host(), extensions::ExtensionRegistry::EVERYTHING); |
436 DCHECK(extension); | 430 DCHECK(extension); |
437 | 431 |
438 return base::UTF8ToUTF16(extension->name()); | 432 return base::UTF8ToUTF16(extension->name()); |
439 } | 433 } |
440 #endif | 434 #endif |
441 | 435 |
442 return base::string16(); | 436 return base::string16(); |
443 } | 437 } |
OLD | NEW |