Chromium Code Reviews| Index: ash/system/chromeos/tray_display.cc |
| diff --git a/ash/system/chromeos/tray_display.cc b/ash/system/chromeos/tray_display.cc |
| index ebafa37158f4c88df647ca5fbf3b7ef3507ba0fa..f8f25f0783b0c6d01ae0d39ccb8f39a140375f97 100644 |
| --- a/ash/system/chromeos/tray_display.cc |
| +++ b/ash/system/chromeos/tray_display.cc |
| @@ -326,21 +326,30 @@ TrayDisplay::TrayDisplay(SystemTray* system_tray) |
| : SystemTrayItem(system_tray), |
| default_(NULL) { |
| Shell::GetInstance()->display_controller()->AddObserver(this); |
| + UpdateDisplayInfo(NULL); |
| } |
| TrayDisplay::~TrayDisplay() { |
| Shell::GetInstance()->display_controller()->RemoveObserver(this); |
| } |
| -bool TrayDisplay::GetDisplayMessageForNotification(base::string16* message) { |
| +void TrayDisplay::UpdateDisplayInfo(TrayDisplay::DisplayInfoMap* old_info) { |
| + if (old_info) { |
| + old_info->clear(); |
| + old_info->swap(display_info_); |
| + } else { |
| + display_info_.clear(); |
| + } |
|
stevenjb
2013/08/12 21:52:07
Isn't this the same as:
if (old_info)
old_info-
Jun Mukai
2013/08/12 22:07:49
good catch. fixed as you suggested.
|
| + |
| DisplayManager* display_manager = GetDisplayManager(); |
| - DisplayInfoMap old_info; |
| - old_info.swap(display_info_); |
| for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) { |
| int64 id = display_manager->GetDisplayAt(i).id(); |
| display_info_[id] = display_manager->GetDisplayInfo(id); |
| } |
| +} |
| +bool TrayDisplay::GetDisplayMessageForNotification( |
| + base::string16* message, const TrayDisplay::DisplayInfoMap& old_info) { |
|
stevenjb
2013/08/12 21:52:07
one arg per line
Jun Mukai
2013/08/12 22:07:49
Done.
|
| // Display is added or removed. Use the same message as the one in |
| // the system tray. |
| if (display_info_.size() != old_info.size()) { |
| @@ -405,13 +414,16 @@ void TrayDisplay::DestroyDefaultView() { |
| } |
| void TrayDisplay::OnDisplayConfigurationChanged() { |
| + DisplayInfoMap old_info; |
| + UpdateDisplayInfo(&old_info); |
| + |
| if (!Shell::GetInstance()->system_tray_delegate()-> |
| ShouldShowDisplayNotification()) { |
| return; |
| } |
| base::string16 message; |
| - if (GetDisplayMessageForNotification(&message)) |
| + if (GetDisplayMessageForNotification(&message, old_info)) |
| UpdateDisplayNotification(message); |
| } |