1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
// Copyright 2015 The Chromium Authors
// 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_PAYMENTS_SAVE_CARD_BUBBLE_VIEWS_H_
#define CHROME_BROWSER_UI_VIEWS_AUTOFILL_PAYMENTS_SAVE_CARD_BUBBLE_VIEWS_H_
#include <memory>
#include "base/memory/raw_ptr.h"
#include "chrome/browser/ui/autofill/autofill_bubble_base.h"
#include "chrome/browser/ui/autofill/payments/save_card_bubble_controller.h"
#include "chrome/browser/ui/views/autofill/autofill_location_bar_bubble.h"
#include "components/signin/public/base/signin_metrics.h"
#include "ui/base/metadata/metadata_header_macros.h"
namespace content {
class WebContents;
}
namespace autofill {
// This class serves as a base view to any of the bubble views that are part of
// the flow for when the user submits a form with a credit card number that
// Autofill has not previously saved. The base view establishes the button
// handlers, the calculated size, the Super G logo, testing methods, and the
// window title (controller eventually handles the title for each sub-class).
class SaveCardBubbleViews : public AutofillLocationBarBubble {
METADATA_HEADER(SaveCardBubbleViews, AutofillLocationBarBubble)
public:
// Bubble will be anchored to |anchor_view|.
SaveCardBubbleViews(views::View* anchor_view,
content::WebContents* web_contents,
SaveCardBubbleController* controller);
SaveCardBubbleViews(const SaveCardBubbleViews&) = delete;
SaveCardBubbleViews& operator=(const SaveCardBubbleViews&) = delete;
void Show(DisplayReason reason);
// AutofillBubbleBase:
void Hide() override;
// LocationBarBubbleDelegateView:
void OnBeforeBubbleWidgetInit(views::Widget::InitParams* params,
views::Widget* widget) const override;
void AddedToWidget() override;
std::u16string GetWindowTitle() const override;
void WindowClosing() override;
// Returns the footnote view, so it can be searched for clickable views.
// Exists for testing (specifically, browsertests).
views::View* GetFootnoteViewForTesting();
const std::u16string GetCardIdentifierString() const;
protected:
// Create the dialog's content view containing everything except for the
// footnote.
virtual std::unique_ptr<views::View> CreateMainContentView();
// Called by sub-classes to initialize |footnote_view_|.
virtual void InitFootnoteView(views::View* footnote_view);
SaveCardBubbleController* controller() const { return controller_; }
// Attributes IDs to the dialog's DialogDelegate-supplied buttons.
void AssignIdsToDialogButtons();
// LocationBarBubbleDelegateView:
void Init() override;
void OnDialogAccepted();
~SaveCardBubbleViews() override;
private:
friend class SaveCardBubbleViewsFullFormBrowserTest;
std::unique_ptr<views::View> GetCardIdentifierView();
raw_ptr<views::View> footnote_view_ = nullptr;
raw_ptr<SaveCardBubbleController> controller_; // Weak reference.
};
} // namespace autofill
#endif // CHROME_BROWSER_UI_VIEWS_AUTOFILL_PAYMENTS_SAVE_CARD_BUBBLE_VIEWS_H_
|