| 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 "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/browser/notifications/notification.h" |
| 8 #include "chrome/browser/notifications/notification_platform_bridge.h" | 9 #include "chrome/browser/notifications/notification_platform_bridge.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 10 | 11 |
| 11 namespace { | 12 namespace { |
| 12 | 13 |
| 13 std::string GetProfileId(Profile* profile) { | 14 std::string GetProfileId(Profile* profile) { |
| 14 #if defined(OS_WIN) | 15 #if defined(OS_WIN) |
| 15 std::string profile_id = | 16 std::string profile_id = |
| 16 base::WideToUTF8(profile->GetPath().BaseName().value()); | 17 base::WideToUTF8(profile->GetPath().BaseName().value()); |
| 17 #elif defined(OS_POSIX) | 18 #elif defined(OS_POSIX) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 30 DCHECK(notification_bridge_); | 31 DCHECK(notification_bridge_); |
| 31 } | 32 } |
| 32 | 33 |
| 33 NativeNotificationDisplayService::~NativeNotificationDisplayService() {} | 34 NativeNotificationDisplayService::~NativeNotificationDisplayService() {} |
| 34 | 35 |
| 35 void NativeNotificationDisplayService::Display( | 36 void NativeNotificationDisplayService::Display( |
| 36 const std::string& notification_id, | 37 const std::string& notification_id, |
| 37 const Notification& notification) { | 38 const Notification& notification) { |
| 38 notification_bridge_->Display(notification_id, GetProfileId(profile_), | 39 notification_bridge_->Display(notification_id, GetProfileId(profile_), |
| 39 profile_->IsOffTheRecord(), notification); | 40 profile_->IsOffTheRecord(), notification); |
| 41 notification.delegate()->Display(); |
| 40 } | 42 } |
| 41 | 43 |
| 42 void NativeNotificationDisplayService::Close( | 44 void NativeNotificationDisplayService::Close( |
| 43 const std::string& notification_id) { | 45 const std::string& notification_id) { |
| 44 notification_bridge_->Close(GetProfileId(profile_), notification_id); | 46 notification_bridge_->Close(GetProfileId(profile_), notification_id); |
| 45 } | 47 } |
| 46 | 48 |
| 47 bool NativeNotificationDisplayService::GetDisplayed( | 49 bool NativeNotificationDisplayService::GetDisplayed( |
| 48 std::set<std::string>* notifications) const { | 50 std::set<std::string>* notifications) const { |
| 49 return notification_bridge_->GetDisplayed( | 51 return notification_bridge_->GetDisplayed( |
| 50 GetProfileId(profile_), profile_->IsOffTheRecord(), notifications); | 52 GetProfileId(profile_), profile_->IsOffTheRecord(), notifications); |
| 51 } | 53 } |
| 52 | 54 |
| 53 bool NativeNotificationDisplayService::SupportsNotificationCenter() const { | 55 bool NativeNotificationDisplayService::SupportsNotificationCenter() const { |
| 54 return notification_bridge_->SupportsNotificationCenter(); | 56 return notification_bridge_->SupportsNotificationCenter(); |
| 55 } | 57 } |
| OLD | NEW |