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" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" | 13 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" |
14 #include "chrome/grit/generated_resources.h" | 14 #include "chrome/grit/generated_resources.h" |
15 #include "chrome/grit/theme_resources.h" | 15 #include "chrome/grit/theme_resources.h" |
16 #include "components/signin/core/account_id/account_id.h" | 16 #include "components/signin/core/account_id/account_id.h" |
17 #include "ui/base/l10n/l10n_util.h" | 17 #include "ui/base/l10n/l10n_util.h" |
18 #include "ui/base/resource/resource_bundle.h" | 18 #include "ui/base/resource/resource_bundle.h" |
19 #include "ui/message_center/message_center.h" | 19 #include "ui/message_center/message_center.h" |
20 #include "ui/message_center/message_center_observer.h" | 20 #include "ui/message_center/message_center_observer.h" |
21 #include "ui/message_center/notification.h" | 21 #include "ui/message_center/notification.h" |
22 #include "ui/message_center/notification_delegate.h" | 22 #include "ui/message_center/notification_delegate.h" |
23 #include "url/gurl.h" | 23 #include "url/gurl.h" |
24 | 24 |
25 namespace { | 25 namespace { |
26 | 26 |
27 // Ids of the notification shown on first run. | 27 // Ids of the notification shown on first run. |
28 const char kNotifierId[] = "arc_auth"; | 28 const char kNotifierId[] = "arc_auth"; |
29 const char kDisplaySoruce[] = "arc_auth_source"; | 29 const char kDisplaySource[] = "arc_auth_source"; |
30 const char kFirstRunNotificationId[] = "arc_auth/first_run"; | 30 const char kFirstRunNotificationId[] = "arc_auth/first_run"; |
31 | 31 |
32 class ArcAuthNotificationDelegate | 32 class ArcAuthNotificationDelegate |
33 : public message_center::NotificationDelegate, | 33 : public message_center::NotificationDelegate, |
34 public message_center::MessageCenterObserver { | 34 public message_center::MessageCenterObserver { |
35 public: | 35 public: |
36 ArcAuthNotificationDelegate() {} | 36 ArcAuthNotificationDelegate() {} |
37 | 37 |
38 // message_center::MessageCenterObserver | 38 // message_center::MessageCenterObserver |
39 void OnNotificationUpdated(const std::string& notification_id) override { | 39 void OnNotificationUpdated(const std::string& notification_id) override { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 data.buttons.push_back(message_center::ButtonInfo( | 100 data.buttons.push_back(message_center::ButtonInfo( |
101 l10n_util::GetStringUTF16(IDS_ARC_CANCEL_NOTIFICATION_BUTTON))); | 101 l10n_util::GetStringUTF16(IDS_ARC_CANCEL_NOTIFICATION_BUTTON))); |
102 ui::ResourceBundle& resource_bundle = ui::ResourceBundle::GetSharedInstance(); | 102 ui::ResourceBundle& resource_bundle = ui::ResourceBundle::GetSharedInstance(); |
103 std::unique_ptr<message_center::Notification> notification( | 103 std::unique_ptr<message_center::Notification> notification( |
104 new message_center::Notification( | 104 new message_center::Notification( |
105 message_center::NOTIFICATION_TYPE_SIMPLE, kFirstRunNotificationId, | 105 message_center::NOTIFICATION_TYPE_SIMPLE, kFirstRunNotificationId, |
106 l10n_util::GetStringUTF16(IDS_ARC_NOTIFICATION_TITLE), | 106 l10n_util::GetStringUTF16(IDS_ARC_NOTIFICATION_TITLE), |
107 l10n_util::GetStringFUTF16(IDS_ARC_NOTIFICATION_MESSAGE, | 107 l10n_util::GetStringFUTF16(IDS_ARC_NOTIFICATION_MESSAGE, |
108 ash::GetChromeOSDeviceName()), | 108 ash::GetChromeOSDeviceName()), |
109 resource_bundle.GetImageNamed(IDR_ARC_PLAY_STORE_NOTIFICATION), | 109 resource_bundle.GetImageNamed(IDR_ARC_PLAY_STORE_NOTIFICATION), |
110 base::UTF8ToUTF16(kDisplaySoruce), GURL(), notifier_id, data, | 110 base::UTF8ToUTF16(kDisplaySource), GURL(), notifier_id, data, |
111 new ArcAuthNotificationDelegate())); | 111 new ArcAuthNotificationDelegate())); |
112 message_center::MessageCenter::Get()->AddNotification( | 112 message_center::MessageCenter::Get()->AddNotification( |
113 std::move(notification)); | 113 std::move(notification)); |
114 } | 114 } |
115 | 115 |
116 // static | 116 // static |
117 void ArcAuthNotification::Hide() { | 117 void ArcAuthNotification::Hide() { |
118 message_center::MessageCenter::Get()->RemoveNotification( | 118 message_center::MessageCenter::Get()->RemoveNotification( |
119 kFirstRunNotificationId, false); | 119 kFirstRunNotificationId, false); |
120 } | 120 } |
121 | 121 |
122 } // namespace arc | 122 } // namespace arc |
OLD | NEW |