Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(508)

Side by Side Diff: ash/system/chromeos/tray_display.cc

Issue 22908004: Updates the list of display info in TrayDisplay even if notification is prevented. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/system/chromeos/tray_display.h" 5 #include "ash/system/chromeos/tray_display.h"
6 6
7 #include "ash/display/display_controller.h" 7 #include "ash/display/display_controller.h"
8 #include "ash/display/display_manager.h" 8 #include "ash/display/display_manager.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/system/tray/actionable_view.h" 10 #include "ash/system/tray/actionable_view.h"
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 private: 319 private:
320 user::LoginStatus login_status_; 320 user::LoginStatus login_status_;
321 321
322 DISALLOW_COPY_AND_ASSIGN(DisplayNotificationView); 322 DISALLOW_COPY_AND_ASSIGN(DisplayNotificationView);
323 }; 323 };
324 324
325 TrayDisplay::TrayDisplay(SystemTray* system_tray) 325 TrayDisplay::TrayDisplay(SystemTray* system_tray)
326 : SystemTrayItem(system_tray), 326 : SystemTrayItem(system_tray),
327 default_(NULL) { 327 default_(NULL) {
328 Shell::GetInstance()->display_controller()->AddObserver(this); 328 Shell::GetInstance()->display_controller()->AddObserver(this);
329 UpdateDisplayInfo(NULL);
329 } 330 }
330 331
331 TrayDisplay::~TrayDisplay() { 332 TrayDisplay::~TrayDisplay() {
332 Shell::GetInstance()->display_controller()->RemoveObserver(this); 333 Shell::GetInstance()->display_controller()->RemoveObserver(this);
333 } 334 }
334 335
335 bool TrayDisplay::GetDisplayMessageForNotification(base::string16* message) { 336 void TrayDisplay::UpdateDisplayInfo(TrayDisplay::DisplayInfoMap* old_info) {
337 if (old_info) {
338 old_info->clear();
339 old_info->swap(display_info_);
340 } else {
341 display_info_.clear();
342 }
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.
343
336 DisplayManager* display_manager = GetDisplayManager(); 344 DisplayManager* display_manager = GetDisplayManager();
337 DisplayInfoMap old_info;
338 old_info.swap(display_info_);
339 for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) { 345 for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) {
340 int64 id = display_manager->GetDisplayAt(i).id(); 346 int64 id = display_manager->GetDisplayAt(i).id();
341 display_info_[id] = display_manager->GetDisplayInfo(id); 347 display_info_[id] = display_manager->GetDisplayInfo(id);
342 } 348 }
349 }
343 350
351 bool TrayDisplay::GetDisplayMessageForNotification(
352 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.
344 // Display is added or removed. Use the same message as the one in 353 // Display is added or removed. Use the same message as the one in
345 // the system tray. 354 // the system tray.
346 if (display_info_.size() != old_info.size()) { 355 if (display_info_.size() != old_info.size()) {
347 *message = GetTrayDisplayMessage(); 356 *message = GetTrayDisplayMessage();
348 return true; 357 return true;
349 } 358 }
350 359
351 for (DisplayInfoMap::const_iterator iter = display_info_.begin(); 360 for (DisplayInfoMap::const_iterator iter = display_info_.begin();
352 iter != display_info_.end(); ++iter) { 361 iter != display_info_.end(); ++iter) {
353 DisplayInfoMap::const_iterator old_iter = old_info.find(iter->first); 362 DisplayInfoMap::const_iterator old_iter = old_info.find(iter->first);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 DCHECK(default_ == NULL); 407 DCHECK(default_ == NULL);
399 default_ = new DisplayView(status); 408 default_ = new DisplayView(status);
400 return default_; 409 return default_;
401 } 410 }
402 411
403 void TrayDisplay::DestroyDefaultView() { 412 void TrayDisplay::DestroyDefaultView() {
404 default_ = NULL; 413 default_ = NULL;
405 } 414 }
406 415
407 void TrayDisplay::OnDisplayConfigurationChanged() { 416 void TrayDisplay::OnDisplayConfigurationChanged() {
417 DisplayInfoMap old_info;
418 UpdateDisplayInfo(&old_info);
419
408 if (!Shell::GetInstance()->system_tray_delegate()-> 420 if (!Shell::GetInstance()->system_tray_delegate()->
409 ShouldShowDisplayNotification()) { 421 ShouldShowDisplayNotification()) {
410 return; 422 return;
411 } 423 }
412 424
413 base::string16 message; 425 base::string16 message;
414 if (GetDisplayMessageForNotification(&message)) 426 if (GetDisplayMessageForNotification(&message, old_info))
415 UpdateDisplayNotification(message); 427 UpdateDisplayNotification(message);
416 } 428 }
417 429
418 base::string16 TrayDisplay::GetDefaultViewMessage() { 430 base::string16 TrayDisplay::GetDefaultViewMessage() {
419 if (!default_ || !default_->visible()) 431 if (!default_ || !default_->visible())
420 return base::string16(); 432 return base::string16();
421 433
422 return static_cast<DisplayView*>(default_)->label()->text(); 434 return static_cast<DisplayView*>(default_)->label()->text();
423 } 435 }
424 436
425 base::string16 TrayDisplay::GetNotificationMessage() { 437 base::string16 TrayDisplay::GetNotificationMessage() {
426 message_center::NotificationList::Notifications notifications = 438 message_center::NotificationList::Notifications notifications =
427 message_center::MessageCenter::Get()->GetNotifications(); 439 message_center::MessageCenter::Get()->GetNotifications();
428 for (message_center::NotificationList::Notifications::const_iterator iter = 440 for (message_center::NotificationList::Notifications::const_iterator iter =
429 notifications.begin(); iter != notifications.end(); ++iter) { 441 notifications.begin(); iter != notifications.end(); ++iter) {
430 if ((*iter)->id() == kDisplayNotificationId) 442 if ((*iter)->id() == kDisplayNotificationId)
431 return (*iter)->title(); 443 return (*iter)->title();
432 } 444 }
433 445
434 return base::string16(); 446 return base::string16();
435 } 447 }
436 448
437 void TrayDisplay::CloseNotificationForTest() { 449 void TrayDisplay::CloseNotificationForTest() {
438 message_center::MessageCenter::Get()->RemoveNotification( 450 message_center::MessageCenter::Get()->RemoveNotification(
439 kDisplayNotificationId, false); 451 kDisplayNotificationId, false);
440 } 452 }
441 453
442 } // namespace internal 454 } // namespace internal
443 } // namespace ash 455 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698