Commit 463378c6 authored by Tatsuhisa Yamaguchi's avatar Tatsuhisa Yamaguchi Committed by Commit Bot

Avoid flashing of notification counter for bundled notifications.

This is reland of crrev.com/c/1295633 with some fix.

When ARC++ app builds bundled notifications, multiple individual
notifications are sent and then replaced with a single bundled
notification. The indicator icon showed such update as-is, resulting
in flashing. This change limits the frequency to reflect notification
count updates for avoiding such effect.

Bug: 892021
Change-Id: If7dbfdfdc530d3498f271f9b7b15b2d02b6b216d
Reviewed-on: https://chromium-review.googlesource.com/c/1298829Reviewed-by: default avatarYoshiki Iguchi <yoshiki@chromium.org>
Commit-Queue: Tatsuhisa Yamaguchi <yamaguchi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#603001}
parent abe18aa1
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
#include "ash/system/unified/unified_slider_bubble_controller.h" #include "ash/system/unified/unified_slider_bubble_controller.h"
#include "ash/system/unified/unified_system_tray_bubble.h" #include "ash/system/unified/unified_system_tray_bubble.h"
#include "ash/system/unified/unified_system_tray_model.h" #include "ash/system/unified/unified_system_tray_model.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
#include "chromeos/network/network_handler.h" #include "chromeos/network/network_handler.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/display/display.h" #include "ui/display/display.h"
...@@ -65,6 +67,9 @@ class UnifiedSystemTray::UiDelegate : public MessageCenterUiDelegate { ...@@ -65,6 +67,9 @@ class UnifiedSystemTray::UiDelegate : public MessageCenterUiDelegate {
DISALLOW_COPY_AND_ASSIGN(UiDelegate); DISALLOW_COPY_AND_ASSIGN(UiDelegate);
}; };
const base::TimeDelta UnifiedSystemTray::kNotificationCountUpdateDelay =
base::TimeDelta::FromMilliseconds(100);
UnifiedSystemTray::UiDelegate::UiDelegate(UnifiedSystemTray* owner) UnifiedSystemTray::UiDelegate::UiDelegate(UnifiedSystemTray* owner)
: owner_(owner) { : owner_(owner) {
ui_controller_ = std::make_unique<MessageCenterUiController>(this); ui_controller_ = std::make_unique<MessageCenterUiController>(this);
...@@ -327,6 +332,16 @@ void UnifiedSystemTray::HideBubbleInternal() { ...@@ -327,6 +332,16 @@ void UnifiedSystemTray::HideBubbleInternal() {
} }
void UnifiedSystemTray::UpdateNotificationInternal() { void UnifiedSystemTray::UpdateNotificationInternal() {
// Limit update frequency in order to avoid flashing when 2 updates are
// incoming in a very short period of time. It happens when ARC++ apps
// creating bundled notifications.
if (!timer_.IsRunning()) {
timer_.Start(FROM_HERE, kNotificationCountUpdateDelay, this,
&UnifiedSystemTray::UpdateNotificationAfterDelay);
}
}
void UnifiedSystemTray::UpdateNotificationAfterDelay() {
notification_counter_item_->Update(); notification_counter_item_->Update();
quiet_mode_view_->Update(); quiet_mode_view_->Update();
} }
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
#include "ash/ash_export.h" #include "ash/ash_export.h"
#include "ash/system/tray/tray_background_view.h" #include "ash/system/tray/tray_background_view.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
namespace ash { namespace ash {
...@@ -97,6 +99,8 @@ class ASH_EXPORT UnifiedSystemTray : public TrayBackgroundView { ...@@ -97,6 +99,8 @@ class ASH_EXPORT UnifiedSystemTray : public TrayBackgroundView {
UnifiedSystemTrayModel* model() { return model_.get(); } UnifiedSystemTrayModel* model() { return model_.get(); }
private: private:
const static base::TimeDelta kNotificationCountUpdateDelay;
friend class UnifiedSystemTrayTest; friend class UnifiedSystemTrayTest;
friend class UnifiedSystemTrayTestApi; friend class UnifiedSystemTrayTestApi;
...@@ -110,6 +114,7 @@ class ASH_EXPORT UnifiedSystemTray : public TrayBackgroundView { ...@@ -110,6 +114,7 @@ class ASH_EXPORT UnifiedSystemTray : public TrayBackgroundView {
void ShowBubbleInternal(bool show_by_click); void ShowBubbleInternal(bool show_by_click);
void HideBubbleInternal(); void HideBubbleInternal();
void UpdateNotificationInternal(); void UpdateNotificationInternal();
void UpdateNotificationAfterDelay();
const std::unique_ptr<UiDelegate> ui_delegate_; const std::unique_ptr<UiDelegate> ui_delegate_;
...@@ -130,6 +135,7 @@ class ASH_EXPORT UnifiedSystemTray : public TrayBackgroundView { ...@@ -130,6 +135,7 @@ class ASH_EXPORT UnifiedSystemTray : public TrayBackgroundView {
tray::TimeTrayItemView* const time_view_; tray::TimeTrayItemView* const time_view_;
ui::Layer* ink_drop_layer_ = nullptr; ui::Layer* ink_drop_layer_ = nullptr;
base::OneShotTimer timer_;
DISALLOW_COPY_AND_ASSIGN(UnifiedSystemTray); DISALLOW_COPY_AND_ASSIGN(UnifiedSystemTray);
}; };
......
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