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

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

Issue 2318463002: arc: Make ChromeVox read an ARC custom notification (Closed)
Patch Set: remove unused field and include 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
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..eb38b640f0576c3eab749d4cfd926147da400d9d 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"
@@ -60,6 +61,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 +72,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
@@ -260,4 +264,23 @@ void MessageView::CreateOrUpdateCloseButtonView(
}
}
+base::string16 MessageView::CreateAccessibleName(
yoshiki 2016/09/07 08:29:34 Could you make this method non-member of the Messa
yhanada 2016/09/07 08:52:26 Done.
+ const Notification& notification) {
+ if (!notification.accessible_name().empty()) {
yoshiki 2016/09/07 08:29:34 nit: no need of the braces for one line body.
yhanada 2016/09/07 08:52:26 Done.
+ 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<NotificationItem> items = notification.items();
+ for (size_t i = 0; i < items.size() && i < kNotificationMaximumItems; ++i) {
+ accessible_lines.push_back(items[i].title + base::ASCIIToUTF16(" ") +
+ items[i].message);
+ }
+ return base::JoinString(accessible_lines, base::ASCIIToUTF16("\n"));
+}
+
} // namespace message_center

Powered by Google App Engine
This is Rietveld 408576698