Commit d618d6ba authored by Ahmed Mehfooz's avatar Ahmed Mehfooz Committed by Commit Bot

Add one time notification for gesture education

Bug: 1056451
Change-Id: Ie624e1c5256da34bc99f6019ac70b14d5f5c3d26
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2079545Reviewed-by: default avatarTim Song <tengs@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Ahmed Mehfooz <amehfooz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#745711}
parent 9bd9d86b
......@@ -767,6 +767,8 @@ component("ash") {
"system/cast/unified_cast_detailed_view_controller.cc",
"system/cast/unified_cast_detailed_view_controller.h",
"system/enterprise/enterprise_domain_observer.h",
"system/gesture_education/gesture_education_notification_controller.cc",
"system/gesture_education/gesture_education_notification_controller.h",
"system/ime/ime_feature_pod_controller.cc",
"system/ime/ime_feature_pod_controller.h",
"system/ime/ime_observer.h",
......
......@@ -19,6 +19,7 @@
#include "ash/shelf/shelf_controller.h"
#include "ash/system/bluetooth/bluetooth_power_controller.h"
#include "ash/system/caps_lock_notification_controller.h"
#include "ash/system/gesture_education/gesture_education_notification_controller.h"
#include "ash/system/message_center/message_center_controller.h"
#include "ash/system/network/vpn_list_view.h"
#include "ash/system/night_light/night_light_controller_impl.h"
......@@ -47,6 +48,7 @@ void RegisterProfilePrefs(PrefRegistrySimple* registry, bool for_test) {
contextual_tooltip::RegisterProfilePrefs(registry);
desks_restore_util::RegisterProfilePrefs(registry);
DockedMagnifierControllerImpl::RegisterProfilePrefs(registry);
GestureEducationNotificationController::RegisterProfilePrefs(registry);
LoginScreenController::RegisterProfilePrefs(registry, for_test);
LogoutButtonTray::RegisterProfilePrefs(registry);
MediaControllerImpl::RegisterProfilePrefs(registry);
......
......@@ -446,6 +446,12 @@ This file contains the strings for ash.
<message name="IDS_ROLLBACK_NOTIFICATION_TITLE" desc="The title of the notification to notify that the user should restart to roll back the device.">
Device will be rolled back
</message>
<message name="IDS_GESTURE_NOTIFICATION_TITLE" desc="The title of the notification to show off new gestures.">
Try out new gesture navigation
</message>
<message name="IDS_GESTURE_NOTIFICATION_MESSAGE_LEARN_MORE" desc="The body of the notification to show off new gestures. This notification body links to the help page for the gestures.">
Use gestures to quickly switch between apps and interact with your chromebook in tablet mode.
</message>
<message name="IDS_UPDATE_NOTIFICATION_MESSAGE_LEARN_MORE" desc="The body of the notification to notify that the user should restart to get system updates. This notification body links to the info page on the update.">
Learn more about the latest <ph name="SYSTEM_APP_NAME">$1<ex>Chromium OS</ex></ph> update
</message>
......
b830625ecaa29020d83b4a73caa073804e740894
\ No newline at end of file
b830625ecaa29020d83b4a73caa073804e740894
\ No newline at end of file
......@@ -196,6 +196,11 @@ const char kExternalDisplayMirrorInfo[] =
// layout/offset information.
const char kSecondaryDisplays[] = "settings.display.secondary_displays";
// A boolean pref storing whether the gesture education notification has ever
// been shown to the user, which we use to stop showing it again.
const char kGestureEducationNotificationShown[] =
"ash.gesture_education.notification_shown";
// A boolean pref which stores whether a stylus has been seen before.
const char kHasSeenStylus[] = "ash.has_seen_stylus";
// A boolean pref which stores whether a the palette warm welcome bubble
......
......@@ -79,6 +79,8 @@ ASH_PUBLIC_EXPORT extern const char kDisplayTouchPortAssociations[];
ASH_PUBLIC_EXPORT extern const char kExternalDisplayMirrorInfo[];
ASH_PUBLIC_EXPORT extern const char kSecondaryDisplays[];
ASH_PUBLIC_EXPORT extern const char kGestureEducationNotificationShown[];
ASH_PUBLIC_EXPORT extern const char kHasSeenStylus[];
ASH_PUBLIC_EXPORT extern const char kShownPaletteWelcomeBubble[];
ASH_PUBLIC_EXPORT extern const char kEnableStylusTools[];
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/system/gesture_education/gesture_education_notification_controller.h"
#include "ash/public/cpp/ash_pref_names.h"
#include "ash/public/cpp/notification_utils.h"
#include "ash/public/cpp/system_tray_client.h"
#include "ash/session/session_controller_impl.h"
#include "ash/shell.h"
#include "ash/strings/grit/ash_strings.h"
#include "ash/system/model/system_tray_model.h"
#include "base/bind.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/pref_service.h"
#include "components/vector_icons/vector_icons.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/message_center/message_center.h"
#include "ui/message_center/public/cpp/notification.h"
namespace ash {
namespace {
const char kNotifierId[] = "ash.gesture_education";
const char kNotificationId[] = "chrome://gesture_education";
} // namespace
GestureEducationNotificationController::
GestureEducationNotificationController() {
Shell::Get()->session_controller()->AddObserver(this);
chromeos::PowerManagerClient* power_manager_client =
chromeos::PowerManagerClient::Get();
power_manager_client->GetSwitchStates(base::BindOnce(
&GestureEducationNotificationController::OnReceivedSwitchStates,
weak_ptr_factory_.GetWeakPtr()));
}
GestureEducationNotificationController::
~GestureEducationNotificationController() {
Shell::Get()->session_controller()->RemoveObserver(this);
}
void GestureEducationNotificationController::OnActiveUserPrefServiceChanged(
PrefService* prefs) {
if (!tablet_mode_supported_ ||
prefs->GetBoolean(prefs::kGestureEducationNotificationShown)) {
return;
}
GenerateGestureEducationNotification();
prefs->SetBoolean(prefs::kGestureEducationNotificationShown, true);
}
void GestureEducationNotificationController::RegisterProfilePrefs(
PrefRegistrySimple* registry) {
registry->RegisterBooleanPref(prefs::kGestureEducationNotificationShown,
false);
}
void GestureEducationNotificationController::
GenerateGestureEducationNotification() {
std::unique_ptr<message_center::Notification> notification =
CreateSystemNotification(
message_center::NOTIFICATION_TYPE_SIMPLE, kNotifierId,
GetNotificationTitle(), GetNotificationMessage(),
base::string16() /* display_source */, GURL(),
message_center::NotifierId(
message_center::NotifierType::SYSTEM_COMPONENT, kNotificationId),
message_center::RichNotificationData(),
base::MakeRefCounted<message_center::HandleNotificationClickDelegate>(
base::BindRepeating(&GestureEducationNotificationController::
HandleNotificationClick,
weak_ptr_factory_.GetWeakPtr())),
vector_icons::kSettingsIcon,
message_center::SystemNotificationWarningLevel::NORMAL);
message_center::MessageCenter::Get()->AddNotification(
std::move(notification));
}
void GestureEducationNotificationController::HandleNotificationClick() {
Shell::Get()->system_tray_model()->client()->ShowHelp();
}
base::string16 GestureEducationNotificationController::GetNotificationMessage()
const {
base::string16 system_app_name =
l10n_util::GetStringUTF16(IDS_ASH_MESSAGE_CENTER_SYSTEM_APP_NAME);
base::string16 update_text;
update_text = l10n_util::GetStringFUTF16(
IDS_GESTURE_NOTIFICATION_MESSAGE_LEARN_MORE, system_app_name);
return update_text;
}
base::string16 GestureEducationNotificationController::GetNotificationTitle()
const {
return l10n_util::GetStringUTF16(IDS_GESTURE_NOTIFICATION_TITLE);
}
void GestureEducationNotificationController::OnReceivedSwitchStates(
base::Optional<chromeos::PowerManagerClient::SwitchStates> switch_states) {
if (switch_states.has_value() &&
switch_states->tablet_mode !=
chromeos::PowerManagerClient::TabletMode::UNSUPPORTED) {
tablet_mode_supported_ = true;
}
}
} // namespace ash
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_SYSTEM_GESTURE_EDUCATION_GESTURE_EDUCATION_NOTIFICATION_CONTROLLER_H_
#define ASH_SYSTEM_GESTURE_EDUCATION_GESTURE_EDUCATION_NOTIFICATION_CONTROLLER_H_
#include "ash/ash_export.h"
#include "ash/session/session_observer.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/optional.h"
#include "base/strings/string16.h"
#include "chromeos/dbus/power/power_manager_client.h"
class PrefRegistrySimple;
namespace ash {
// Controller class to manage gesture education notification. This notification
// shows up once to provide the user with information about new gestures added
// to chrome os for easier navigation.
class ASH_EXPORT GestureEducationNotificationController
: public SessionObserver {
public:
GestureEducationNotificationController();
~GestureEducationNotificationController() override;
// SessionObserver:
void OnActiveUserPrefServiceChanged(PrefService* pref_service) override;
// See Shell::RegisterProfilePrefs().
static void RegisterProfilePrefs(PrefRegistrySimple* registry);
private:
void GenerateGestureEducationNotification();
base::string16 GetNotificationTitle() const;
base::string16 GetNotificationMessage() const;
void HandleNotificationClick();
void OnReceivedSwitchStates(
base::Optional<chromeos::PowerManagerClient::SwitchStates> switch_states);
bool tablet_mode_supported_ = false;
base::WeakPtrFactory<GestureEducationNotificationController>
weak_ptr_factory_{this};
};
} // namespace ash
#endif // ASH_SYSTEM_GESTURE_EDUCATION_GESTURE_EDUCATION_NOTIFICATION_CONTROLLER_H_
......@@ -6,6 +6,7 @@
#include "ash/system/caps_lock_notification_controller.h"
#include "ash/system/cast/cast_notification_controller.h"
#include "ash/system/gesture_education/gesture_education_notification_controller.h"
#include "ash/system/network/auto_connect_notifier.h"
#include "ash/system/network/wifi_toggle_notification_controller.h"
#include "ash/system/power/power_notification_controller.h"
......@@ -22,6 +23,8 @@ SystemNotificationController::SystemNotificationController()
: auto_connect_(std::make_unique<AutoConnectNotifier>()),
caps_lock_(std::make_unique<CapsLockNotificationController>()),
cast_(std::make_unique<CastNotificationController>()),
gesture_education_(
std::make_unique<GestureEducationNotificationController>()),
power_(std::make_unique<PowerNotificationController>(
message_center::MessageCenter::Get())),
screen_security_(
......
......@@ -14,6 +14,7 @@ namespace ash {
class AutoConnectNotifier;
class AutoConnectNotifierTest;
class CapsLockNotificationController;
class GestureEducationNotificationController;
class CastNotificationController;
class PowerNotificationController;
class ScreenSecurityNotificationController;
......@@ -35,6 +36,8 @@ class SystemNotificationController {
const std::unique_ptr<AutoConnectNotifier> auto_connect_;
const std::unique_ptr<CapsLockNotificationController> caps_lock_;
const std::unique_ptr<CastNotificationController> cast_;
const std::unique_ptr<GestureEducationNotificationController>
gesture_education_;
const std::unique_ptr<PowerNotificationController> power_;
const std::unique_ptr<ScreenSecurityNotificationController> screen_security_;
const std::unique_ptr<SessionLimitNotificationController> session_limit_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment