autofill_popup.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 {
  16. public:
  17. explicit AutofillPopup(gfx::NativeView);
  18. ~AutofillPopup();
  19. void CreateView(content::RenderFrameHost* render_frame,
  20. bool offscreen, views::Widget* widget, const gfx::RectF& bounds);
  21. void Hide();
  22. void SetItems(const std::vector<base::string16>& values,
  23. const std::vector<base::string16>& labels);
  24. void UpdatePopupBounds(int height_compensation);
  25. private:
  26. friend class AutofillPopupView;
  27. void AcceptSuggestion(int index);
  28. int GetDesiredPopupHeight();
  29. int GetDesiredPopupWidth();
  30. gfx::Rect GetRowBounds(int i);
  31. const gfx::FontList& GetValueFontListForRow(int index) const;
  32. const gfx::FontList& GetLabelFontListForRow(int index) const;
  33. ui::NativeTheme::ColorId GetBackgroundColorIDForRow(int index) const;
  34. int GetLineCount();
  35. base::string16 GetValueAt(int i);
  36. base::string16 GetLabelAt(int i);
  37. int LineFromY(int y) const;
  38. // The native view that contains this
  39. gfx::NativeView container_view_;
  40. int selected_index_;
  41. // Popup location
  42. gfx::Rect popup_bounds_;
  43. gfx::Rect popup_bounds_in_view_;
  44. // Bounds of the autofilled element
  45. gfx::Rect element_bounds_;
  46. // Datalist suggestions
  47. std::vector<base::string16> values_;
  48. std::vector<base::string16> labels_;
  49. // Font lists for the suggestions
  50. gfx::FontList smaller_font_list_;
  51. gfx::FontList bold_font_list_;
  52. // For sending the accepted suggestion to the render frame that
  53. // asked to open the popup
  54. content::RenderFrameHost* frame_host_;
  55. // The popup view. The lifetime is managed by the owning Widget
  56. AutofillPopupView* view_;
  57. DISALLOW_COPY_AND_ASSIGN(AutofillPopup);
  58. };
  59. } // namespace atom
  60. #endif // ATOM_BROWSER_UI_AUTOFILL_POPUP_H_