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