blob: a75b0d6d064fd02465449352e0b10d4331769ec1 [file] [log] [blame]
// 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 CHROME_BROWSER_UI_VIEWS_AUTOFILL_AUTOFILL_POPUP_VIEW_VIEWS_H_
#define CHROME_BROWSER_UI_VIEWS_AUTOFILL_AUTOFILL_POPUP_VIEW_VIEWS_H_
#include <stddef.h>
#include "base/macros.h"
#include "base/optional.h"
#include "chrome/browser/ui/autofill/autofill_popup_view.h"
#include "chrome/browser/ui/views/autofill/autofill_popup_base_view.h"
#include "ui/views/controls/scroll_view.h"
namespace autofill {
class AutofillPopupController;
namespace {
class AutofillPopupChildView;
}
// Views toolkit implementation for AutofillPopupView.
class AutofillPopupViewViews : public AutofillPopupBaseView,
public AutofillPopupView {
public:
// |controller| should not be null.
AutofillPopupViewViews(AutofillPopupController* controller,
views::Widget* parent_widget);
~AutofillPopupViewViews() override;
private:
FRIEND_TEST_ALL_PREFIXES(AutofillPopupViewViewsTest, OnSelectedRowChanged);
// AutofillPopupView implementation.
void Show() override;
void Hide() override;
void OnSelectedRowChanged(base::Optional<int> previous_row_selection,
base::Optional<int> current_row_selection) override;
void OnSuggestionsChanged() override;
// views::Views implementation
void OnPaint(gfx::Canvas* canvas) override;
// AutofillPopupBaseView implementation
void AddExtraInitParams(views::Widget::InitParams* params) override;
std::unique_ptr<views::View> CreateWrapperView() override;
std::unique_ptr<views::Border> CreateBorder() override;
void SetClipPath() override;
void DoUpdateBoundsAndRedrawPopup() override;
// Draw the given autofill entry in |entry_rect|.
void DrawAutofillEntry(gfx::Canvas* canvas,
int index,
const gfx::Rect& entry_rect);
// Creates child views based on the suggestions given by |controller_|. These
// child views are used for accessibility events only. We need child views to
// populate the correct |AXNodeData| when user selects a suggestion.
void CreateChildViews();
AutofillPopupChildView* GetChildRow(size_t child_index) const;
AutofillPopupController* controller_; // Weak reference.
views::ScrollView* scroll_view_;
DISALLOW_COPY_AND_ASSIGN(AutofillPopupViewViews);
};
} // namespace autofill
#endif // CHROME_BROWSER_UI_VIEWS_AUTOFILL_AUTOFILL_POPUP_VIEW_VIEWS_H_