privacy_info_view.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. // Copyright 2019 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 ASH_APP_LIST_VIEWS_PRIVACY_INFO_VIEW_H_
  5. #define ASH_APP_LIST_VIEWS_PRIVACY_INFO_VIEW_H_
  6. #include "ash/app_list/views/search_result_base_view.h"
  7. #include "ui/views/controls/styled_label.h"
  8. #include "ui/views/view.h"
  9. namespace views {
  10. class Button;
  11. class ImageButton;
  12. class ImageView;
  13. class Link;
  14. class StyledLabel;
  15. } // namespace views
  16. namespace ash {
  17. // View representing privacy info in Launcher.
  18. class PrivacyInfoView : public SearchResultBaseView {
  19. public:
  20. PrivacyInfoView(const PrivacyInfoView&) = delete;
  21. PrivacyInfoView& operator=(const PrivacyInfoView&) = delete;
  22. ~PrivacyInfoView() override;
  23. // views::View:
  24. gfx::Size CalculatePreferredSize() const override;
  25. int GetHeightForWidth(int width) const override;
  26. void OnPaintBackground(gfx::Canvas* canvas) override;
  27. void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
  28. // ui::EventHandler:
  29. void OnMouseEvent(ui::MouseEvent* event) override;
  30. void OnGestureEvent(ui::GestureEvent* event) override;
  31. void OnKeyEvent(ui::KeyEvent* event) override;
  32. // SearchResultBaseView:
  33. void SelectInitialResultAction(bool reverse_tab_order) override;
  34. bool SelectNextResultAction(bool reverse_tab_order) override;
  35. views::View* GetSelectedView() override;
  36. virtual void LinkClicked() = 0;
  37. virtual void CloseButtonPressed() = 0;
  38. protected:
  39. PrivacyInfoView(int info_string_id, int link_string_id);
  40. private:
  41. enum class Action { kNone, kTextLink, kCloseButton };
  42. // Button pressed callback.
  43. void OnButtonPressed();
  44. void InitLayout();
  45. void InitInfoIcon();
  46. void InitText();
  47. void InitCloseButton();
  48. void UpdateLinkStyle();
  49. views::ImageView* info_icon_ = nullptr; // Owned by view hierarchy.
  50. views::StyledLabel* text_view_ = nullptr; // Owned by view hierarchy.
  51. views::ImageButton* close_button_ = nullptr; // Owned by view hierarchy.
  52. const int info_string_id_;
  53. const int link_string_id_;
  54. views::Link* link_view_ = nullptr; // Not owned.
  55. // Indicates which of the privacy notice's actions is selected for keyboard
  56. // navigation.
  57. Action selected_action_ = Action::kNone;
  58. };
  59. } // namespace ash
  60. #endif // ASH_APP_LIST_VIEWS_PRIVACY_INFO_VIEW_H_