- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / views / autofill / autofill_dialog_views.h
1 // Copyright (c) 2012 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.
4
5 #ifndef CHROME_BROWSER_UI_VIEWS_AUTOFILL_AUTOFILL_DIALOG_VIEWS_H_
6 #define CHROME_BROWSER_UI_VIEWS_AUTOFILL_AUTOFILL_DIALOG_VIEWS_H_
7
8 #include <map>
9 #include <set>
10
11 #include "base/memory/scoped_vector.h"
12 #include "base/memory/weak_ptr.h"
13 #include "base/scoped_observer.h"
14 #include "chrome/browser/ui/autofill/autofill_dialog_types.h"
15 #include "chrome/browser/ui/autofill/autofill_dialog_view.h"
16 #include "chrome/browser/ui/autofill/autofill_dialog_view_delegate.h"
17 #include "chrome/browser/ui/autofill/testable_autofill_dialog_view.h"
18 #include "ui/views/bubble/bubble_delegate.h"
19 #include "ui/views/controls/button/button.h"
20 #include "ui/views/controls/button/menu_button.h"
21 #include "ui/views/controls/button/menu_button_listener.h"
22 #include "ui/views/controls/combobox/combobox_listener.h"
23 #include "ui/views/controls/link_listener.h"
24 #include "ui/views/controls/progress_bar.h"
25 #include "ui/views/controls/scroll_view.h"
26 #include "ui/views/controls/styled_label_listener.h"
27 #include "ui/views/controls/textfield/textfield_controller.h"
28 #include "ui/views/focus/focus_manager.h"
29 #include "ui/views/widget/widget_observer.h"
30 #include "ui/views/window/dialog_delegate.h"
31
32 namespace gfx {
33 class Image;
34 }
35
36 namespace views {
37 class BubbleBorder;
38 class Checkbox;
39 class Combobox;
40 class FocusManager;
41 class ImageView;
42 class Label;
43 class LabelButton;
44 class Link;
45 class MenuRunner;
46 class StyledLabel;
47 class WebView;
48 class Widget;
49 }  // namespace views
50
51 namespace ui {
52 class ComboboxModel;
53 class KeyEvent;
54 }
55
56 namespace autofill {
57
58 class AutofillDialogSignInDelegate;
59 class DecoratedTextfield;
60
61 // Views toolkit implementation of the Autofill dialog that handles the
62 // imperative autocomplete API call.
63 class AutofillDialogViews : public AutofillDialogView,
64                             public TestableAutofillDialogView,
65                             public views::DialogDelegateView,
66                             public views::WidgetObserver,
67                             public views::TextfieldController,
68                             public views::FocusChangeListener,
69                             public views::ComboboxListener,
70                             public views::StyledLabelListener,
71                             public views::MenuButtonListener {
72  public:
73   explicit AutofillDialogViews(AutofillDialogViewDelegate* delegate);
74   virtual ~AutofillDialogViews();
75
76   // AutofillDialogView implementation:
77   virtual void Show() OVERRIDE;
78   virtual void Hide() OVERRIDE;
79   virtual void UpdatesStarted() OVERRIDE;
80   virtual void UpdatesFinished() OVERRIDE;
81   virtual void UpdateAccountChooser() OVERRIDE;
82   virtual void UpdateButtonStrip() OVERRIDE;
83   virtual void UpdateOverlay() OVERRIDE;
84   virtual void UpdateDetailArea() OVERRIDE;
85   virtual void UpdateForErrors() OVERRIDE;
86   virtual void UpdateNotificationArea() OVERRIDE;
87   virtual void UpdateSection(DialogSection section) OVERRIDE;
88   virtual void UpdateErrorBubble() OVERRIDE;
89   virtual void FillSection(DialogSection section,
90                            const DetailInput& originating_input) OVERRIDE;
91   virtual void GetUserInput(DialogSection section,
92                             DetailOutputMap* output) OVERRIDE;
93   virtual base::string16 GetCvc() OVERRIDE;
94   virtual bool HitTestInput(const DetailInput& input,
95                             const gfx::Point& screen_point) OVERRIDE;
96   virtual bool SaveDetailsLocally() OVERRIDE;
97   virtual const content::NavigationController* ShowSignIn() OVERRIDE;
98   virtual void HideSignIn() OVERRIDE;
99   virtual void ModelChanged() OVERRIDE;
100   virtual TestableAutofillDialogView* GetTestableView() OVERRIDE;
101   virtual void OnSignInResize(const gfx::Size& pref_size) OVERRIDE;
102
103   // TestableAutofillDialogView implementation:
104   virtual void SubmitForTesting() OVERRIDE;
105   virtual void CancelForTesting() OVERRIDE;
106   virtual base::string16 GetTextContentsOfInput(
107       const DetailInput& input) OVERRIDE;
108   virtual void SetTextContentsOfInput(const DetailInput& input,
109                                       const base::string16& contents) OVERRIDE;
110   virtual void SetTextContentsOfSuggestionInput(
111       DialogSection section,
112       const base::string16& text) OVERRIDE;
113   virtual void ActivateInput(const DetailInput& input) OVERRIDE;
114   virtual gfx::Size GetSize() const OVERRIDE;
115   virtual content::WebContents* GetSignInWebContents() OVERRIDE;
116   virtual bool IsShowingOverlay() const OVERRIDE;
117
118   // views::View implementation.
119   virtual gfx::Size GetPreferredSize() OVERRIDE;
120   virtual gfx::Size GetMinimumSize() OVERRIDE;
121   virtual void Layout() OVERRIDE;
122
123   // views::DialogDelegate implementation:
124   virtual base::string16 GetWindowTitle() const OVERRIDE;
125   virtual void WindowClosing() OVERRIDE;
126   virtual void DeleteDelegate() OVERRIDE;
127   virtual views::View* CreateOverlayView() OVERRIDE;
128   virtual int GetDialogButtons() const OVERRIDE;
129   virtual int GetDefaultDialogButton() const OVERRIDE;
130   virtual base::string16 GetDialogButtonLabel(ui::DialogButton button) const
131       OVERRIDE;
132   virtual bool ShouldDefaultButtonBeBlue() const OVERRIDE;
133   virtual bool IsDialogButtonEnabled(ui::DialogButton button) const OVERRIDE;
134   virtual views::View* GetInitiallyFocusedView() OVERRIDE;
135   virtual views::View* CreateExtraView() OVERRIDE;
136   virtual views::View* CreateTitlebarExtraView() OVERRIDE;
137   virtual views::View* CreateFootnoteView() OVERRIDE;
138   virtual bool Cancel() OVERRIDE;
139   virtual bool Accept() OVERRIDE;
140   virtual views::NonClientFrameView* CreateNonClientFrameView(
141       views::Widget* widget) OVERRIDE;
142
143   // views::WidgetObserver implementation:
144   virtual void OnWidgetClosing(views::Widget* widget) OVERRIDE;
145   virtual void OnWidgetBoundsChanged(views::Widget* widget,
146                                      const gfx::Rect& new_bounds) OVERRIDE;
147
148   // views::TextfieldController implementation:
149   virtual void ContentsChanged(views::Textfield* sender,
150                                const base::string16& new_contents) OVERRIDE;
151   virtual bool HandleKeyEvent(views::Textfield* sender,
152                               const ui::KeyEvent& key_event) OVERRIDE;
153   virtual bool HandleMouseEvent(views::Textfield* sender,
154                                 const ui::MouseEvent& key_event) OVERRIDE;
155
156   // views::FocusChangeListener implementation.
157   virtual void OnWillChangeFocus(views::View* focused_before,
158                                  views::View* focused_now) OVERRIDE;
159   virtual void OnDidChangeFocus(views::View* focused_before,
160                                 views::View* focused_now) OVERRIDE;
161
162   // views::ComboboxListener implementation:
163   virtual void OnSelectedIndexChanged(views::Combobox* combobox) OVERRIDE;
164
165   // views::StyledLabelListener implementation:
166   virtual void StyledLabelLinkClicked(const gfx::Range& range, int event_flags)
167       OVERRIDE;
168
169   // views::MenuButtonListener implementation.
170   virtual void OnMenuButtonClicked(views::View* source,
171                                    const gfx::Point& point) OVERRIDE;
172
173  protected:
174   // Exposed for testing.
175   views::View* GetLoadingShieldForTesting();
176   views::WebView* GetSignInWebViewForTesting();
177   views::View* GetNotificationAreaForTesting();
178   views::View* GetScrollableAreaForTesting();
179
180  private:
181   // What the entire dialog should be doing (e.g. gathering info from the user,
182   // asking the user to sign in, etc.).
183   enum DialogMode {
184     DETAIL_INPUT,
185     LOADING,
186     SIGN_IN,
187   };
188
189   // A class that creates and manages a widget for error messages.
190   class ErrorBubble : public views::BubbleDelegateView {
191    public:
192     ErrorBubble(views::View* anchor,
193                 views::View* anchor_container,
194                 const base::string16& message);
195     virtual ~ErrorBubble();
196
197     // Updates the position of the bubble.
198     void UpdatePosition();
199
200     // Hides and closes the bubble.
201     void Hide();
202
203     // views::BubbleDelegateView:
204     virtual gfx::Size GetPreferredSize() OVERRIDE;
205     virtual gfx::Rect GetBubbleBounds() OVERRIDE;
206     virtual void OnWidgetClosing(views::Widget* widget) OVERRIDE;
207     virtual bool ShouldFlipArrowForRtl() const OVERRIDE;
208
209     const views::View* anchor() const { return anchor_; }
210
211    private:
212     // Calculate the effective container width (ignores edge padding).
213     int GetContainerWidth();
214
215     // Returns the desired bubble width (total).
216     int GetPreferredBubbleWidth();
217
218     // Whether the bubble should stick to the right edge of |anchor_|.
219     bool ShouldArrowGoOnTheRight();
220
221     views::Widget* widget_;  // Weak, may be NULL.
222     views::View* const anchor_;  // Weak.
223
224     // Used to determine the width of the bubble and whether to stick to the
225     // right edge of |anchor_|. Must contain |anchor_|.
226     views::View* const anchor_container_;  // Weak.
227
228     // Whether the bubble should be shown above the anchor (default is below).
229     const bool show_above_anchor_;
230
231     DISALLOW_COPY_AND_ASSIGN(ErrorBubble);
232   };
233
234   // A View which displays the currently selected account and lets the user
235   // switch accounts.
236   class AccountChooser : public views::View,
237                          public views::LinkListener,
238                          public views::MenuButtonListener,
239                          public base::SupportsWeakPtr<AccountChooser> {
240    public:
241     explicit AccountChooser(AutofillDialogViewDelegate* delegate);
242     virtual ~AccountChooser();
243
244     // Updates the view based on the state that |delegate_| reports.
245     void Update();
246
247     // views::LinkListener implementation.
248     virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE;
249
250     // views::MenuButtonListener implementation.
251     virtual void OnMenuButtonClicked(views::View* source,
252                                      const gfx::Point& point) OVERRIDE;
253
254    private:
255     // The icon for the currently in-use account.
256     views::ImageView* image_;
257
258     // The button for showing a menu to change the currently in-use account.
259     views::MenuButton* menu_button_;
260
261     // The sign in link.
262     views::Link* link_;
263
264     // The delegate |this| queries for logic and state.
265     AutofillDialogViewDelegate* delegate_;
266
267     // Runs the suggestion menu (triggered by each section's |suggested_button|.
268     scoped_ptr<views::MenuRunner> menu_runner_;
269
270     DISALLOW_COPY_AND_ASSIGN(AccountChooser);
271   };
272
273   // A view which displays an image, optionally some messages and a button. Used
274   // for the Wallet interstitial.
275   class OverlayView : public views::View {
276    public:
277     explicit OverlayView(AutofillDialogViewDelegate* delegate);
278     virtual ~OverlayView();
279
280     // Returns a height which should be used when the contents view has width
281     // |w|. Note that the value returned should be used as the height of the
282     // dialog's contents.
283     int GetHeightForContentsForWidth(int width);
284
285     // Sets the state to whatever |delegate_| says it should be.
286     void UpdateState();
287
288     // views::View implementation:
289     virtual gfx::Insets GetInsets() const OVERRIDE;
290     virtual void Layout() OVERRIDE;
291     virtual const char* GetClassName() const OVERRIDE;
292     virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
293
294    private:
295     // Gets the border of the non-client frame view as a BubbleBorder.
296     views::BubbleBorder* GetBubbleBorder();
297
298     // Gets the bounds of this view without the frame view's bubble border.
299     gfx::Rect ContentBoundsSansBubbleBorder();
300
301     // The delegate that provides |state| when UpdateState is called.
302     AutofillDialogViewDelegate* delegate_;
303
304     // Child View. Front and center.
305     views::ImageView* image_view_;
306     // Child View. When visible, below |image_view_|.
307     views::Label* message_view_;
308
309     DISALLOW_COPY_AND_ASSIGN(OverlayView);
310   };
311
312   // An area for notifications. Some notifications point at the account chooser.
313   class NotificationArea : public views::View {
314    public:
315     explicit NotificationArea(AutofillDialogViewDelegate* delegate);
316     virtual ~NotificationArea();
317
318     // Displays the given notifications.
319     void SetNotifications(const std::vector<DialogNotification>& notifications);
320
321     // views::View implementation.
322     virtual gfx::Size GetPreferredSize() OVERRIDE;
323     virtual const char* GetClassName() const OVERRIDE;
324     virtual void PaintChildren(gfx::Canvas* canvas) OVERRIDE;
325     virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
326
327     void set_arrow_centering_anchor(
328         const base::WeakPtr<views::View>& arrow_centering_anchor) {
329       arrow_centering_anchor_ = arrow_centering_anchor;
330     }
331
332    private:
333     // Utility function for determining whether an arrow should be drawn
334     // pointing at |arrow_centering_anchor_|.
335     bool HasArrow();
336
337     // A reference to the delegate/controller than owns this view.
338     // Used to report when checkboxes change their values.
339     AutofillDialogViewDelegate* delegate_;  // weak
340
341     // If HasArrow() is true, the arrow should point at this.
342     base::WeakPtr<views::View> arrow_centering_anchor_;
343
344     std::vector<DialogNotification> notifications_;
345
346     DISALLOW_COPY_AND_ASSIGN(NotificationArea);
347   };
348
349   typedef std::map<const DetailInput*, DecoratedTextfield*> TextfieldMap;
350   typedef std::map<const DetailInput*, views::Combobox*> ComboboxMap;
351
352   // A view that packs a label on the left and some related controls
353   // on the right.
354   class SectionContainer : public views::View {
355    public:
356     SectionContainer(const base::string16& label,
357                      views::View* controls,
358                      views::Button* proxy_button);
359     virtual ~SectionContainer();
360
361     // Sets the visual appearance of the section to active (considered active
362     // when showing the menu or hovered by the mouse cursor).
363     void SetActive(bool active);
364
365     // Sets whether mouse events should be forwarded to |proxy_button_|.
366     void SetForwardMouseEvents(bool forward);
367
368     // views::View implementation.
369     virtual const char* GetClassName() const OVERRIDE;
370     virtual void OnMouseMoved(const ui::MouseEvent& event) OVERRIDE;
371     virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE;
372     virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE;
373     virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE;
374     virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE;
375     // This is needed because not all events percolate up the views hierarchy.
376     virtual View* GetEventHandlerForPoint(const gfx::Point& point) OVERRIDE;
377
378    private:
379     // Converts |event| to one suitable for |proxy_button_|.
380     static ui::MouseEvent ProxyEvent(const ui::MouseEvent& event);
381
382     // Returns true if the given event should be forwarded to |proxy_button_|.
383     bool ShouldForwardEvent(const ui::MouseEvent& event);
384
385     // Mouse events on |this| are sent to this button.
386     views::Button* proxy_button_;  // Weak reference.
387
388     // When true, all mouse events will be forwarded to |proxy_button_|.
389     bool forward_mouse_events_;
390
391     DISALLOW_COPY_AND_ASSIGN(SectionContainer);
392   };
393
394   // A button to show address or billing suggestions.
395   class SuggestedButton : public views::MenuButton {
396    public:
397     explicit SuggestedButton(views::MenuButtonListener* listener);
398     virtual ~SuggestedButton();
399
400     // views::MenuButton implementation.
401     virtual gfx::Size GetPreferredSize() OVERRIDE;
402     virtual const char* GetClassName() const OVERRIDE;
403     virtual void PaintChildren(gfx::Canvas* canvas) OVERRIDE;
404     virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
405
406    private:
407     // Returns the corred resource ID (i.e. IDR_*) for the current |state()|.
408     int ResourceIDForState() const;
409
410     DISALLOW_COPY_AND_ASSIGN(SuggestedButton);
411   };
412
413   // A view that runs a callback whenever its bounds change, and which can
414   // optionally suppress layout.
415   class DetailsContainerView : public views::View {
416    public:
417     explicit DetailsContainerView(const base::Closure& callback);
418     virtual ~DetailsContainerView();
419
420     void set_ignore_layouts(bool ignore_layouts) {
421       ignore_layouts_ = ignore_layouts;
422     }
423
424     // views::View implementation.
425     virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE;
426     virtual void Layout() OVERRIDE;
427
428    private:
429     base::Closure bounds_changed_callback_;
430
431     // The view ignores Layout() calls when this is true.
432     bool ignore_layouts_;
433
434     DISALLOW_COPY_AND_ASSIGN(DetailsContainerView);
435   };
436
437   // A view that contains a suggestion (such as a known address) and a link to
438   // edit the suggestion.
439   class SuggestionView : public views::View {
440    public:
441     explicit SuggestionView(AutofillDialogViews* autofill_dialog);
442     virtual ~SuggestionView();
443
444     void SetState(const SuggestionState& state);
445
446     // views::View implementation.
447     virtual gfx::Size GetPreferredSize() OVERRIDE;
448     virtual int GetHeightForWidth(int width) OVERRIDE;
449     virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE;
450
451     DecoratedTextfield* decorated_textfield() { return decorated_; }
452
453    private:
454     // Returns whether there's room to display |state_.vertically_compact_text|
455     // without resorting to an ellipsis for a pixel width of |available_width|.
456     // Fills in |resulting_height| with the amount of space required to display
457     // |vertically_compact_text| or |horizontally_compact_text| as the case may
458     // be.
459     bool CanUseVerticallyCompactText(int available_width,
460                                      int* resulting_height);
461
462     // Sets the display text of the suggestion.
463     void SetLabelText(const base::string16& text);
464
465     // Sets the icon which should be displayed ahead of the text.
466     void SetIcon(const gfx::Image& image);
467
468     // Shows an auxiliary textfield to the right of the suggestion icon and
469     // text. This is currently only used to show a CVC field for the CC section.
470     void SetTextfield(const base::string16& placeholder_text,
471                       const gfx::Image& icon);
472
473     // The state of |this|.
474     SuggestionState state_;
475
476     // This caches preferred heights for given widths. The key is a preferred
477     // width, the value is a cached result of CanUseVerticallyCompactText.
478     std::map<int, std::pair<bool, int> > calculated_heights_;
479
480     // The label that holds the suggestion description text.
481     views::Label* label_;
482     // The second (and greater) line of text that describes the suggestion.
483     views::Label* label_line_2_;
484     // The icon that comes just before |label_|.
485     views::ImageView* icon_;
486     // The input set by ShowTextfield.
487     DecoratedTextfield* decorated_;
488     // An "Edit" link that flips to editable inputs rather than suggestion text.
489     views::Link* edit_link_;
490
491     DISALLOW_COPY_AND_ASSIGN(SuggestionView);
492   };
493
494   // A convenience struct for holding pointers to views within each detail
495   // section. None of the member pointers are owned.
496   struct DetailsGroup {
497     explicit DetailsGroup(DialogSection section);
498     ~DetailsGroup();
499
500     // The section this group is associated with.
501     const DialogSection section;
502     // The view that contains the entire section (label + input).
503     SectionContainer* container;
504     // The view that allows manual input.
505     views::View* manual_input;
506     // The textfields in |manual_input|, tracked by their DetailInput.
507     TextfieldMap textfields;
508     // The comboboxes in |manual_input|, tracked by their DetailInput.
509     ComboboxMap comboboxes;
510     // The view that holds the text of the suggested data. This will be
511     // visible IFF |manual_input| is not visible.
512     SuggestionView* suggested_info;
513     // The view that allows selecting other data suggestions.
514     SuggestedButton* suggested_button;
515   };
516
517   typedef std::map<DialogSection, DetailsGroup> DetailGroupMap;
518
519   // Returns the preferred size or minimum size (if |get_minimum_size| is true).
520   gfx::Size CalculatePreferredSize(bool get_minimum_size);
521
522   // Returns the minimum size of the sign in view for this dialog.
523   gfx::Size GetMinimumSignInViewSize() const;
524
525   // Returns the maximum size of the sign in view for this dialog.
526   gfx::Size GetMaximumSignInViewSize() const;
527
528   // Returns which section should currently be used for credit card info.
529   DialogSection GetCreditCardSection() const;
530
531   void InitChildViews();
532
533   // Creates and returns a view that holds all detail sections.
534   views::View* CreateDetailsContainer();
535
536   // Creates and returns a view that holds the requesting host and intro text.
537   views::View* CreateNotificationArea();
538
539   // Creates and returns a view that holds the main controls of this dialog.
540   views::View* CreateMainContainer();
541
542   // Creates a detail section (Shipping, Email, etc.) with the given label,
543   // inputs View, and suggestion model. Relevant pointers are stored in |group|.
544   void CreateDetailsSection(DialogSection section);
545
546   // Creates the view that holds controls for inputing or selecting data for
547   // a given section.
548   views::View* CreateInputsContainer(DialogSection section);
549
550   // Creates a grid of textfield views for the given section, and stores them
551   // in the appropriate DetailsGroup. The top level View in the hierarchy is
552   // returned.
553   views::View* InitInputsView(DialogSection section);
554
555   // Changes the function of the whole dialog. Currently this can show a loading
556   // shield, an embedded sign in web view, or the more typical detail input mode
557   // (suggestions and form inputs).
558   void ShowDialogInMode(DialogMode dialog_mode);
559
560   // Updates the given section to match the state provided by |delegate_|. If
561   // |clobber_inputs| is true, the current state of the textfields will be
562   // ignored, otherwise their contents will be preserved.
563   void UpdateSectionImpl(DialogSection section, bool clobber_inputs);
564
565   // Updates the visual state of the given group as per the model.
566   void UpdateDetailsGroupState(const DetailsGroup& group);
567
568   // Gets a pointer to the DetailsGroup that's associated with the given section
569   // of the dialog.
570   DetailsGroup* GroupForSection(DialogSection section);
571
572   // Gets a pointer to the DetailsGroup that's associated with a given |view|.
573   // Returns NULL if no DetailsGroup was found.
574   DetailsGroup* GroupForView(views::View* view);
575
576   // Explicitly focuses the initially focusable view.
577   void FocusInitialView();
578
579   // Sets the visual state for an input to be either valid or invalid. This
580   // should work on Comboboxes or DecoratedTextfields. If |message| is empty,
581   // the input is valid.
582   template<class T>
583   void SetValidityForInput(T* input, const base::string16& message);
584
585   // Shows an error bubble pointing at |view| if |view| has a message in
586   // |validity_map_|.
587   void ShowErrorBubbleForViewIfNecessary(views::View* view);
588
589   // Hides |error_bubble_| (if it exists).
590   void HideErrorBubble();
591
592   // Updates validity of the inputs in |section| with new |validity_messages|.
593   // Fields are only updated with unsure messages if |overwrite_valid| is true.
594   void MarkInputsInvalid(DialogSection section,
595                          const ValidityMessages& validity_messages,
596                          bool overwrite_invalid);
597
598   // Checks all manual inputs in |group| for validity. Decorates the invalid
599   // ones and returns true if all were valid.
600   bool ValidateGroup(const DetailsGroup& group, ValidationType type);
601
602   // Checks all manual inputs in the form for validity. Decorates the invalid
603   // ones and returns true if all were valid.
604   bool ValidateForm();
605
606   // When an input textfield is edited (its contents change) or activated
607   // (clicked while focused), this function will inform the delegate that it's
608   // time to show a suggestion popup and possibly reset the validity state of
609   // the input.
610   void TextfieldEditedOrActivated(views::Textfield* textfield, bool was_edit);
611
612   // Updates the views in the button strip.
613   void UpdateButtonStripExtraView();
614
615   // Call this when the size of anything in |contents_| might've changed.
616   void ContentsPreferredSizeChanged();
617   void DoContentsPreferredSizeChanged();
618
619   // Gets the textfield view that is shown for the given DetailInput model, or
620   // NULL.
621   views::Textfield* TextfieldForInput(const DetailInput& input);
622
623   // Gets the combobox view that is shown for the given DetailInput model, or
624   // NULL.
625   views::Combobox* ComboboxForInput(const DetailInput& input);
626
627   // Called when the details container changes in size or position.
628   void DetailsContainerBoundsChanged();
629
630   // Sets the icons in |section| according to the field values. For example,
631   // sets the credit card and CVC icons according to the credit card number.
632   void SetIconsForSection(DialogSection section);
633
634   // Iterates over all the inputs in |section| and sets their enabled/disabled
635   // state.
636   void SetEditabilityForSection(DialogSection section);
637
638   // The delegate that drives this view. Weak pointer, always non-NULL.
639   AutofillDialogViewDelegate* const delegate_;
640
641   // The preferred size of the view, cached to avoid needless recomputation.
642   gfx::Size preferred_size_;
643
644   // The current number of unmatched calls to UpdatesStarted.
645   int updates_scope_;
646
647   // True when there's been a call to ContentsPreferredSizeChanged() suppressed
648   // due to an unmatched UpdatesStarted.
649   bool needs_update_;
650
651   // The window that displays |contents_|. Weak pointer; may be NULL when the
652   // dialog is closing.
653   views::Widget* window_;
654
655   // A DialogSection-keyed map of the DetailGroup structs.
656   DetailGroupMap detail_groups_;
657
658   // Somewhere to show notification messages about errors, warnings, or promos.
659   NotificationArea* notification_area_;
660
661   // Runs the suggestion menu (triggered by each section's |suggested_button|.
662   scoped_ptr<views::MenuRunner> menu_runner_;
663
664   // The view that allows the user to toggle the data source.
665   AccountChooser* account_chooser_;
666
667   // A WebView to that navigates to a Google sign-in page to allow the user to
668   // sign-in.
669   views::WebView* sign_in_web_view_;
670
671   // View that wraps |details_container_| and makes it scroll vertically.
672   views::ScrollView* scrollable_area_;
673
674   // View to host details sections.
675   DetailsContainerView* details_container_;
676
677   // A view that overlays |this| (for "loading..." messages).
678   views::View* loading_shield_;
679
680   // The height for |loading_shield_|. This prevents the height of the dialog
681   // from changing while the loading shield is showing.
682   int loading_shield_height_;
683
684   // The view that completely overlays the dialog (used for the splash page).
685   OverlayView* overlay_view_;
686
687   // The "Extra view" is on the same row as the dialog buttons.
688   views::View* button_strip_extra_view_;
689
690   // This checkbox controls whether new details are saved to the Autofill
691   // database. It lives in |extra_view_|.
692   views::Checkbox* save_in_chrome_checkbox_;
693
694   // Holds the above checkbox and an associated tooltip icon.
695   views::View* save_in_chrome_checkbox_container_;
696
697   // Used to display an image in the button strip extra view.
698   views::ImageView* button_strip_image_;
699
700   // View that aren't in the hierarchy but are owned by |this|. Currently
701   // just holds the (hidden) country comboboxes.
702   ScopedVector<views::View> other_owned_views_;
703
704   // The view that is appended to the bottom of the dialog, below the button
705   // strip. Used to display legal document links.
706   views::View* footnote_view_;
707
708   // The legal document text and links.
709   views::StyledLabel* legal_document_view_;
710
711   // The focus manager for |window_|.
712   views::FocusManager* focus_manager_;
713
714   // The object that manages the error bubble widget.
715   ErrorBubble* error_bubble_;  // Weak; owns itself.
716
717   // Map from input view (textfield or combobox) to error string.
718   std::map<views::View*, base::string16> validity_map_;
719
720   ScopedObserver<views::Widget, AutofillDialogViews> observer_;
721
722   // Delegate for the sign-in dialog's webview.
723   scoped_ptr<AutofillDialogSignInDelegate> sign_in_delegate_;
724
725   DISALLOW_COPY_AND_ASSIGN(AutofillDialogViews);
726 };
727
728 }  // namespace autofill
729
730 #endif  // CHROME_BROWSER_UI_VIEWS_AUTOFILL_AUTOFILL_DIALOG_VIEWS_H_