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/chromeos/arc/arc_auth_notification.h" | 5 #include "chrome/browser/chromeos/arc/arc_auth_notification.h" |
| 6 | 6 |
| 7 #include "ash/common/system/chromeos/devicetype_utils.h" | 7 #include "ash/common/system/chromeos/devicetype_utils.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/chromeos/arc/arc_auth_service.h" | 10 #include "chrome/browser/chromeos/arc/arc_auth_service.h" |
| 11 #include "chrome/browser/chromeos/arc/arc_optin_uma.h" | 11 #include "chrome/browser/chromeos/arc/arc_optin_uma.h" |
| 12 #include "chrome/browser/profiles/profile.h" | |
|
oshima
2016/07/19 15:58:55
I believe you don't need this.
mtomasz
2016/07/20 00:22:55
Done.
| |
| 13 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" | |
| 12 #include "chrome/grit/generated_resources.h" | 14 #include "chrome/grit/generated_resources.h" |
| 13 #include "chrome/grit/theme_resources.h" | 15 #include "chrome/grit/theme_resources.h" |
| 16 #include "components/signin/core/account_id/account_id.h" | |
| 14 #include "ui/base/l10n/l10n_util.h" | 17 #include "ui/base/l10n/l10n_util.h" |
| 15 #include "ui/base/resource/resource_bundle.h" | 18 #include "ui/base/resource/resource_bundle.h" |
| 16 #include "ui/message_center/message_center.h" | 19 #include "ui/message_center/message_center.h" |
| 17 #include "ui/message_center/message_center_observer.h" | 20 #include "ui/message_center/message_center_observer.h" |
| 18 #include "ui/message_center/notification.h" | 21 #include "ui/message_center/notification.h" |
| 19 #include "ui/message_center/notification_delegate.h" | 22 #include "ui/message_center/notification_delegate.h" |
| 20 #include "url/gurl.h" | 23 #include "url/gurl.h" |
| 21 | 24 |
| 22 namespace { | 25 namespace { |
| 23 | 26 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 78 } | 81 } |
| 79 | 82 |
| 80 DISALLOW_COPY_AND_ASSIGN(ArcAuthNotificationDelegate); | 83 DISALLOW_COPY_AND_ASSIGN(ArcAuthNotificationDelegate); |
| 81 }; | 84 }; |
| 82 | 85 |
| 83 } // namespace | 86 } // namespace |
| 84 | 87 |
| 85 namespace arc { | 88 namespace arc { |
| 86 | 89 |
| 87 // static | 90 // static |
| 88 void ArcAuthNotification::Show() { | 91 void ArcAuthNotification::Show(Profile* profile) { |
| 89 message_center::NotifierId notifier_id( | 92 message_center::NotifierId notifier_id( |
| 90 message_center::NotifierId::SYSTEM_COMPONENT, kNotifierId); | 93 message_center::NotifierId::SYSTEM_COMPONENT, kNotifierId); |
| 94 notifier_id.profile_id = | |
| 95 multi_user_util::GetAccountIdFromProfile(profile).GetUserEmail(); | |
| 91 | 96 |
| 92 message_center::RichNotificationData data; | 97 message_center::RichNotificationData data; |
| 93 data.buttons.push_back(message_center::ButtonInfo( | 98 data.buttons.push_back(message_center::ButtonInfo( |
| 94 l10n_util::GetStringUTF16(IDS_ARC_OPEN_PLAY_STORE_NOTIFICATION_BUTTON))); | 99 l10n_util::GetStringUTF16(IDS_ARC_OPEN_PLAY_STORE_NOTIFICATION_BUTTON))); |
| 95 data.buttons.push_back(message_center::ButtonInfo( | 100 data.buttons.push_back(message_center::ButtonInfo( |
| 96 l10n_util::GetStringUTF16(IDS_ARC_CANCEL_NOTIFICATION_BUTTON))); | 101 l10n_util::GetStringUTF16(IDS_ARC_CANCEL_NOTIFICATION_BUTTON))); |
| 97 ui::ResourceBundle& resource_bundle = ui::ResourceBundle::GetSharedInstance(); | 102 ui::ResourceBundle& resource_bundle = ui::ResourceBundle::GetSharedInstance(); |
| 98 std::unique_ptr<message_center::Notification> notification( | 103 std::unique_ptr<message_center::Notification> notification( |
| 99 new message_center::Notification( | 104 new message_center::Notification( |
| 100 message_center::NOTIFICATION_TYPE_SIMPLE, kFirstRunNotificationId, | 105 message_center::NOTIFICATION_TYPE_SIMPLE, kFirstRunNotificationId, |
| 101 l10n_util::GetStringUTF16(IDS_ARC_NOTIFICATION_TITLE), | 106 l10n_util::GetStringUTF16(IDS_ARC_NOTIFICATION_TITLE), |
| 102 l10n_util::GetStringFUTF16(IDS_ARC_NOTIFICATION_MESSAGE, | 107 l10n_util::GetStringFUTF16(IDS_ARC_NOTIFICATION_MESSAGE, |
| 103 ash::GetChromeOSDeviceName()), | 108 ash::GetChromeOSDeviceName()), |
| 104 resource_bundle.GetImageNamed(IDR_ARC_PLAY_STORE_NOTIFICATION), | 109 resource_bundle.GetImageNamed(IDR_ARC_PLAY_STORE_NOTIFICATION), |
| 105 base::UTF8ToUTF16(kDisplaySoruce), GURL(), notifier_id, data, | 110 base::UTF8ToUTF16(kDisplaySoruce), GURL(), notifier_id, data, |
| 106 new ArcAuthNotificationDelegate())); | 111 new ArcAuthNotificationDelegate())); |
| 107 message_center::MessageCenter::Get()->AddNotification( | 112 message_center::MessageCenter::Get()->AddNotification( |
| 108 std::move(notification)); | 113 std::move(notification)); |
| 109 } | 114 } |
| 110 | 115 |
| 111 // static | 116 // static |
| 112 void ArcAuthNotification::Hide() { | 117 void ArcAuthNotification::Hide() { |
| 113 message_center::MessageCenter::Get()->RemoveNotification( | 118 message_center::MessageCenter::Get()->RemoveNotification( |
| 114 kFirstRunNotificationId, false); | 119 kFirstRunNotificationId, false); |
| 115 } | 120 } |
| 116 | 121 |
| 117 } // namespace arc | 122 } // namespace arc |
| OLD | NEW |