Commit 0b50dab3 authored by Nancy Wang's avatar Nancy Wang Committed by Commit Bot

Rename UpdateAppBadging function to UpdateAppNotificationBadging

There are other app icon badgings, e.g. pause badge, block badge, the
current UpdateAppBadging is used to update the notification badging
only, so rename the related function names.

BUG=1144384

Change-Id: I7ec07dc7687bd55cb3566b423665cded9714b95d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2545336
Commit-Queue: Nancy Wang <nancylingwang@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#828832}
parent 7ab19b71
......@@ -505,7 +505,8 @@ void AppListControllerImpl::OnAppListItemAdded(AppListItem* item) {
// Update the notification badge indicator for the newly added app list
// item.
cache_->ForOneApp(item->id(), [item](const apps::AppUpdate& update) {
item->UpdateBadge(update.HasBadge() == apps::mojom::OptionalBool::kTrue);
item->UpdateNotificationBadge(update.HasBadge() ==
apps::mojom::OptionalBool::kTrue);
});
}
}
......@@ -518,7 +519,8 @@ void AppListControllerImpl::OnActiveUserPrefServiceChanged(
pref_change_registrar_->Add(
prefs::kAppNotificationBadgingEnabled,
base::BindRepeating(&AppListControllerImpl::UpdateAppBadging,
base::BindRepeating(
&AppListControllerImpl::UpdateAppNotificationBadging,
base::Unretained(this)));
// Observe AppRegistryCache for the current active account to get
......@@ -529,10 +531,11 @@ void AppListControllerImpl::OnActiveUserPrefServiceChanged(
apps::AppRegistryCacheWrapper::Get().GetAppRegistryCache(account_id);
Observe(cache_);
// Resetting the recorded pref forces the next call to UpdateAppBadging()
// to update notification badging for every app item.
// Resetting the recorded pref forces the next call to
// UpdateAppNotificationBadging() to update notification badging for every
// app item.
notification_badging_pref_enabled_.reset();
UpdateAppBadging();
UpdateAppNotificationBadging();
}
if (!IsTabletMode()) {
......@@ -1741,7 +1744,7 @@ void AppListControllerImpl::OnAppRegistryCacheWillBeDestroyed(
}
void AppListControllerImpl::OnQuietModeChanged(bool in_quiet_mode) {
UpdateAppBadging();
UpdateAppNotificationBadging();
}
void AppListControllerImpl::UpdateTrackedAppWindow() {
......@@ -1765,11 +1768,13 @@ void AppListControllerImpl::UpdateItemNotificationBadge(
const std::string& app_id,
apps::mojom::OptionalBool has_badge) {
AppListItem* item = model_->FindItem(app_id);
if (item)
item->UpdateBadge(has_badge == apps::mojom::OptionalBool::kTrue);
if (item) {
item->UpdateNotificationBadge(has_badge ==
apps::mojom::OptionalBool::kTrue);
}
}
void AppListControllerImpl::UpdateAppBadging() {
void AppListControllerImpl::UpdateAppNotificationBadging() {
bool new_badging_enabled = pref_change_registrar_
? pref_change_registrar_->prefs()->GetBoolean(
prefs::kAppNotificationBadgingEnabled)
......
......@@ -383,7 +383,7 @@ class ASH_EXPORT AppListControllerImpl
// Checks the notification badging pref and then updates whether a
// notification badge is shown for each AppListItem.
void UpdateAppBadging();
void UpdateAppNotificationBadging();
// Whether the home launcher is
// * being shown (either through an animation or a drag)
......
......@@ -90,7 +90,7 @@ void AppListItem::SetNameAndShortName(const std::string& name,
observer.ItemNameChanged();
}
void AppListItem::UpdateBadge(bool has_badge) {
void AppListItem::UpdateNotificationBadge(bool has_badge) {
if (has_notification_badge_ == has_badge)
return;
......
......@@ -86,7 +86,9 @@ class APP_LIST_MODEL_EXPORT AppListItem {
bool has_notification_badge() const { return has_notification_badge_; }
void UpdateBadgeForTesting(bool has_badge) { UpdateBadge(has_badge); }
void UpdateNotificationBadgeForTesting(bool has_badge) {
UpdateNotificationBadge(has_badge);
}
protected:
// Subclasses also have mutable access to the metadata ptr.
......@@ -109,7 +111,7 @@ class APP_LIST_MODEL_EXPORT AppListItem {
const std::string& short_name);
// Updates whether the notification badge is shown on the view.
void UpdateBadge(bool has_badge);
void UpdateNotificationBadge(bool has_badge);
void set_position(const syncer::StringOrdinal& new_position) {
DCHECK(new_position.IsValid());
......
......@@ -156,7 +156,7 @@ void ShelfController::OnActiveUserPrefServiceChanged(
if (is_notification_indicator_enabled_) {
pref_change_registrar_->Add(
prefs::kAppNotificationBadgingEnabled,
base::BindRepeating(&ShelfController::UpdateAppBadging,
base::BindRepeating(&ShelfController::UpdateAppNotificationBadging,
base::Unretained(this)));
// Observe AppRegistryCache for the current active account to get
......@@ -167,14 +167,15 @@ void ShelfController::OnActiveUserPrefServiceChanged(
apps::AppRegistryCacheWrapper::Get().GetAppRegistryCache(account_id);
Observe(cache_);
// Resetting the recorded pref forces the next call to UpdateAppBadging()
// to update notification badging for every app item.
// Resetting the recorded pref forces the next call to
// UpdateAppNotificationBadging() to update notification badging for every
// app item.
notification_badging_pref_enabled_.reset();
// Update the notification badge indicator for all apps. This will also
// ensure that apps have the correct notification badge value for the
// multiprofile case when switching between users.
UpdateAppBadging();
UpdateAppNotificationBadging();
}
}
......@@ -252,10 +253,10 @@ void ShelfController::ShelfItemAdded(int index) {
}
void ShelfController::OnQuietModeChanged(bool in_quiet_mode) {
UpdateAppBadging();
UpdateAppNotificationBadging();
}
void ShelfController::UpdateAppBadging() {
void ShelfController::UpdateAppNotificationBadging() {
bool new_badging_enabled = pref_change_registrar_
? pref_change_registrar_->prefs()->GetBoolean(
prefs::kAppNotificationBadgingEnabled)
......
......@@ -66,8 +66,9 @@ class ASH_EXPORT ShelfController
// message_center::MessageCenterObserver:
void OnQuietModeChanged(bool in_quiet_mode) override;
// Updates whether an app badge is shown for the shelf items in the model.
void UpdateAppBadging();
// Updates whether an app notification badge is shown for the shelf items in
// the model.
void UpdateAppNotificationBadging();
// The shelf model shared by all shelf instances.
ShelfModel model_;
......
......@@ -163,7 +163,7 @@ class NotificationSpokenFeedbackAppListTest : public SpokenFeedbackAppListTest {
auto* model = ash::Shell::Get()->app_list_controller()->GetModel();
auto* item = model->FindItem(id);
item->UpdateBadgeForTesting(has_badge);
item->UpdateNotificationBadgeForTesting(has_badge);
}
private:
......
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