Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/native_notification_display_service.h" | 5 #include "chrome/browser/notifications/native_notification_display_service.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 53 | 53 |
| 54 notification_bridge->SetReadyCallback(base::BindOnce( | 54 notification_bridge->SetReadyCallback(base::BindOnce( |
| 55 &NativeNotificationDisplayService::OnNotificationPlatformBridgeReady, | 55 &NativeNotificationDisplayService::OnNotificationPlatformBridgeReady, |
| 56 weak_factory_.GetWeakPtr())); | 56 weak_factory_.GetWeakPtr())); |
| 57 | 57 |
| 58 AddNotificationHandler(NotificationCommon::NON_PERSISTENT, | 58 AddNotificationHandler(NotificationCommon::NON_PERSISTENT, |
| 59 base::MakeUnique<NonPersistentNotificationHandler>()); | 59 base::MakeUnique<NonPersistentNotificationHandler>()); |
| 60 AddNotificationHandler(NotificationCommon::PERSISTENT, | 60 AddNotificationHandler(NotificationCommon::PERSISTENT, |
| 61 base::MakeUnique<PersistentNotificationHandler>()); | 61 base::MakeUnique<PersistentNotificationHandler>()); |
| 62 #if BUILDFLAG(ENABLE_EXTENSIONS) | 62 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 63 AddNotificationHandler(NotificationCommon::EXTENSION, | 63 AddNotificationHandler( |
| 64 base::MakeUnique<ExtensionNotificationHandler>()); | 64 NotificationCommon::EXTENSION, |
| 65 base::MakeUnique<extensions::ExtensionNotificationHandler>()); | |
|
dewittj
2017/05/16 22:07:17
Depending on where else this type is referenced, i
Miguel Garcia
2017/05/20 07:04:10
I've noticed this pattern with the notification de
| |
| 65 #endif | 66 #endif |
| 66 } | 67 } |
| 67 | 68 |
| 68 NativeNotificationDisplayService::~NativeNotificationDisplayService() = default; | 69 NativeNotificationDisplayService::~NativeNotificationDisplayService() = default; |
| 69 | 70 |
| 70 void NativeNotificationDisplayService::OnNotificationPlatformBridgeReady( | 71 void NativeNotificationDisplayService::OnNotificationPlatformBridgeReady( |
| 71 bool success) { | 72 bool success) { |
| 72 UMA_HISTOGRAM_BOOLEAN("Notifications.UsingNativeNotificationCenter", success); | 73 UMA_HISTOGRAM_BOOLEAN("Notifications.UsingNativeNotificationCenter", success); |
| 73 if (success) { | 74 if (success) { |
| 74 notification_bridge_ready_ = true; | 75 notification_bridge_ready_ = true; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 175 notification_handlers_.erase(notification_type); | 176 notification_handlers_.erase(notification_type); |
| 176 } | 177 } |
| 177 | 178 |
| 178 NotificationHandler* NativeNotificationDisplayService::GetNotificationHandler( | 179 NotificationHandler* NativeNotificationDisplayService::GetNotificationHandler( |
| 179 NotificationCommon::Type notification_type) { | 180 NotificationCommon::Type notification_type) { |
| 180 DCHECK(notification_handlers_.find(notification_type) != | 181 DCHECK(notification_handlers_.find(notification_type) != |
| 181 notification_handlers_.end()) | 182 notification_handlers_.end()) |
| 182 << notification_type << " is not registered."; | 183 << notification_type << " is not registered."; |
| 183 return notification_handlers_[notification_type].get(); | 184 return notification_handlers_[notification_type].get(); |
| 184 } | 185 } |
| OLD | NEW |