Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(745)

Side by Side Diff: chrome/browser/chromeos/arc/arc_migration_guide_notification.cc

Issue 2813633002: arc: Notification for guiding the user to filesystem migration. (Closed)
Patch Set: Fix for hidehiko@'s comments. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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() = default;
33
34 // message_center::NotificationDelegate
35 void ButtonClick(int button_index) override { chrome::AttemptUserExit(); }
36
37 private:
38 ~ArcMigrationGuideNotificationDelegate() override = default;
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.
khmel 2017/04/10 19:10:10 nit: probably bug id sounds better here once this
kinaba 2017/04/11 00:59:20 Done.
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698