electron/atom/browser/ui/autofill_popup.h

92 lines
2.5 KiB
C
Raw Normal View History

2017-05-19 19:35:13 +00:00
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ATOM_BROWSER_UI_AUTOFILL_POPUP_H_
#define ATOM_BROWSER_UI_AUTOFILL_POPUP_H_
2017-05-19 19:52:18 +00:00
#include <vector>
2017-05-19 19:35:13 +00:00
#include "atom/browser/ui/views/autofill_popup_view.h"
#include "content/public/browser/render_frame_host.h"
2017-05-19 19:35:13 +00:00
#include "ui/gfx/font_list.h"
#include "ui/native_theme/native_theme.h"
#include "ui/views/view.h"
2017-11-02 23:42:30 +00:00
#include "ui/views/widget/widget.h"
2017-05-19 19:35:13 +00:00
namespace atom {
class AutofillPopupView;
2017-05-19 19:52:18 +00:00
class AutofillPopup : public views::ViewObserver {
2017-05-19 19:35:13 +00:00
public:
AutofillPopup();
~AutofillPopup() override;
2017-05-19 19:35:13 +00:00
void CreateView(content::RenderFrameHost* render_frame,
content::RenderFrameHost* embedder_frame,
bool offscreen,
views::View* parent,
const gfx::RectF& bounds);
2017-05-19 19:35:13 +00:00
void Hide();
2017-05-19 19:52:18 +00:00
2017-05-19 19:35:13 +00:00
void SetItems(const std::vector<base::string16>& values,
const std::vector<base::string16>& labels);
void UpdatePopupBounds();
2017-05-19 19:52:18 +00:00
2018-05-15 01:59:22 +00:00
gfx::Rect popup_bounds_in_view();
2017-05-19 19:35:13 +00:00
private:
friend class AutofillPopupView;
2017-05-19 19:52:18 +00:00
// views::ViewObserver:
void OnViewBoundsChanged(views::View* view) override;
void OnViewIsDeleting(views::View* view) override;
2017-05-19 19:35:13 +00:00
void AcceptSuggestion(int index);
2017-05-19 19:52:18 +00:00
2017-05-19 19:35:13 +00:00
int GetDesiredPopupHeight();
int GetDesiredPopupWidth();
gfx::Rect GetRowBounds(int i);
const gfx::FontList& GetValueFontListForRow(int index) const;
const gfx::FontList& GetLabelFontListForRow(int index) const;
ui::NativeTheme::ColorId GetBackgroundColorIDForRow(int index) const;
2017-05-19 19:52:18 +00:00
2017-05-19 19:35:13 +00:00
int GetLineCount();
base::string16 GetValueAt(int i);
base::string16 GetLabelAt(int i);
int LineFromY(int y) const;
2017-05-19 19:52:18 +00:00
2017-05-19 19:35:13 +00:00
int selected_index_;
2017-05-19 19:52:18 +00:00
2017-05-19 19:35:13 +00:00
// Popup location
gfx::Rect popup_bounds_;
2017-05-19 19:52:18 +00:00
2017-05-19 19:35:13 +00:00
// Bounds of the autofilled element
gfx::Rect element_bounds_;
2017-05-19 19:52:18 +00:00
2017-05-19 19:35:13 +00:00
// Datalist suggestions
std::vector<base::string16> values_;
std::vector<base::string16> labels_;
2017-05-19 19:52:18 +00:00
2017-05-19 19:35:13 +00:00
// Font lists for the suggestions
gfx::FontList smaller_font_list_;
gfx::FontList bold_font_list_;
2017-05-19 19:52:18 +00:00
// For sending the accepted suggestion to the render frame that
2017-05-19 19:35:13 +00:00
// asked to open the popup
content::RenderFrameHost* frame_host_ = nullptr;
2017-05-19 19:52:18 +00:00
// The popup view. The lifetime is managed by the owning Widget
AutofillPopupView* view_ = nullptr;
// The parent view that the popup view shows on. Weak ref.
views::View* parent_ = nullptr;
2017-05-19 19:35:13 +00:00
DISALLOW_COPY_AND_ASSIGN(AutofillPopup);
};
} // namespace atom
2017-05-19 19:52:18 +00:00
#endif // ATOM_BROWSER_UI_AUTOFILL_POPUP_H_