Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef CHROME_BROWSER_UI_VIEWS_SUBTLE_NOTIFICATION_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_SUBTLE_NOTIFICATION_VIEW_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_SUBTLE_NOTIFICATION_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_SUBTLE_NOTIFICATION_VIEW_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
| 10 #include "ui/gfx/native_widget_types.h" | 10 #include "ui/gfx/native_widget_types.h" |
| 11 #include "ui/views/view.h" | 11 #include "ui/views/view.h" |
| 12 #include "ui/views/widget/widget_observer.h" | |
| 13 | |
| 14 namespace ui { | |
| 15 struct AXViewState; | |
| 16 } | |
| 12 | 17 |
| 13 namespace views { | 18 namespace views { |
| 14 class Link; | 19 class Link; |
| 15 class LinkListener; | 20 class LinkListener; |
| 16 class Widget; | 21 class Widget; |
| 17 } | 22 } |
| 18 | 23 |
| 19 // A transient, transparent notification bubble that appears at the top of the | 24 // A transient, transparent notification bubble that appears at the top of the |
| 20 // browser window to give the user a short instruction (e.g., "Press Esc to exit | 25 // browser window to give the user a short instruction (e.g., "Press Esc to exit |
| 21 // full screen"). Unlike a full notification, a subtle notification | 26 // full screen"). Unlike a full notification, a subtle notification |
| 22 // auto-dismisses after a short period of time. It also has special | 27 // auto-dismisses after a short period of time. It also has special |
| 23 // functionality for displaying keyboard shortcuts (rendering the keys inside a | 28 // functionality for displaying keyboard shortcuts (rendering the keys inside a |
| 24 // rounded rectangle). | 29 // rounded rectangle). |
| 25 class SubtleNotificationView : public views::View { | 30 class SubtleNotificationView : public views::View, |
| 31 public views::WidgetObserver { | |
| 26 public: | 32 public: |
| 27 explicit SubtleNotificationView(views::LinkListener* link_listener); | 33 explicit SubtleNotificationView(views::LinkListener* link_listener); |
| 28 ~SubtleNotificationView() override; | 34 ~SubtleNotificationView() override; |
| 29 | 35 |
| 30 void UpdateContent(const base::string16& instruction_text, | 36 void UpdateContent(const base::string16& instruction_text, |
| 31 const base::string16& link_text); | 37 const base::string16& link_text); |
| 32 | 38 |
| 33 // Creates a Widget containing a SubtleNotificationView. If |accept_events|, | 39 // Creates a Widget containing a SubtleNotificationView. If |accept_events|, |
| 34 // the bubble will intercept mouse events (required if there is a clickable | 40 // the bubble will intercept mouse events (required if there is a clickable |
| 35 // link); if not, events will go through to the underlying window. | 41 // link); if not, events will go through to the underlying window. |
| 36 static views::Widget* CreatePopupWidget(gfx::NativeView parent_view, | 42 static views::Widget* CreatePopupWidget(gfx::NativeView parent_view, |
| 37 SubtleNotificationView* view, | 43 SubtleNotificationView* view, |
| 38 bool accept_events); | 44 bool accept_events); |
| 39 | 45 |
| 46 // The accessible text for screenreaders to announce on displaying this | |
| 47 // notification, which should have unicode characters expanded. | |
| 48 base::string16 accessible_name() const { return accessible_name_; } | |
|
tapted
2016/07/12 00:51:40
This might not be needed - see if you can update a
Patti Lor
2016/07/19 01:31:51
Done.
| |
| 49 void SetAccessibleName(const base::string16& accessible_name); | |
| 50 | |
| 51 // views::View: | |
| 52 void GetAccessibleState(ui::AXViewState* state) override; | |
| 53 | |
| 54 // views::WidgetObserver: | |
| 55 void OnWidgetClosing(views::Widget* widget) override; | |
| 56 void OnWidgetVisibilityChanged(views::Widget* widget, bool visible) override; | |
| 57 | |
| 40 private: | 58 private: |
| 41 class InstructionView; | 59 class InstructionView; |
| 42 | 60 |
| 43 // Text displayed in the bubble, with optional keyboard keys. | 61 // Text displayed in the bubble, with optional keyboard keys. |
| 44 InstructionView* instruction_view_; | 62 InstructionView* instruction_view_; |
| 45 // Clickable text link. If there is also an instruction view, this appears | 63 // Clickable text link. If there is also an instruction view, this appears |
| 46 // after the instruction text. | 64 // after the instruction text. |
| 47 views::Link* link_; | 65 views::Link* link_; |
| 48 | 66 |
| 67 base::string16 accessible_name_; | |
| 68 | |
| 49 DISALLOW_COPY_AND_ASSIGN(SubtleNotificationView); | 69 DISALLOW_COPY_AND_ASSIGN(SubtleNotificationView); |
| 50 }; | 70 }; |
| 51 | 71 |
| 52 #endif // CHROME_BROWSER_UI_VIEWS_SUBTLE_NOTIFICATION_VIEW_H_ | 72 #endif // CHROME_BROWSER_UI_VIEWS_SUBTLE_NOTIFICATION_VIEW_H_ |
| OLD | NEW |