Chromium Code Reviews| Index: chrome/browser/ui/views/subtle_notification_view.cc |
| diff --git a/chrome/browser/ui/views/subtle_notification_view.cc b/chrome/browser/ui/views/subtle_notification_view.cc |
| index 8d42713d9d59bbfab42d6ea49c257883f5927e4d..7fcc97d37bdf95825a5a90fdee718cbc0c6514ff 100644 |
| --- a/chrome/browser/ui/views/subtle_notification_view.cc |
| +++ b/chrome/browser/ui/views/subtle_notification_view.cc |
| @@ -7,8 +7,10 @@ |
| #include <memory> |
| #include "base/strings/string_split.h" |
| +#include "base/strings/string_util.h" |
| #include "base/strings/utf_string_conversions.h" |
| #include "third_party/skia/include/core/SkColor.h" |
| +#include "ui/accessibility/ax_view_state.h" |
| #include "ui/base/resource/resource_bundle.h" |
| #include "ui/gfx/font_list.h" |
| #include "ui/views/bubble/bubble_border.h" |
| @@ -34,6 +36,9 @@ const int kKeyNameBorderPx = 1; |
| const int kKeyNameCornerRadius = 2; |
| const int kKeyNamePaddingPx = 5; |
| +// Delimiter indicating there should be a segment displayed as a keyboard key. |
| +const char kKeyNameDelimiter[] = "|"; |
| + |
| } // namespace |
| // Class containing the instruction text. Contains fancy styling on the keyboard |
| @@ -41,14 +46,16 @@ const int kKeyNamePaddingPx = 5; |
| class SubtleNotificationView::InstructionView : public views::View { |
| public: |
| // Creates an InstructionView with specific text. |text| may contain one or |
| - // more segments delimited by a pair of pipes ('|'); each of these segments |
| - // will be displayed as a keyboard key. e.g., "Press |Alt|+|Q| to exit" will |
| - // have "Alt" and "Q" rendered as keys. |
| + // more segments delimited by |kKeyNameDelimiter|; each of these segments |
|
Matt Giuca
2016/06/24 04:21:12
I don't think this comment change is necessary. ("
Patti Lor
2016/06/27 05:10:39
Done.
|
| + // will be displayed as a keyboard key. e.g. if |kKeyNameDelimiter| is set to |
| + // a pipe ('|'), "Press |Alt|+|Q| to exit" will have "Alt" and "Q" rendered as |
| + // keys. |
| InstructionView(const base::string16& text, |
| const gfx::FontList& font_list, |
| SkColor foreground_color, |
| SkColor background_color); |
| + base::string16 text() { return text_; } |
| void SetText(const base::string16& text); |
| private: |
| @@ -92,8 +99,8 @@ void SubtleNotificationView::InstructionView::SetText( |
| // Parse |text|, looking for pipe-delimited segment. |
| std::vector<base::string16> segments = |
| - base::SplitString(text, base::ASCIIToUTF16("|"), base::TRIM_WHITESPACE, |
| - base::SPLIT_WANT_ALL); |
| + base::SplitString(text, base::ASCIIToUTF16(kKeyNameDelimiter), |
| + base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| // SplitString() returns empty strings for zero-length segments, so given an |
| // even number of pipes, there should always be an odd number of segments. |
| // The exception is if |text| is entirely empty, in which case the returned |
| @@ -208,3 +215,9 @@ views::Widget* SubtleNotificationView::CreatePopupWidget( |
| return popup; |
| } |
| + |
| +void SubtleNotificationView::GetAccessibleState(ui::AXViewState* state) { |
| + state->role = ui::AX_ROLE_LABEL_TEXT; |
| + base::RemoveChars(instruction_view_->text(), |
| + base::ASCIIToUTF16(kKeyNameDelimiter), &state->name); |
| +} |