| 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/profile_notification.h" | 5 #include "chrome/browser/notifications/profile_notification.h" |
| 6 | 6 |
| 7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" | 8 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" |
| 9 #include "components/user_manager/user_id.h" |
| 9 | 10 |
| 10 // static | 11 // static |
| 11 std::string ProfileNotification::GetProfileNotificationId( | 12 std::string ProfileNotification::GetProfileNotificationId( |
| 12 const std::string& delegate_id, | 13 const std::string& delegate_id, |
| 13 ProfileID profile_id) { | 14 ProfileID profile_id) { |
| 14 DCHECK(profile_id); | 15 DCHECK(profile_id); |
| 15 return base::StringPrintf("notification-ui-manager#%p#%s", | 16 return base::StringPrintf("notification-ui-manager#%p#%s", |
| 16 profile_id, // Each profile has its unique instance | 17 profile_id, // Each profile has its unique instance |
| 17 // including incognito profile. | 18 // including incognito profile. |
| 18 delegate_id.c_str()); | 19 delegate_id.c_str()); |
| 19 } | 20 } |
| 20 | 21 |
| 21 ProfileNotification::ProfileNotification( | 22 ProfileNotification::ProfileNotification( |
| 22 Profile* profile, | 23 Profile* profile, |
| 23 const Notification& notification) | 24 const Notification& notification) |
| 24 : profile_(profile), | 25 : profile_(profile), |
| 25 notification_( | 26 notification_( |
| 26 // Uses Notification's copy constructor to assign the message center | 27 // Uses Notification's copy constructor to assign the message center |
| 27 // id, which should be unique for every profile + Notification pair. | 28 // id, which should be unique for every profile + Notification pair. |
| 28 GetProfileNotificationId( | 29 GetProfileNotificationId( |
| 29 notification.delegate_id(), | 30 notification.delegate_id(), |
| 30 NotificationUIManager::GetProfileID(profile)), | 31 NotificationUIManager::GetProfileID(profile)), |
| 31 notification) { | 32 notification) { |
| 32 DCHECK(profile); | 33 DCHECK(profile); |
| 33 #if defined(OS_CHROMEOS) | 34 #if defined(OS_CHROMEOS) |
| 34 notification_.set_profile_id(multi_user_util::GetUserIDFromProfile(profile)); | 35 notification_.set_profile_id(multi_user_util::GetUserIDFromProfile(profile).Ge
tUserEmail()); |
| 35 #endif | 36 #endif |
| 36 } | 37 } |
| 37 | 38 |
| 38 ProfileNotification::~ProfileNotification() {} | 39 ProfileNotification::~ProfileNotification() {} |
| 39 | 40 |
| OLD | NEW |