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

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

Issue 2318463002: arc: Make ChromeVox read an ARC custom notification (Closed)
Patch Set: rebase 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..18b8df445bc9e666d8d700a18b0c77a4f943ea54 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.
+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;
dcheng 2016/09/07 22:15:02 It might be slightly more readable to use an initi
yhanada 2016/09/08 03:37:23 Done.
+ 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

Powered by Google App Engine
This is Rietveld 408576698