autofill_popup.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. content::RenderFrameHost* embedder_frame,
  21. bool offscreen,
  22. views::View* parent,
  23. const gfx::RectF& bounds);
  24. void Hide();
  25. void SetItems(const std::vector<base::string16>& values,
  26. const std::vector<base::string16>& labels);
  27. void UpdatePopupBounds();
  28. gfx::Rect popup_bounds_in_view();
  29. private:
  30. friend class AutofillPopupView;
  31. // views::ViewObserver:
  32. void OnViewBoundsChanged(views::View* view) override;
  33. void OnViewIsDeleting(views::View* view) override;
  34. void AcceptSuggestion(int index);
  35. int GetDesiredPopupHeight();
  36. int GetDesiredPopupWidth();
  37. gfx::Rect GetRowBounds(int i);
  38. const gfx::FontList& GetValueFontListForRow(int index) const;
  39. const gfx::FontList& GetLabelFontListForRow(int index) const;
  40. ui::NativeTheme::ColorId GetBackgroundColorIDForRow(int index) const;
  41. int GetLineCount();
  42. base::string16 GetValueAt(int i);
  43. base::string16 GetLabelAt(int i);
  44. int LineFromY(int y) const;
  45. int selected_index_;
  46. // Popup location
  47. gfx::Rect popup_bounds_;
  48. // Bounds of the autofilled element
  49. gfx::Rect element_bounds_;
  50. // Datalist suggestions
  51. std::vector<base::string16> values_;
  52. std::vector<base::string16> labels_;
  53. // Font lists for the suggestions
  54. gfx::FontList smaller_font_list_;
  55. gfx::FontList bold_font_list_;
  56. // For sending the accepted suggestion to the render frame that
  57. // asked to open the popup
  58. content::RenderFrameHost* frame_host_ = nullptr;
  59. // The popup view. The lifetime is managed by the owning Widget
  60. AutofillPopupView* view_ = nullptr;
  61. // The parent view that the popup view shows on. Weak ref.
  62. views::View* parent_ = nullptr;
  63. DISALLOW_COPY_AND_ASSIGN(AutofillPopup);
  64. };
  65. } // namespace atom
  66. #endif // ATOM_BROWSER_UI_AUTOFILL_POPUP_H_