autofill_popup.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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
  3. // found in the LICENSE file.
  4. #ifndef ATOM_BROWSER_UI_AUTOFILL_POPUP_H_
  5. #define ATOM_BROWSER_UI_AUTOFILL_POPUP_H_
  6. #include <vector>
  7. #include "atom/browser/ui/views/autofill_popup_view.h"
  8. #include "content/public/browser/render_frame_host.h"
  9. #include "ui/gfx/font_list.h"
  10. #include "ui/native_theme/native_theme.h"
  11. #include "ui/views/view.h"
  12. #include "ui/views/widget/widget.h"
  13. namespace atom {
  14. class AutofillPopupView;
  15. class AutofillPopup : public views::ViewObserver {
  16. public:
  17. AutofillPopup();
  18. ~AutofillPopup() override;
  19. void CreateView(content::RenderFrameHost* render_frame,
  20. bool offscreen,
  21. views::View* parent,
  22. const gfx::RectF& bounds);
  23. void Hide();
  24. void SetItems(const std::vector<base::string16>& values,
  25. const std::vector<base::string16>& labels);
  26. void UpdatePopupBounds();
  27. private:
  28. friend class AutofillPopupView;
  29. // views::ViewObserver:
  30. void OnViewBoundsChanged(views::View* view) override;
  31. void OnViewIsDeleting(views::View* view) override;
  32. void AcceptSuggestion(int index);
  33. int GetDesiredPopupHeight();
  34. int GetDesiredPopupWidth();
  35. gfx::Rect GetRowBounds(int i);
  36. const gfx::FontList& GetValueFontListForRow(int index) const;
  37. const gfx::FontList& GetLabelFontListForRow(int index) const;
  38. ui::NativeTheme::ColorId GetBackgroundColorIDForRow(int index) const;
  39. int GetLineCount();
  40. base::string16 GetValueAt(int i);
  41. base::string16 GetLabelAt(int i);
  42. int LineFromY(int y) const;
  43. int selected_index_;
  44. // Popup location
  45. gfx::Rect popup_bounds_;
  46. gfx::Rect popup_bounds_in_view_;
  47. // Bounds of the autofilled element
  48. gfx::Rect element_bounds_;
  49. // Datalist suggestions
  50. std::vector<base::string16> values_;
  51. std::vector<base::string16> labels_;
  52. // Font lists for the suggestions
  53. gfx::FontList smaller_font_list_;
  54. gfx::FontList bold_font_list_;
  55. // For sending the accepted suggestion to the render frame that
  56. // asked to open the popup
  57. content::RenderFrameHost* frame_host_ = nullptr;
  58. // The popup view. The lifetime is managed by the owning Widget
  59. AutofillPopupView* view_ = nullptr;
  60. // The parent view that the popup view shows on. Weak ref.
  61. views::View* parent_ = nullptr;
  62. DISALLOW_COPY_AND_ASSIGN(AutofillPopup);
  63. };
  64. } // namespace atom
  65. #endif // ATOM_BROWSER_UI_AUTOFILL_POPUP_H_