Chromium Code Reviews| Index: ui/message_center/views/message_view.cc |
| diff --git a/ui/message_center/views/message_view.cc b/ui/message_center/views/message_view.cc |
| index 622b18a5899f2be6e03ecc3d3168b8e240be02a2..1b38931de3f235575431bb5d11f6f5fe14a01773 100644 |
| --- a/ui/message_center/views/message_view.cc |
| +++ b/ui/message_center/views/message_view.cc |
| @@ -4,6 +4,7 @@ |
| #include "ui/message_center/views/message_view.h" |
| +#include "base/strings/utf_string_conversions.h" |
| #include "ui/accessibility/ax_view_state.h" |
| #include "ui/base/l10n/l10n_util.h" |
| #include "ui/base/models/simple_menu_model.h" |
| @@ -32,6 +33,28 @@ constexpr int kCloseIconRightPadding = 5; |
| constexpr int kShadowOffset = 1; |
| constexpr int kShadowBlur = 4; |
| +// Creates a text for spoken feedback from the data contained |
| +// in the notification. |
|
yoshiki
2016/09/07 08:57:46
nit: could you move "in the" to the first line in
yhanada
2016/09/07 09:08:03
Done.
|
| +base::string16 CreateAccessibleName( |
| + const message_center::Notification& notification) { |
| + if (!notification.accessible_name().empty()) |
| + return notification.accessible_name(); |
| + |
| + // Fall back to a text constructed from the notification. |
| + std::vector<base::string16> accessible_lines; |
| + accessible_lines.push_back(notification.title()); |
| + accessible_lines.push_back(notification.message()); |
| + accessible_lines.push_back(notification.context_message()); |
| + std::vector<message_center::NotificationItem> items = notification.items(); |
| + for (size_t i = 0; |
| + i < items.size() && i < message_center::kNotificationMaximumItems; |
| + ++i) { |
| + accessible_lines.push_back(items[i].title + base::ASCIIToUTF16(" ") + |
| + items[i].message); |
| + } |
| + return base::JoinString(accessible_lines, base::ASCIIToUTF16("\n")); |
| +} |
| + |
| } // namespace |
| namespace message_center { |
| @@ -60,6 +83,8 @@ MessageView::MessageView(MessageCenterController* controller, |
| focus_painter_ = views::Painter::CreateSolidFocusPainter( |
| kFocusBorderColor, gfx::Insets(0, 1, 3, 2)); |
| + |
| + accessible_name_ = CreateAccessibleName(notification); |
| } |
| MessageView::~MessageView() { |
| @@ -69,6 +94,7 @@ void MessageView::UpdateWithNotification(const Notification& notification) { |
| small_image_view_->SetImage(notification.small_image().AsImageSkia()); |
| display_source_ = notification.display_source(); |
| CreateOrUpdateCloseButtonView(notification); |
| + accessible_name_ = CreateAccessibleName(notification); |
| } |
| // static |