| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 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_migration_guide_notification.h" | 5 #include "chrome/browser/chromeos/arc/arc_migration_guide_notification.h" |
| 6 | 6 |
| 7 #include "ash/system/devicetype_utils.h" |
| 8 #include "ash/system/power/power_status.h" |
| 7 #include "base/macros.h" | 9 #include "base/macros.h" |
| 8 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 9 #include "chrome/app/vector_icons/vector_icons.h" | 11 #include "chrome/app/vector_icons/vector_icons.h" |
| 12 #include "chrome/browser/chromeos/arc/arc_migration_constants.h" |
| 10 #include "chrome/browser/chromeos/arc/arc_util.h" | 13 #include "chrome/browser/chromeos/arc/arc_util.h" |
| 11 #include "chrome/browser/lifetime/application_lifetime.h" | 14 #include "chrome/browser/lifetime/application_lifetime.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" | 16 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" |
| 14 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
| 15 #include "chrome/grit/generated_resources.h" | 18 #include "chrome/grit/generated_resources.h" |
| 16 #include "components/signin/core/account_id/account_id.h" | 19 #include "components/signin/core/account_id/account_id.h" |
| 17 #include "components/user_manager/known_user.h" | 20 #include "components/user_manager/known_user.h" |
| 18 #include "ui/base/l10n/l10n_util.h" | 21 #include "ui/base/l10n/l10n_util.h" |
| 19 #include "ui/gfx/color_palette.h" | 22 #include "ui/gfx/color_palette.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 // Always remove the notification to make sure the notification appears | 54 // Always remove the notification to make sure the notification appears |
| 52 // as a popup in any situation. | 55 // as a popup in any situation. |
| 53 message_center::MessageCenter::Get()->RemoveNotification( | 56 message_center::MessageCenter::Get()->RemoveNotification( |
| 54 kSuggestNotificationId, false /* by_user */); | 57 kSuggestNotificationId, false /* by_user */); |
| 55 | 58 |
| 56 message_center::NotifierId notifier_id( | 59 message_center::NotifierId notifier_id( |
| 57 message_center::NotifierId::SYSTEM_COMPONENT, kNotifierId); | 60 message_center::NotifierId::SYSTEM_COMPONENT, kNotifierId); |
| 58 notifier_id.profile_id = | 61 notifier_id.profile_id = |
| 59 multi_user_util::GetAccountIdFromProfile(profile).GetUserEmail(); | 62 multi_user_util::GetAccountIdFromProfile(profile).GetUserEmail(); |
| 60 | 63 |
| 64 const bool is_low_battery = ash::PowerStatus::IsInitialized() && |
| 65 ash::PowerStatus::Get()->IsBatteryPresent() && |
| 66 ash::PowerStatus::Get()->GetBatteryPercent() < |
| 67 kMigrationMinimumBatteryPercent; |
| 68 |
| 69 const base::string16 message = |
| 70 is_low_battery |
| 71 ? ash::SubstituteChromeOSDeviceType( |
| 72 IDS_ARC_MIGRATE_ENCRYPTION_NOTIFICATION_LOW_BATTERY_MESSAGE) |
| 73 : l10n_util::GetStringUTF16( |
| 74 IDS_ARC_MIGRATE_ENCRYPTION_NOTIFICATION_MESSAGE); |
| 75 |
| 61 message_center::RichNotificationData data; | 76 message_center::RichNotificationData data; |
| 62 data.buttons.push_back(message_center::ButtonInfo(l10n_util::GetStringUTF16( | 77 data.buttons.push_back(message_center::ButtonInfo(l10n_util::GetStringUTF16( |
| 63 IDS_ARC_MIGRATE_ENCRYPTION_NOTIFICATION_RESTART_BUTTON))); | 78 IDS_ARC_MIGRATE_ENCRYPTION_NOTIFICATION_RESTART_BUTTON))); |
| 64 message_center::MessageCenter::Get()->AddNotification( | 79 message_center::MessageCenter::Get()->AddNotification( |
| 65 base::MakeUnique<message_center::Notification>( | 80 base::MakeUnique<message_center::Notification>( |
| 66 message_center::NOTIFICATION_TYPE_SIMPLE, kSuggestNotificationId, | 81 message_center::NOTIFICATION_TYPE_SIMPLE, kSuggestNotificationId, |
| 67 l10n_util::GetStringUTF16( | 82 l10n_util::GetStringUTF16( |
| 68 IDS_ARC_MIGRATE_ENCRYPTION_NOTIFICATION_TITLE), | 83 IDS_ARC_MIGRATE_ENCRYPTION_NOTIFICATION_TITLE), |
| 69 // TODO(kinaba): crbug/710289 Change message for low-battery case. | 84 message, |
| 70 l10n_util::GetStringUTF16( | |
| 71 IDS_ARC_MIGRATE_ENCRYPTION_NOTIFICATION_MESSAGE), | |
| 72 gfx::Image(gfx::CreateVectorIcon( | 85 gfx::Image(gfx::CreateVectorIcon( |
| 73 kArcMigrateEncryptionNotificationIcon, gfx::kPlaceholderColor)), | 86 kArcMigrateEncryptionNotificationIcon, gfx::kPlaceholderColor)), |
| 74 base::string16(), GURL(), notifier_id, data, | 87 base::string16(), GURL(), notifier_id, data, |
| 75 new ArcMigrationGuideNotificationDelegate())); | 88 new ArcMigrationGuideNotificationDelegate())); |
| 76 } | 89 } |
| 77 | 90 |
| 78 void ShowArcMigrationSuccessNotificationIfNeeded(Profile* profile) { | 91 void ShowArcMigrationSuccessNotificationIfNeeded(Profile* profile) { |
| 79 const AccountId account_id = | 92 const AccountId account_id = |
| 80 multi_user_util::GetAccountIdFromProfile(profile); | 93 multi_user_util::GetAccountIdFromProfile(profile); |
| 81 | 94 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 new message_center::NotificationDelegate())); | 129 new message_center::NotificationDelegate())); |
| 117 } | 130 } |
| 118 | 131 |
| 119 // Mark as notified. | 132 // Mark as notified. |
| 120 user_manager::known_user::SetIntegerPref( | 133 user_manager::known_user::SetIntegerPref( |
| 121 account_id, prefs::kArcCompatibleFilesystemChosen, | 134 account_id, prefs::kArcCompatibleFilesystemChosen, |
| 122 arc::kFileSystemCompatibleAndNotified); | 135 arc::kFileSystemCompatibleAndNotified); |
| 123 } | 136 } |
| 124 | 137 |
| 125 } // namespace arc | 138 } // namespace arc |
| OLD | NEW |