subtle_notification_view.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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
  3. // found in the LICENSE file.
  4. #ifndef COMPONENTS_FULLSCREEN_CONTROL_SUBTLE_NOTIFICATION_VIEW_H_
  5. #define COMPONENTS_FULLSCREEN_CONTROL_SUBTLE_NOTIFICATION_VIEW_H_
  6. #include <memory>
  7. #include <string>
  8. #include <vector>
  9. #include "base/memory/raw_ptr.h"
  10. #include "ui/base/metadata/metadata_header_macros.h"
  11. #include "ui/gfx/native_widget_types.h"
  12. #include "ui/views/controls/image_view.h"
  13. #include "ui/views/view.h"
  14. namespace views {
  15. class Widget;
  16. }
  17. // A transient, transparent notification bubble that appears at the top of the
  18. // browser window to give the user a short instruction (e.g., "Press Esc to exit
  19. // full screen"). Unlike a full notification, a subtle notification
  20. // auto-dismisses after a short period of time. It also has special
  21. // functionality for displaying keyboard shortcuts (rendering the keys inside a
  22. // rounded rectangle).
  23. class SubtleNotificationView : public views::View {
  24. public:
  25. METADATA_HEADER(SubtleNotificationView);
  26. SubtleNotificationView();
  27. SubtleNotificationView(const SubtleNotificationView&) = delete;
  28. SubtleNotificationView& operator=(const SubtleNotificationView&) = delete;
  29. ~SubtleNotificationView() override;
  30. // Display the |instruction_text| to the user. If |instruction_text| is
  31. // empty hide the view.
  32. void UpdateContent(const std::u16string& instruction_text);
  33. // Display the |instruction_text| to the user, with the |key_images| inside
  34. // the rectangles that represent keys. |key_images| must either be empty, or
  35. // the same length as the number of text segments inside pipe characters.
  36. //
  37. // If |instruction_text| is empty hide the view.
  38. void UpdateContent(const std::u16string& instruction_text,
  39. std::vector<std::unique_ptr<views::View>> key_images);
  40. // Creates a Widget containing a SubtleNotificationView.
  41. static views::Widget* CreatePopupWidget(
  42. gfx::NativeView parent_view,
  43. std::unique_ptr<SubtleNotificationView> view);
  44. // views::View
  45. void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
  46. private:
  47. class InstructionView;
  48. // Text displayed in the bubble, with optional keyboard keys.
  49. raw_ptr<InstructionView> instruction_view_;
  50. };
  51. #endif // COMPONENTS_FULLSCREEN_CONTROL_SUBTLE_NOTIFICATION_VIEW_H_