| OLD | NEW |
| 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 "ui/message_center/views/notification_view.h" | 5 #include "ui/message_center/views/notification_view.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 IDS_MESSAGE_CENTER_CLOSE_NOTIFICATION_BUTTON_TOOLTIP)); | 701 IDS_MESSAGE_CENTER_CLOSE_NOTIFICATION_BUTTON_TOOLTIP)); |
| 702 close_button_->set_owned_by_client(); | 702 close_button_->set_owned_by_client(); |
| 703 AddChildView(close_button_.get()); | 703 AddChildView(close_button_.get()); |
| 704 UpdateControlButtonsVisibility(); | 704 UpdateControlButtonsVisibility(); |
| 705 } else if (notification.pinned() && close_button_) { | 705 } else if (notification.pinned() && close_button_) { |
| 706 close_button_.reset(); | 706 close_button_.reset(); |
| 707 } | 707 } |
| 708 } | 708 } |
| 709 | 709 |
| 710 void NotificationView::UpdateControlButtonsVisibility() { | 710 void NotificationView::UpdateControlButtonsVisibility() { |
| 711 const bool target_visibility = | 711 const bool target_visibility = IsMouseHovered() || HasFocusedView(); |
| 712 IsMouseHovered() || HasFocus() || | |
| 713 (close_button_ && close_button_->HasFocus()) || | |
| 714 (settings_button_view_ && settings_button_view_->HasFocus()); | |
| 715 | 712 |
| 716 if (close_button_) { | 713 if (close_button_) { |
| 717 if (target_visibility != close_button_->visible()) | 714 if (target_visibility != close_button_->visible()) |
| 718 close_button_->SetVisible(target_visibility); | 715 close_button_->SetVisible(target_visibility); |
| 719 } | 716 } |
| 720 | 717 |
| 721 if (settings_button_view_) { | 718 if (settings_button_view_) { |
| 722 if (target_visibility != settings_button_view_->visible()) | 719 if (target_visibility != settings_button_view_->visible()) |
| 723 settings_button_view_->SetVisible(target_visibility); | 720 settings_button_view_->SetVisible(target_visibility); |
| 724 } | 721 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 758 std::max(0, message_line_limit - line_reduction_from_title); | 755 std::max(0, message_line_limit - line_reduction_from_title); |
| 759 | 756 |
| 760 return message_line_limit; | 757 return message_line_limit; |
| 761 } | 758 } |
| 762 | 759 |
| 763 int NotificationView::GetMessageHeight(int width, int limit) const { | 760 int NotificationView::GetMessageHeight(int width, int limit) const { |
| 764 return message_view_ ? | 761 return message_view_ ? |
| 765 message_view_->GetSizeForWidthAndLines(width, limit).height() : 0; | 762 message_view_->GetSizeForWidthAndLines(width, limit).height() : 0; |
| 766 } | 763 } |
| 767 | 764 |
| 765 bool NotificationView::HasFocusedView() { |
| 766 const views::FocusManager* focus_manager = GetFocusManager(); |
| 767 return focus_manager && Contains(focus_manager->GetFocusedView()); |
| 768 } |
| 769 |
| 768 } // namespace message_center | 770 } // namespace message_center |
| OLD | NEW |