electron/shell/browser/ui/autofill_popup.h
Charles Kerr e70ce89235
chore: more iwyu (#43063)
* chore: iwyu shell/browser/electron_pdf_document_helper_client.h

* chore: iwyu shell/browser/hid/electron_hid_delegate.h

* chore: iwyu content/public/browser/web_contents.h

* chore: iwyu shell/browser/usb/electron_usb_delegate.h

* chore: iwyu shell/browser/browser_observer.h

* chore: iwyu shell/browser/bluetooth/electron_bluetooth_delegate.h

* chore: iwyu shell/browser/serial/electron_serial_delegate.h

* chore: iwyu shell/browser/api/frame_subscriber.h

* chore: iwyu mojo/public/cpp/bindings/

* chore: iwyu components/

* chore: iwyu extensions/

* chore: iwyu shell/common/gin_helper/

* chore: iwyu v8/

* chore: iwyu base/containers/linked_list.h

* chore: iwyu shell/browser/native_window.h

* chore: iwyu shell/browser/api/electron_api_base_window.h

* chore: iwyu shell/common/node_includes.h

* chore: iwyu gin/handle.h

* chore: iwyu base/functional/callback.h

* chore: iwyu ui/gfx/

* chore: iwyu content/public/browser/render_frame_host.h

* fix: mac

* fix: mac

* fix: win

* chore: iwyu base/files/file_path.h

* chore: iwyu base/unguessable_token.h

* chore: iwyu ui/display/screen.h

* chore: iwyu chrome/browser/predictors/preconnect_manager.h

* chore: iwyu base/observer_list_types.h

* chore: iwyu content/public/browser/web_contents.h

* chore: iwyu chrome/browser/devtools/devtools_eye_dropper.h

* chore: iwyu shell/browser/ui/inspectable_web_contents.h

* chore: iwyu content/public/browser/keyboard_event_processing_result.h

* chore: iwyu net/cookies/canonical_cookie.h

* chore: iwyu net/base/address_list.h

* chore: iwyu net/cert/x509_certificate.h

* chore: iwyu net/cookies/cookie_change_dispatcher.h

* chore: iwyu net/dns/public/host_resolver_results.h

* fix: mac

* Revert "chore: iwyu net/cert/x509_certificate.h"

This reverts commit 002896f71146e90f1e29e090a1d6eede48cee11e.
2024-07-29 12:42:57 -05:00

100 lines
2.8 KiB
C++

// 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 ELECTRON_SHELL_BROWSER_UI_AUTOFILL_POPUP_H_
#define ELECTRON_SHELL_BROWSER_UI_AUTOFILL_POPUP_H_
#include <vector>
#include "base/memory/raw_ptr.h"
#include "shell/browser/ui/views/autofill_popup_view.h"
#include "ui/gfx/font_list.h"
#include "ui/views/view.h"
#include "ui/views/widget/widget.h"
namespace content {
class RenderFrameHost;
} // namespace content
namespace ui {
using ColorId = int;
} // namespace ui
namespace electron {
class AutofillPopupView;
class AutofillPopup : private views::ViewObserver {
public:
AutofillPopup();
~AutofillPopup() override;
// disable copy
AutofillPopup(const AutofillPopup&) = delete;
AutofillPopup& operator=(const AutofillPopup&) = delete;
void CreateView(content::RenderFrameHost* render_frame,
content::RenderFrameHost* embedder_frame,
bool offscreen,
views::View* parent,
const gfx::RectF& bounds);
void Hide();
void SetItems(const std::vector<std::u16string>& values,
const std::vector<std::u16string>& labels);
void UpdatePopupBounds();
gfx::Rect popup_bounds_in_view();
private:
friend class AutofillPopupView;
// views::ViewObserver:
void OnViewBoundsChanged(views::View* view) override;
void OnViewIsDeleting(views::View* view) override;
void AcceptSuggestion(int index);
int GetDesiredPopupHeight();
int GetDesiredPopupWidth();
gfx::Rect GetRowBounds(int i);
const gfx::FontList& GetValueFontListForRow(int index) const;
const gfx::FontList& GetLabelFontListForRow(int index) const;
ui::ColorId GetBackgroundColorIDForRow(int index) const;
int line_count() const { return values_.size(); }
const std::u16string& value_at(int i) const { return values_.at(i); }
const std::u16string& label_at(int i) const { return labels_.at(i); }
int LineFromY(int y) const;
int selected_index_;
// Popup location
gfx::Rect popup_bounds_;
// Bounds of the autofilled element
gfx::Rect element_bounds_;
// Datalist suggestions
std::vector<std::u16string> values_;
std::vector<std::u16string> labels_;
// Font lists for the suggestions
gfx::FontList smaller_font_list_;
gfx::FontList bold_font_list_;
// For sending the accepted suggestion to the render frame that
// asked to open the popup
raw_ptr<content::RenderFrameHost> frame_host_ = nullptr;
// The popup view. The lifetime is managed by the owning Widget
raw_ptr<AutofillPopupView> view_ = nullptr;
// The parent view that the popup view shows on. Weak ref.
raw_ptr<views::View> parent_ = nullptr;
};
} // namespace electron
#endif // ELECTRON_SHELL_BROWSER_UI_AUTOFILL_POPUP_H_