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

Unified Diff: ui/message_center/views/message_view.cc

Issue 2318463002: arc: Make ChromeVox read an ARC custom notification (Closed)
Patch Set: rebase and cleanup Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/message_center/views/message_view.h ('k') | ui/message_center/views/notification_view.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..14b1a9e4b37a7ab9332b02283c1c0e24db9407f2 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,27 @@ 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.
+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 = {
+ notification.title(), notification.message(),
+ 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 +82,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 +93,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
« no previous file with comments | « ui/message_center/views/message_view.h ('k') | ui/message_center/views/notification_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698