Add ICU message format support
[chromium-blink-merge.git] / chrome / browser / ui / autofill / autofill_dialog_view_delegate.h
blob375fb2bc34786414f48ea0ca186e3720ba9d8939
1 // Copyright 2013 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.
5 #ifndef CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_VIEW_DELEGATE_H_
6 #define CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_VIEW_DELEGATE_H_
8 #include <vector>
10 #include "base/strings/string16.h"
11 #include "chrome/browser/ui/autofill/autofill_dialog_types.h"
12 #include "components/autofill/content/browser/wallet/required_action.h"
13 #include "components/autofill/core/browser/detail_input.h"
14 #include "components/autofill/core/browser/dialog_section.h"
15 #include "components/autofill/core/browser/field_types.h"
16 #include "ui/base/ui_base_types.h"
17 #include "ui/gfx/image/image.h"
18 #include "ui/gfx/native_widget_types.h"
19 #include "ui/gfx/range/range.h"
21 class FieldValueMap;
22 class GURL;
23 class Profile;
25 namespace content {
26 class WebContents;
27 struct NativeWebKeyboardEvent;
30 namespace gfx {
31 class Rect;
34 namespace ui {
35 class ComboboxModel;
36 class MenuModel;
39 namespace autofill {
41 typedef std::map<ServerFieldType, gfx::Image> FieldIconMap;
43 // This class defines the interface to the controller that the dialog view sees.
44 class AutofillDialogViewDelegate {
45 public:
46 // Strings -------------------------------------------------------------------
48 virtual base::string16 DialogTitle() const = 0;
49 virtual base::string16 AccountChooserText() const = 0;
50 virtual base::string16 SignInLinkText() const = 0;
51 virtual base::string16 SpinnerText() const = 0;
52 virtual base::string16 EditSuggestionText() const = 0;
53 virtual base::string16 CancelButtonText() const = 0;
54 virtual base::string16 ConfirmButtonText() const = 0;
55 virtual base::string16 SaveLocallyText() const = 0;
56 virtual base::string16 SaveLocallyTooltip() const = 0;
57 virtual base::string16 LegalDocumentsText() = 0;
59 // State ---------------------------------------------------------------------
61 // Whether a loading animation should be shown (e.g. while signing in,
62 // retreiving Wallet data, etc.).
63 virtual bool ShouldShowSpinner() const = 0;
65 // Whether the account chooser/sign in link control should be visible.
66 virtual bool ShouldShowAccountChooser() const = 0;
68 // Whether the sign in web view should be displayed.
69 virtual bool ShouldShowSignInWebView() const = 0;
71 // Whether to show the checkbox to save data locally (in Autofill).
72 virtual bool ShouldOfferToSaveInChrome() const = 0;
74 // Whether the checkbox to save data locally should be checked initially.
75 virtual bool ShouldSaveInChrome() const = 0;
77 // Returns the model for the account chooser. It will return NULL if the
78 // account chooser should not show a menu. In this case, clicking on the
79 // account chooser should initiate sign-in.
80 virtual ui::MenuModel* MenuModelForAccountChooser() = 0;
82 // Returns the icon that should be shown in the account chooser.
83 virtual gfx::Image AccountChooserImage() = 0;
85 // Returns the image that should be shown on the left of the button strip
86 // or an empty image if none should be shown.
87 virtual gfx::Image ButtonStripImage() const = 0;
89 // Which dialog buttons should be visible.
90 virtual int GetDialogButtons() const = 0;
92 // Whether or not the |button| should be enabled.
93 virtual bool IsDialogButtonEnabled(ui::DialogButton button) const = 0;
95 // Returns a struct full of data concerning what overlay, if any, should be
96 // displayed on top of the dialog.
97 virtual DialogOverlayState GetDialogOverlay() = 0;
99 // Returns ranges to linkify in the text returned by |LegalDocumentsText()|.
100 virtual const std::vector<gfx::Range>& LegalDocumentLinks() = 0;
102 // Detail inputs -------------------------------------------------------------
104 // Whether the section is currently active (i.e. should be shown).
105 virtual bool SectionIsActive(DialogSection section) const = 0;
107 // Returns the set of inputs the page has requested which fall under
108 // |section|.
109 virtual const DetailInputs& RequestedFieldsForSection(DialogSection section)
110 const = 0;
112 // Returns the combobox model for inputs of type |type|, or NULL if the input
113 // should be a text field.
114 virtual ui::ComboboxModel* ComboboxModelForAutofillType(
115 ServerFieldType type) = 0;
117 // Returns the model for suggestions for fields that fall under |section|.
118 // This may return NULL, in which case no menu should be shown for that
119 // section.
120 virtual ui::MenuModel* MenuModelForSection(DialogSection section) = 0;
122 // Returns the label text used to describe the section (i.e. Billing).
123 virtual base::string16 LabelForSection(DialogSection section) const = 0;
125 // Returns the current state of suggestions for |section|.
126 virtual SuggestionState SuggestionStateForSection(DialogSection section) = 0;
128 // Returns the icons to be displayed along with the given |user_inputs| in a
129 // section.
130 virtual FieldIconMap IconsForFields(
131 const FieldValueMap& user_inputs) const = 0;
133 // Returns true if the value of this field |type| controls the icons for the
134 // rest of the fields in a section.
135 virtual bool FieldControlsIcons(ServerFieldType type) const = 0;
137 // Returns a tooltip for the given field, or an empty string if none exists.
138 virtual base::string16 TooltipForField(ServerFieldType type) const = 0;
140 // Whether a particular DetailInput in |section| should be edited or not.
141 virtual bool InputIsEditable(const DetailInput& input,
142 DialogSection section) = 0;
144 // Decides whether input of |value| is valid for a field of type |type|. If
145 // valid, the returned string will be empty. Otherwise it will contain an
146 // error message.
147 virtual base::string16 InputValidityMessage(DialogSection section,
148 ServerFieldType type,
149 const base::string16& value) = 0;
151 // Decides whether the combination of all |inputs| is valid, returns a
152 // map of field types to validity messages.
153 virtual ValidityMessages InputsAreValid(DialogSection section,
154 const FieldValueMap& inputs) = 0;
156 // Called when the user edits or activates a textfield or combobox.
157 // |was_edit| is true when the function was called in response to the user
158 // editing the input.
159 virtual void UserEditedOrActivatedInput(DialogSection section,
160 ServerFieldType type,
161 gfx::NativeView parent_view,
162 const gfx::Rect& content_bounds,
163 const base::string16& field_contents,
164 bool was_edit) = 0;
166 // The view forwards keypresses in text inputs. Returns true if there should
167 // be no further processing of the event.
168 virtual bool HandleKeyPressEventInInput(
169 const content::NativeWebKeyboardEvent& event) = 0;
171 // Called when focus has changed position within the view.
172 virtual void FocusMoved() = 0;
174 // Whether the view is allowed to show a validation error bubble.
175 virtual bool ShouldShowErrorBubble() const = 0;
177 // Miscellany ----------------------------------------------------------------
179 // Called when the view has been closed.
180 virtual void ViewClosed() = 0;
182 // Returns dialog notifications that the view should currently be showing in
183 // order from top to bottom.
184 virtual std::vector<DialogNotification> CurrentNotifications() = 0;
186 // Called when a generic link has been clicked in the dialog. Opens the URL
187 // out-of-line.
188 virtual void LinkClicked(const GURL& url) = 0;
190 // Begins or aborts the flow to sign into Wallet.
191 virtual void SignInLinkClicked() = 0;
193 // Called when a checkbox in the notification area has changed its state.
194 virtual void NotificationCheckboxStateChanged(DialogNotification::Type type,
195 bool checked) = 0;
197 // A legal document link has been clicked.
198 virtual void LegalDocumentLinkClicked(const gfx::Range& range) = 0;
200 // Called when the view has been cancelled. Returns true if the dialog should
201 // now close, or false to keep it open.
202 virtual bool OnCancel() = 0;
204 // Called when the view has been accepted. This could be to submit the payment
205 // info or to handle a required action. Returns true if the dialog should now
206 // close, or false to keep it open.
207 virtual bool OnAccept() = 0;
209 // Returns the profile for this dialog.
210 virtual Profile* profile() = 0;
212 // The web contents that prompted the dialog.
213 virtual content::WebContents* GetWebContents() = 0;
215 protected:
216 virtual ~AutofillDialogViewDelegate();
219 } // namespace autofill
221 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_VIEW_DELEGATE_H_