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/message_view.h" | 5 #include "ui/message_center/views/message_view.h" |
6 | 6 |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "ui/accessibility/ax_node_data.h" | 8 #include "ui/accessibility/ax_node_data.h" |
9 #include "ui/base/l10n/l10n_util.h" | 9 #include "ui/base/l10n/l10n_util.h" |
10 #include "ui/base/models/simple_menu_model.h" | 10 #include "ui/base/models/simple_menu_model.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 } | 57 } |
58 | 58 |
59 } // namespace | 59 } // namespace |
60 | 60 |
61 namespace message_center { | 61 namespace message_center { |
62 | 62 |
63 MessageView::MessageView(MessageCenterController* controller, | 63 MessageView::MessageView(MessageCenterController* controller, |
64 const Notification& notification) | 64 const Notification& notification) |
65 : controller_(controller), | 65 : controller_(controller), |
66 notification_id_(notification.id()), | 66 notification_id_(notification.id()), |
67 notifier_id_(notification.notifier_id()), | 67 notifier_id_(notification.notifier_id()) { |
68 display_source_(notification.display_source()) { | |
69 SetFocusBehavior(FocusBehavior::ALWAYS); | 68 SetFocusBehavior(FocusBehavior::ALWAYS); |
70 | 69 |
71 // Create the opaque background that's above the view's shadow. | 70 // Create the opaque background that's above the view's shadow. |
72 background_view_ = new views::View(); | 71 background_view_ = new views::View(); |
73 background_view_->set_background( | 72 background_view_->set_background( |
74 views::Background::CreateSolidBackground(kNotificationBackgroundColor)); | 73 views::Background::CreateSolidBackground(kNotificationBackgroundColor)); |
75 AddChildView(background_view_); | 74 AddChildView(background_view_); |
76 | 75 |
77 views::ImageView* small_image_view = new views::ImageView(); | 76 views::ImageView* small_image_view = new views::ImageView(); |
78 small_image_view->SetImage(notification.small_image().AsImageSkia()); | |
79 small_image_view->SetImageSize(gfx::Size(kSmallImageSize, kSmallImageSize)); | 77 small_image_view->SetImageSize(gfx::Size(kSmallImageSize, kSmallImageSize)); |
80 // The small image view should be added to view hierarchy by the derived | 78 // The small image view should be added to view hierarchy by the derived |
81 // class. This ensures that it is on top of other views. | 79 // class. This ensures that it is on top of other views. |
82 small_image_view->set_owned_by_client(); | 80 small_image_view->set_owned_by_client(); |
83 small_image_view_.reset(small_image_view); | 81 small_image_view_.reset(small_image_view); |
84 | 82 |
85 focus_painter_ = views::Painter::CreateSolidFocusPainter( | 83 focus_painter_ = views::Painter::CreateSolidFocusPainter( |
86 kFocusBorderColor, gfx::Insets(0, 1, 3, 2)); | 84 kFocusBorderColor, gfx::Insets(0, 1, 3, 2)); |
87 | 85 |
88 accessible_name_ = CreateAccessibleName(notification); | 86 UpdateWithNotification(notification); |
89 } | 87 } |
90 | 88 |
91 MessageView::~MessageView() { | 89 MessageView::~MessageView() { |
92 } | 90 } |
93 | 91 |
94 void MessageView::UpdateWithNotification(const Notification& notification) { | 92 void MessageView::UpdateWithNotification(const Notification& notification) { |
95 small_image_view_->SetImage(notification.small_image().AsImageSkia()); | 93 small_image_view_->SetImage(notification.small_image().AsImageSkia()); |
96 display_source_ = notification.display_source(); | 94 display_source_ = notification.display_source(); |
97 accessible_name_ = CreateAccessibleName(notification); | 95 accessible_name_ = CreateAccessibleName(notification); |
| 96 set_slide_out_enabled(!notification.pinned()); |
98 } | 97 } |
99 | 98 |
100 // static | 99 // static |
101 gfx::Insets MessageView::GetShadowInsets() { | 100 gfx::Insets MessageView::GetShadowInsets() { |
102 return -gfx::ShadowValue::GetMargin( | 101 return -gfx::ShadowValue::GetMargin( |
103 gfx::ShadowDetails::Get(kShadowElevation, kShadowCornerRadius).values); | 102 gfx::ShadowDetails::Get(kShadowElevation, kShadowCornerRadius).values); |
104 } | 103 } |
105 | 104 |
106 void MessageView::CreateShadowBorder() { | 105 void MessageView::CreateShadowBorder() { |
107 const auto& shadow = | 106 const auto& shadow = |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 } | 234 } |
236 | 235 |
237 void MessageView::SetDrawBackgroundAsActive(bool active) { | 236 void MessageView::SetDrawBackgroundAsActive(bool active) { |
238 background_view_->background()-> | 237 background_view_->background()-> |
239 SetNativeControlColor(active ? kHoveredButtonBackgroundColor : | 238 SetNativeControlColor(active ? kHoveredButtonBackgroundColor : |
240 kNotificationBackgroundColor); | 239 kNotificationBackgroundColor); |
241 SchedulePaint(); | 240 SchedulePaint(); |
242 } | 241 } |
243 | 242 |
244 } // namespace message_center | 243 } // namespace message_center |
OLD | NEW |