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