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