Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/chromeos/arc/arc_migration_guide_notification.h" | |
| 6 | |
| 7 #include "base/macros.h" | |
| 8 #include "base/memory/ptr_util.h" | |
| 9 #include "chrome/browser/chromeos/arc/arc_util.h" | |
| 10 #include "chrome/browser/lifetime/application_lifetime.h" | |
| 11 #include "chrome/browser/profiles/profile.h" | |
| 12 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" | |
| 13 #include "chrome/grit/generated_resources.h" | |
| 14 #include "chrome/grit/theme_resources.h" | |
| 15 #include "components/signin/core/account_id/account_id.h" | |
| 16 #include "ui/base/l10n/l10n_util.h" | |
| 17 #include "ui/base/resource/resource_bundle.h" | |
| 18 #include "ui/message_center/message_center.h" | |
| 19 #include "ui/message_center/notification.h" | |
| 20 #include "ui/message_center/notification_delegate.h" | |
| 21 | |
| 22 namespace arc { | |
| 23 | |
| 24 namespace { | |
| 25 | |
| 26 constexpr char kNotifierId[] = "arc_fs_migration"; | |
| 27 constexpr char kNotificationId[] = "arc_fs_migration/migrate"; | |
| 28 | |
| 29 class ArcMigrationGuideNotificationDelegate | |
| 30 : public message_center::NotificationDelegate { | |
| 31 public: | |
| 32 ArcMigrationGuideNotificationDelegate() {} | |
|
hidehiko
2017/04/10 14:14:09
nit: Please s/{}/= default;/. Ditto for dtor.
kinaba
2017/04/10 14:31:00
Done.
| |
| 33 | |
| 34 // message_center::NotificationDelegate | |
| 35 void ButtonClick(int button_index) override { chrome::AttemptUserExit(); } | |
| 36 | |
| 37 private: | |
| 38 ~ArcMigrationGuideNotificationDelegate() override {} | |
| 39 | |
| 40 DISALLOW_COPY_AND_ASSIGN(ArcMigrationGuideNotificationDelegate); | |
| 41 }; | |
| 42 | |
| 43 } // namespace | |
| 44 | |
| 45 // static | |
| 46 void ShowArcMigrationGuideNotification(Profile* profile) { | |
| 47 // Always remove the notification to make sure the notification appears | |
| 48 // as a popup in any situation. | |
| 49 message_center::MessageCenter::Get()->RemoveNotification(kNotificationId, | |
| 50 false /* by_user */); | |
| 51 | |
| 52 message_center::NotifierId notifier_id( | |
| 53 message_center::NotifierId::SYSTEM_COMPONENT, kNotifierId); | |
| 54 notifier_id.profile_id = | |
| 55 multi_user_util::GetAccountIdFromProfile(profile).GetUserEmail(); | |
| 56 | |
| 57 message_center::RichNotificationData data; | |
| 58 data.buttons.push_back(message_center::ButtonInfo(l10n_util::GetStringUTF16( | |
| 59 IDS_ARC_MIGRATE_ENCRYPTION_NOTIFICATION_RESTART_BUTTON))); | |
| 60 ui::ResourceBundle& resource_bundle = ui::ResourceBundle::GetSharedInstance(); | |
| 61 message_center::MessageCenter::Get()->AddNotification( | |
| 62 base::MakeUnique<message_center::Notification>( | |
| 63 message_center::NOTIFICATION_TYPE_SIMPLE, kNotificationId, | |
| 64 l10n_util::GetStringUTF16( | |
| 65 IDS_ARC_MIGRATE_ENCRYPTION_NOTIFICATION_TITLE), | |
| 66 // TODO(kinaba): Change message for low-battery case. | |
| 67 l10n_util::GetStringUTF16( | |
| 68 IDS_ARC_MIGRATE_ENCRYPTION_NOTIFICATION_MESSAGE), | |
| 69 // TODO(kinaba): Replace the icon with the final design. | |
| 70 resource_bundle.GetImageNamed(IDR_ARC_PLAY_STORE_NOTIFICATION), | |
| 71 base::string16(), GURL(), notifier_id, data, | |
| 72 new ArcMigrationGuideNotificationDelegate())); | |
| 73 } | |
| 74 | |
| 75 } // namespace arc | |
| OLD | NEW |