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

Side by Side Diff: ui/message_center/views/notification_view.cc

Issue 2954373002: Make the control buttons on a notification always show on non Chrome OS platform. (Closed)
Patch Set: Created 3 years, 5 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
« no previous file with comments | « ui/arc/notification/arc_custom_notification_view.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 209
210 // Put together the different content and control views. Layering those allows 210 // Put together the different content and control views. Layering those allows
211 // for proper layout logic and it also allows the close button and small 211 // for proper layout logic and it also allows the close button and small
212 // image to overlap the content as needed to provide large enough click and 212 // image to overlap the content as needed to provide large enough click and
213 // touch areas (<http://crbug.com/168822> and <http://crbug.com/168856>). 213 // touch areas (<http://crbug.com/168822> and <http://crbug.com/168856>).
214 AddChildView(small_image_view_.get()); 214 AddChildView(small_image_view_.get());
215 CreateOrUpdateCloseButtonView(notification); 215 CreateOrUpdateCloseButtonView(notification);
216 216
217 SetEventTargeter( 217 SetEventTargeter(
218 std::unique_ptr<views::ViewTargeter>(new views::ViewTargeter(this))); 218 std::unique_ptr<views::ViewTargeter>(new views::ViewTargeter(this)));
219 set_notify_enter_exit_on_child(true);
219 } 220 }
220 221
221 NotificationView::~NotificationView() { 222 NotificationView::~NotificationView() {
222 } 223 }
223 224
224 gfx::Size NotificationView::CalculatePreferredSize() const { 225 gfx::Size NotificationView::CalculatePreferredSize() const {
225 int top_width = top_view_->GetPreferredSize().width() + 226 int top_width = top_view_->GetPreferredSize().width() +
226 icon_view_->GetPreferredSize().width(); 227 icon_view_->GetPreferredSize().width();
227 int bottom_width = bottom_view_->GetPreferredSize().width(); 228 int bottom_width = bottom_view_->GetPreferredSize().width();
228 int preferred_width = std::max(top_width, bottom_width) + GetInsets().width(); 229 int preferred_width = std::max(top_width, bottom_width) + GetInsets().width();
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 IDS_MESSAGE_CENTER_CLOSE_NOTIFICATION_BUTTON_TOOLTIP)); 703 IDS_MESSAGE_CENTER_CLOSE_NOTIFICATION_BUTTON_TOOLTIP));
703 close_button_->set_owned_by_client(); 704 close_button_->set_owned_by_client();
704 AddChildView(close_button_.get()); 705 AddChildView(close_button_.get());
705 UpdateControlButtonsVisibility(); 706 UpdateControlButtonsVisibility();
706 } else if (notification.pinned() && close_button_) { 707 } else if (notification.pinned() && close_button_) {
707 close_button_.reset(); 708 close_button_.reset();
708 } 709 }
709 } 710 }
710 711
711 void NotificationView::UpdateControlButtonsVisibility() { 712 void NotificationView::UpdateControlButtonsVisibility() {
713 #if defined(OS_CHROMEOS)
714 // On Chrome OS, the settings button and the close button are shown only when
715 // the mouse is hovering on the notification.
712 const bool target_visibility = 716 const bool target_visibility =
713 IsMouseHovered() || HasFocus() || 717 IsMouseHovered() || HasFocus() ||
714 (close_button_ && close_button_->HasFocus()) || 718 (close_button_ &&
715 (settings_button_view_ && settings_button_view_->HasFocus()); 719 (close_button_->HasFocus() || close_button_->IsMouseHovered())) ||
720 (settings_button_view_ && (settings_button_view_->HasFocus() ||
721 settings_button_view_->IsMouseHovered()));
722 #else
723 // On non Chrome OS, the settings button and the close button are always
724 // shown.
725 const bool target_visibility = true;
726 #endif
716 727
717 if (close_button_) { 728 if (close_button_) {
718 if (target_visibility != close_button_->visible()) 729 if (target_visibility != close_button_->visible())
719 close_button_->SetVisible(target_visibility); 730 close_button_->SetVisible(target_visibility);
720 } 731 }
721 732
722 if (settings_button_view_) { 733 if (settings_button_view_) {
723 if (target_visibility != settings_button_view_->visible()) 734 if (target_visibility != settings_button_view_->visible())
724 settings_button_view_->SetVisible(target_visibility); 735 settings_button_view_->SetVisible(target_visibility);
725 } 736 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 771
761 return message_line_limit; 772 return message_line_limit;
762 } 773 }
763 774
764 int NotificationView::GetMessageHeight(int width, int limit) const { 775 int NotificationView::GetMessageHeight(int width, int limit) const {
765 return message_view_ ? 776 return message_view_ ?
766 message_view_->GetSizeForWidthAndLines(width, limit).height() : 0; 777 message_view_->GetSizeForWidthAndLines(width, limit).height() : 0;
767 } 778 }
768 779
769 } // namespace message_center 780 } // namespace message_center
OLDNEW
« no previous file with comments | « ui/arc/notification/arc_custom_notification_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698