Chromium Code Reviews| 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/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/notifications/desktop_notification_profile_util.h" | 10 #include "chrome/browser/notifications/desktop_notification_profile_util.h" |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 299 if (iter == persistent_notifications_.end()) | 299 if (iter == persistent_notifications_.end()) |
| 300 return; | 300 return; |
| 301 | 301 |
| 302 GetNotificationUIManager()->CancelById( | 302 GetNotificationUIManager()->CancelById( |
| 303 iter->second, NotificationUIManager::GetProfileID(profile)); | 303 iter->second, NotificationUIManager::GetProfileID(profile)); |
| 304 | 304 |
| 305 persistent_notifications_.erase(iter); | 305 persistent_notifications_.erase(iter); |
| 306 #endif | 306 #endif |
| 307 } | 307 } |
| 308 | 308 |
| 309 bool PlatformNotificationServiceImpl::GetDisplayedPersistentNotifications( | |
| 310 BrowserContext* browser_context, | |
| 311 std::set<std::string>* displayed_notifications) { | |
| 312 DCHECK(displayed_notifications); | |
| 313 | |
| 314 #if !defined(OS_ANDROID) | |
| 315 Profile* profile = Profile::FromBrowserContext(browser_context); | |
| 316 | |
| 317 // TODO(peter): Filter for persistent notifications only. | |
|
johnme
2015/05/14 15:22:32
How hard would it be to implement this TODO now? I
Peter Beverloo
2015/05/14 16:03:34
No, that's not the case, the delegate ids for pers
| |
| 318 *displayed_notifications = | |
| 319 GetNotificationUIManager()->GetAllIdsByProfile(profile); | |
| 320 | |
| 321 return true; | |
| 322 #else | |
| 323 // Android cannot reliably return the notifications that are currently being | |
| 324 // displayed on the platform, see the comment in NotificationUIManagerAndroid. | |
| 325 return false; | |
| 326 #endif | |
|
johnme
2015/05/14 15:22:32
Micro-nit: #endif // !defined(OS_ANDROID)
Peter Beverloo
2015/05/14 16:03:34
Done.
| |
| 327 } | |
| 328 | |
| 309 Notification PlatformNotificationServiceImpl::CreateNotificationFromData( | 329 Notification PlatformNotificationServiceImpl::CreateNotificationFromData( |
| 310 Profile* profile, | 330 Profile* profile, |
| 311 const GURL& origin, | 331 const GURL& origin, |
| 312 const SkBitmap& icon, | 332 const SkBitmap& icon, |
| 313 const content::PlatformNotificationData& notification_data, | 333 const content::PlatformNotificationData& notification_data, |
| 314 NotificationDelegate* delegate) const { | 334 NotificationDelegate* delegate) const { |
| 315 base::string16 display_source = DisplayNameForOrigin(profile, origin); | 335 base::string16 display_source = DisplayNameForOrigin(profile, origin); |
| 316 | 336 |
| 317 // TODO(peter): Icons for Web Notifications are currently always requested for | 337 // TODO(peter): Icons for Web Notifications are currently always requested for |
| 318 // 1x scale, whereas the displays on which they can be displayed can have a | 338 // 1x scale, whereas the displays on which they can be displayed can have a |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 385 formatted_origin.push_back(':'); | 405 formatted_origin.push_back(':'); |
| 386 formatted_origin.append(base::UTF8ToUTF16(origin.port())); | 406 formatted_origin.append(base::UTF8ToUTF16(origin.port())); |
| 387 } | 407 } |
| 388 return formatted_origin; | 408 return formatted_origin; |
| 389 } | 409 } |
| 390 | 410 |
| 391 // TODO(dewittj): Once file:// URLs are passed in to the origin | 411 // TODO(dewittj): Once file:// URLs are passed in to the origin |
| 392 // GURL here, begin returning the path as the display name. | 412 // GURL here, begin returning the path as the display name. |
| 393 return net::FormatUrl(origin, languages); | 413 return net::FormatUrl(origin, languages); |
| 394 } | 414 } |
| OLD | NEW |