BookmarkManager: Fix 'new folder text field size changes on clicking it' issue.
[chromium-blink-merge.git] / chrome / browser / ui / autofill / autofill_dialog_view_delegate.h
bloba3fa24e052f6e69abc2e3f3d84c6bdf187e6e152
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/core/browser/detail_input.h"
13 #include "components/autofill/core/browser/dialog_section.h"
14 #include "components/autofill/core/browser/field_types.h"
15 #include "ui/base/ui_base_types.h"
16 #include "ui/gfx/image/image.h"
17 #include "ui/gfx/native_widget_types.h"
18 #include "ui/gfx/range/range.h"
20 class FieldValueMap;
21 class GURL;
22 class Profile;
24 namespace content {
25 class WebContents;
26 struct NativeWebKeyboardEvent;
29 namespace gfx {
30 class Rect;
33 namespace ui {
34 class ComboboxModel;
35 class MenuModel;
38 namespace autofill {
40 typedef std::map<ServerFieldType, gfx::Image> FieldIconMap;
42 // This class defines the interface to the controller that the dialog view sees.
43 class AutofillDialogViewDelegate {
44 public:
45 // Strings -------------------------------------------------------------------
47 virtual base::string16 DialogTitle() const = 0;
48 virtual base::string16 EditSuggestionText() const = 0;
49 virtual base::string16 CancelButtonText() const = 0;
50 virtual base::string16 ConfirmButtonText() const = 0;
51 virtual base::string16 SaveLocallyText() const = 0;
52 virtual base::string16 SaveLocallyTooltip() const = 0;
54 // State ---------------------------------------------------------------------
56 // Whether to show the checkbox to save data locally (in Autofill).
57 virtual bool ShouldOfferToSaveInChrome() const = 0;
59 // Whether the checkbox to save data locally should be checked initially.
60 virtual bool ShouldSaveInChrome() const = 0;
62 // Which dialog buttons should be visible.
63 virtual int GetDialogButtons() const = 0;
65 // Whether or not the |button| should be enabled.
66 virtual bool IsDialogButtonEnabled(ui::DialogButton button) const = 0;
68 // Detail inputs -------------------------------------------------------------
70 // Whether the section is currently active (i.e. should be shown).
71 virtual bool SectionIsActive(DialogSection section) const = 0;
73 // Returns the set of inputs the page has requested which fall under
74 // |section|.
75 virtual const DetailInputs& RequestedFieldsForSection(DialogSection section)
76 const = 0;
78 // Returns the combobox model for inputs of type |type|, or NULL if the input
79 // should be a text field.
80 virtual ui::ComboboxModel* ComboboxModelForAutofillType(
81 ServerFieldType type) = 0;
83 // Returns the model for suggestions for fields that fall under |section|.
84 // This may return NULL, in which case no menu should be shown for that
85 // section.
86 virtual ui::MenuModel* MenuModelForSection(DialogSection section) = 0;
88 // Returns the label text used to describe the section (i.e. Billing).
89 virtual base::string16 LabelForSection(DialogSection section) const = 0;
91 // Returns the current state of suggestions for |section|.
92 virtual SuggestionState SuggestionStateForSection(DialogSection section) = 0;
94 // Returns the icons to be displayed along with the given |user_inputs| in a
95 // section.
96 virtual FieldIconMap IconsForFields(
97 const FieldValueMap& user_inputs) const = 0;
99 // Returns true if the value of this field |type| controls the icons for the
100 // rest of the fields in a section.
101 virtual bool FieldControlsIcons(ServerFieldType type) const = 0;
103 // Returns a tooltip for the given field, or an empty string if none exists.
104 virtual base::string16 TooltipForField(ServerFieldType type) const = 0;
106 // Decides whether input of |value| is valid for a field of type |type|. If
107 // valid, the returned string will be empty. Otherwise it will contain an
108 // error message.
109 virtual base::string16 InputValidityMessage(DialogSection section,
110 ServerFieldType type,
111 const base::string16& value) = 0;
113 // Decides whether the combination of all |inputs| is valid, returns a
114 // map of field types to validity messages.
115 virtual ValidityMessages InputsAreValid(DialogSection section,
116 const FieldValueMap& inputs) = 0;
118 // Called when the user edits or activates a textfield or combobox.
119 // |was_edit| is true when the function was called in response to the user
120 // editing the input.
121 virtual void UserEditedOrActivatedInput(DialogSection section,
122 ServerFieldType type,
123 gfx::NativeView parent_view,
124 const gfx::Rect& content_bounds,
125 const base::string16& field_contents,
126 bool was_edit) = 0;
128 // The view forwards keypresses in text inputs. Returns true if there should
129 // be no further processing of the event.
130 virtual bool HandleKeyPressEventInInput(
131 const content::NativeWebKeyboardEvent& event) = 0;
133 // Called when focus has changed position within the view.
134 virtual void FocusMoved() = 0;
136 // Whether the view is allowed to show a validation error bubble.
137 virtual bool ShouldShowErrorBubble() const = 0;
139 // Miscellany ----------------------------------------------------------------
141 // Called when the view has been closed.
142 virtual void ViewClosed() = 0;
144 // Returns dialog notifications that the view should currently be showing in
145 // order from top to bottom.
146 virtual std::vector<DialogNotification> CurrentNotifications() = 0;
148 // Called when a generic link has been clicked in the dialog. Opens the URL
149 // out-of-line.
150 virtual void LinkClicked(const GURL& url) = 0;
152 // Called when the view has been cancelled.
153 virtual void OnCancel() = 0;
155 // Called when the view has been accepted.
156 virtual void OnAccept() = 0;
158 // Returns the profile for this dialog.
159 virtual Profile* profile() = 0;
161 // The web contents that prompted the dialog.
162 virtual content::WebContents* GetWebContents() = 0;
164 protected:
165 virtual ~AutofillDialogViewDelegate();
168 } // namespace autofill
170 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_VIEW_DELEGATE_H_