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

Side by Side 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 unified diff | Download patch
OLDNEW
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 "ui/accessibility/ax_view_state.h" 8 #include "ui/accessibility/ax_view_state.h"
8 #include "ui/base/l10n/l10n_util.h" 9 #include "ui/base/l10n/l10n_util.h"
9 #include "ui/base/models/simple_menu_model.h" 10 #include "ui/base/models/simple_menu_model.h"
10 #include "ui/compositor/scoped_layer_animation_settings.h" 11 #include "ui/compositor/scoped_layer_animation_settings.h"
11 #include "ui/gfx/canvas.h" 12 #include "ui/gfx/canvas.h"
12 #include "ui/gfx/shadow_value.h" 13 #include "ui/gfx/shadow_value.h"
13 #include "ui/message_center/message_center.h" 14 #include "ui/message_center/message_center.h"
14 #include "ui/message_center/message_center_style.h" 15 #include "ui/message_center/message_center_style.h"
15 #include "ui/message_center/views/message_center_controller.h" 16 #include "ui/message_center/views/message_center_controller.h"
16 #include "ui/message_center/views/padded_button.h" 17 #include "ui/message_center/views/padded_button.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 views::ImageView* small_image_view = new views::ImageView(); 54 views::ImageView* small_image_view = new views::ImageView();
54 small_image_view->SetImage(notification.small_image().AsImageSkia()); 55 small_image_view->SetImage(notification.small_image().AsImageSkia());
55 small_image_view->SetImageSize(gfx::Size(kSmallImageSize, kSmallImageSize)); 56 small_image_view->SetImageSize(gfx::Size(kSmallImageSize, kSmallImageSize));
56 // The small image view should be added to view hierarchy by the derived 57 // The small image view should be added to view hierarchy by the derived
57 // class. This ensures that it is on top of other views. 58 // class. This ensures that it is on top of other views.
58 small_image_view->set_owned_by_client(); 59 small_image_view->set_owned_by_client();
59 small_image_view_.reset(small_image_view); 60 small_image_view_.reset(small_image_view);
60 61
61 focus_painter_ = views::Painter::CreateSolidFocusPainter( 62 focus_painter_ = views::Painter::CreateSolidFocusPainter(
62 kFocusBorderColor, gfx::Insets(0, 1, 3, 2)); 63 kFocusBorderColor, gfx::Insets(0, 1, 3, 2));
64
65 accessible_name_ = CreateAccessibleName(notification);
63 } 66 }
64 67
65 MessageView::~MessageView() { 68 MessageView::~MessageView() {
66 } 69 }
67 70
68 void MessageView::UpdateWithNotification(const Notification& notification) { 71 void MessageView::UpdateWithNotification(const Notification& notification) {
69 small_image_view_->SetImage(notification.small_image().AsImageSkia()); 72 small_image_view_->SetImage(notification.small_image().AsImageSkia());
70 display_source_ = notification.display_source(); 73 display_source_ = notification.display_source();
71 CreateOrUpdateCloseButtonView(notification); 74 CreateOrUpdateCloseButtonView(notification);
75 accessible_name_ = CreateAccessibleName(notification);
72 } 76 }
73 77
74 // static 78 // static
75 gfx::Insets MessageView::GetShadowInsets() { 79 gfx::Insets MessageView::GetShadowInsets() {
76 return gfx::Insets(kShadowBlur / 2 - kShadowOffset, 80 return gfx::Insets(kShadowBlur / 2 - kShadowOffset,
77 kShadowBlur / 2, 81 kShadowBlur / 2,
78 kShadowBlur / 2 + kShadowOffset, 82 kShadowBlur / 2 + kShadowOffset,
79 kShadowBlur / 2); 83 kShadowBlur / 2);
80 } 84 }
81 85
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 close->SetAccessibleName(l10n_util::GetStringUTF16( 257 close->SetAccessibleName(l10n_util::GetStringUTF16(
254 IDS_MESSAGE_CENTER_CLOSE_NOTIFICATION_BUTTON_ACCESSIBLE_NAME)); 258 IDS_MESSAGE_CENTER_CLOSE_NOTIFICATION_BUTTON_ACCESSIBLE_NAME));
255 close->set_owned_by_client(); 259 close->set_owned_by_client();
256 AddChildView(close); 260 AddChildView(close);
257 close_button_.reset(close); 261 close_button_.reset(close);
258 } else if (notification.pinned() && close_button_) { 262 } else if (notification.pinned() && close_button_) {
259 close_button_.reset(); 263 close_button_.reset();
260 } 264 }
261 } 265 }
262 266
267 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.
268 const Notification& notification) {
269 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.
270 return notification.accessible_name();
271 }
272
273 // Fall back to a text constructed from the notification.
274 std::vector<base::string16> accessible_lines;
275 accessible_lines.push_back(notification.title());
276 accessible_lines.push_back(notification.message());
277 accessible_lines.push_back(notification.context_message());
278 std::vector<NotificationItem> items = notification.items();
279 for (size_t i = 0; i < items.size() && i < kNotificationMaximumItems; ++i) {
280 accessible_lines.push_back(items[i].title + base::ASCIIToUTF16(" ") +
281 items[i].message);
282 }
283 return base::JoinString(accessible_lines, base::ASCIIToUTF16("\n"));
284 }
285
263 } // namespace message_center 286 } // namespace message_center
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698