Index: chrome/browser/notifications/native_notification_display_service.cc |
diff --git a/chrome/browser/notifications/native_notification_display_service.cc b/chrome/browser/notifications/native_notification_display_service.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..2155b35a6310d5c22533493950868c42e08515c5 |
--- /dev/null |
+++ b/chrome/browser/notifications/native_notification_display_service.cc |
@@ -0,0 +1,54 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/browser/notifications/native_notification_display_service.h" |
+ |
+#include "base/strings/utf_string_conversions.h" |
+#include "chrome/browser/notifications/notification_bridge.h" |
+#include "chrome/browser/profiles/profile.h" |
+ |
+namespace { |
+std::string GetProfileId(Profile* profile) { |
Peter Beverloo
2016/04/18 14:57:09
micro nit: blank lines after namespace opening and
Miguel Garcia
2016/04/19 14:24:57
Done.
|
+#if defined(OS_WIN) |
+ std::string profile_id = |
+ base::WideToUTF8(profile->GetPath().BaseName().value()); |
+#elif defined(OS_POSIX) |
+ std::string profile_id = profile->GetPath().BaseName().value(); |
+#endif |
+ return profile_id; |
+} |
+} // namespace |
+ |
+NativeNotificationDisplayService::NativeNotificationDisplayService( |
+ Profile* profile, |
+ NotificationBridge* notification_bridge) |
+ : profile_(profile), notification_bridge_(notification_bridge) {} |
+ |
+NativeNotificationDisplayService::~NativeNotificationDisplayService() {} |
+ |
+void NativeNotificationDisplayService::Display( |
+ const std::string& notification_id, |
+ const Notification& notification) { |
+ DCHECK(notification_bridge_); |
Peter Beverloo
2016/04/18 14:57:09
nit: DCHECK in the constructor instead? That way w
Miguel Garcia
2016/04/19 14:24:57
Done.
|
+ notification_bridge_->Display(notification_id, GetProfileId(profile_), |
+ profile_->IsOffTheRecord(), notification); |
+} |
+ |
+void NativeNotificationDisplayService::Close( |
+ const std::string& notification_id) { |
+ DCHECK(notification_bridge_); |
+ notification_bridge_->Close(GetProfileId(profile_), notification_id); |
+} |
+ |
+bool NativeNotificationDisplayService::GetDisplayed( |
+ std::set<std::string>* notifications) const { |
+ DCHECK(notification_bridge_); |
+ return notification_bridge_->GetDisplayed( |
+ GetProfileId(profile_), profile_->IsOffTheRecord(), notifications); |
+} |
+ |
+bool NativeNotificationDisplayService::SupportsNotificationCenter() const { |
+ DCHECK(notification_bridge_); |
+ return notification_bridge_->SupportsNotificationCenter(); |
+} |