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

Unified Diff: chrome/browser/chromeos/arc/arc_migration_guide_notification.cc

Issue 2828213002: arc: Show migration success notification on the next sign-in after migration. (Closed)
Patch Set: Rebase over the icon addition CL 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/arc/arc_migration_guide_notification.cc
diff --git a/chrome/browser/chromeos/arc/arc_migration_guide_notification.cc b/chrome/browser/chromeos/arc/arc_migration_guide_notification.cc
index 2715606ea194bcd6c20dc2e6598504e9b43de55a..a807fedb929ac70f9a0e26859db2ca6e4c06a853 100644
--- a/chrome/browser/chromeos/arc/arc_migration_guide_notification.cc
+++ b/chrome/browser/chromeos/arc/arc_migration_guide_notification.cc
@@ -11,8 +11,10 @@
#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/ash/multi_user/multi_user_util.h"
+#include "chrome/common/pref_names.h"
#include "chrome/grit/generated_resources.h"
#include "components/signin/core/account_id/account_id.h"
+#include "components/user_manager/known_user.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/color_palette.h"
#include "ui/gfx/paint_vector_icon.h"
@@ -25,7 +27,8 @@ namespace arc {
namespace {
constexpr char kNotifierId[] = "arc_fs_migration";
-constexpr char kNotificationId[] = "arc_fs_migration/migrate";
+constexpr char kSuggestNotificationId[] = "arc_fs_migration/suggest";
+constexpr char kSuccessNotificationId[] = "arc_fs_migration/success";
class ArcMigrationGuideNotificationDelegate
: public message_center::NotificationDelegate {
@@ -47,8 +50,8 @@ class ArcMigrationGuideNotificationDelegate
void ShowArcMigrationGuideNotification(Profile* profile) {
// Always remove the notification to make sure the notification appears
// as a popup in any situation.
- message_center::MessageCenter::Get()->RemoveNotification(kNotificationId,
- false /* by_user */);
+ message_center::MessageCenter::Get()->RemoveNotification(
+ kSuggestNotificationId, false /* by_user */);
message_center::NotifierId notifier_id(
message_center::NotifierId::SYSTEM_COMPONENT, kNotifierId);
@@ -60,7 +63,7 @@ void ShowArcMigrationGuideNotification(Profile* profile) {
IDS_ARC_MIGRATE_ENCRYPTION_NOTIFICATION_RESTART_BUTTON)));
message_center::MessageCenter::Get()->AddNotification(
base::MakeUnique<message_center::Notification>(
- message_center::NOTIFICATION_TYPE_SIMPLE, kNotificationId,
+ message_center::NOTIFICATION_TYPE_SIMPLE, kSuggestNotificationId,
l10n_util::GetStringUTF16(
IDS_ARC_MIGRATE_ENCRYPTION_NOTIFICATION_TITLE),
// TODO(kinaba): crbug/710289 Change message for low-battery case.
@@ -72,4 +75,42 @@ void ShowArcMigrationGuideNotification(Profile* profile) {
new ArcMigrationGuideNotificationDelegate()));
}
+void ShowArcMigrationSuccessNotificationIfNeeded(Profile* profile) {
+ const AccountId account_id(multi_user_util::GetAccountIdFromProfile(profile));
hidehiko 2017/04/24 05:59:48 totally nit/optional: Often, in Chrome, = is used
kinaba 2017/04/24 06:09:36 Done.
+
+ int pref_value = kFileSystemIncompatible;
+ user_manager::known_user::GetIntegerPref(
+ account_id, prefs::kArcCompatibleFilesystemChosen, &pref_value);
+
+ // Show notification only when the pref value indicates the file system is
+ // compatible, but not yet notified.
+ if (pref_value != kFileSystemCompatible)
+ return;
+
+ // If this is a newly created profile, the filesystem was compatible from
+ // the beginning, not because of migration. Skip showing the notification.
+ if (!profile->IsNewProfile()) {
+ message_center::NotifierId notifier_id(
+ message_center::NotifierId::SYSTEM_COMPONENT, kNotifierId);
+ notifier_id.profile_id = account_id.GetUserEmail();
+
+ message_center::MessageCenter::Get()->AddNotification(
+ base::MakeUnique<message_center::Notification>(
+ message_center::NOTIFICATION_TYPE_SIMPLE, kSuccessNotificationId,
+ base::string16(), // title
+ l10n_util::GetStringUTF16(
+ IDS_ARC_MIGRATE_ENCRYPTION_SUCCESS_MESSAGE),
+ gfx::Image(gfx::CreateVectorIcon(
+ kArcMigrateEncryptionNotificationIcon, gfx::kPlaceholderColor)),
+ base::string16(), GURL(), notifier_id,
+ message_center::RichNotificationData(),
+ new message_center::NotificationDelegate()));
+ }
+
+ // Mark as notified.
+ user_manager::known_user::SetIntegerPref(
+ account_id, prefs::kArcCompatibleFilesystemChosen,
+ arc::kFileSystemCompatibleAndNotified);
+}
+
} // namespace arc

Powered by Google App Engine
This is Rietveld 408576698