| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_UI_VIEWS_AUTOFILL_AUTOFILL_DIALOG_VIEWS_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_AUTOFILL_AUTOFILL_DIALOG_VIEWS_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_AUTOFILL_AUTOFILL_DIALOG_VIEWS_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_AUTOFILL_AUTOFILL_DIALOG_VIEWS_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "base/scoped_observer.h" | 12 #include "base/scoped_observer.h" |
| 13 #include "chrome/browser/ui/autofill/autofill_dialog_controller.h" | |
| 14 #include "chrome/browser/ui/autofill/autofill_dialog_view.h" | 13 #include "chrome/browser/ui/autofill/autofill_dialog_view.h" |
| 14 #include "chrome/browser/ui/autofill/autofill_dialog_view_delegate.h" |
| 15 #include "chrome/browser/ui/autofill/testable_autofill_dialog_view.h" | 15 #include "chrome/browser/ui/autofill/testable_autofill_dialog_view.h" |
| 16 #include "ui/base/animation/animation_delegate.h" | 16 #include "ui/base/animation/animation_delegate.h" |
| 17 #include "ui/views/controls/button/button.h" | 17 #include "ui/views/controls/button/button.h" |
| 18 #include "ui/views/controls/button/menu_button_listener.h" | 18 #include "ui/views/controls/button/menu_button_listener.h" |
| 19 #include "ui/views/controls/combobox/combobox_listener.h" | 19 #include "ui/views/controls/combobox/combobox_listener.h" |
| 20 #include "ui/views/controls/link_listener.h" | 20 #include "ui/views/controls/link_listener.h" |
| 21 #include "ui/views/controls/progress_bar.h" | 21 #include "ui/views/controls/progress_bar.h" |
| 22 #include "ui/views/controls/scroll_view.h" | 22 #include "ui/views/controls/scroll_view.h" |
| 23 #include "ui/views/controls/styled_label_listener.h" | 23 #include "ui/views/controls/styled_label_listener.h" |
| 24 #include "ui/views/controls/textfield/textfield_controller.h" | 24 #include "ui/views/controls/textfield/textfield_controller.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 class AutofillDialogViews : public AutofillDialogView, | 67 class AutofillDialogViews : public AutofillDialogView, |
| 68 public TestableAutofillDialogView, | 68 public TestableAutofillDialogView, |
| 69 public views::DialogDelegateView, | 69 public views::DialogDelegateView, |
| 70 public views::WidgetObserver, | 70 public views::WidgetObserver, |
| 71 public views::ButtonListener, | 71 public views::ButtonListener, |
| 72 public views::TextfieldController, | 72 public views::TextfieldController, |
| 73 public views::FocusChangeListener, | 73 public views::FocusChangeListener, |
| 74 public views::ComboboxListener, | 74 public views::ComboboxListener, |
| 75 public views::StyledLabelListener { | 75 public views::StyledLabelListener { |
| 76 public: | 76 public: |
| 77 explicit AutofillDialogViews(AutofillDialogController* controller); | 77 explicit AutofillDialogViews(AutofillDialogViewDelegate* delegate); |
| 78 virtual ~AutofillDialogViews(); | 78 virtual ~AutofillDialogViews(); |
| 79 | 79 |
| 80 // AutofillDialogView implementation: | 80 // AutofillDialogView implementation: |
| 81 virtual void Show() OVERRIDE; | 81 virtual void Show() OVERRIDE; |
| 82 virtual void Hide() OVERRIDE; | 82 virtual void Hide() OVERRIDE; |
| 83 virtual void UpdateAccountChooser() OVERRIDE; | 83 virtual void UpdateAccountChooser() OVERRIDE; |
| 84 virtual void UpdateAutocheckoutStepsArea() OVERRIDE; | 84 virtual void UpdateAutocheckoutStepsArea() OVERRIDE; |
| 85 virtual void UpdateButtonStrip() OVERRIDE; | 85 virtual void UpdateButtonStrip() OVERRIDE; |
| 86 virtual void UpdateDetailArea() OVERRIDE; | 86 virtual void UpdateDetailArea() OVERRIDE; |
| 87 virtual void UpdateForErrors() OVERRIDE; | 87 virtual void UpdateForErrors() OVERRIDE; |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 | 196 |
| 197 DISALLOW_COPY_AND_ASSIGN(ErrorBubble); | 197 DISALLOW_COPY_AND_ASSIGN(ErrorBubble); |
| 198 }; | 198 }; |
| 199 | 199 |
| 200 // A View which displays the currently selected account and lets the user | 200 // A View which displays the currently selected account and lets the user |
| 201 // switch accounts. | 201 // switch accounts. |
| 202 class AccountChooser : public views::View, | 202 class AccountChooser : public views::View, |
| 203 public views::LinkListener, | 203 public views::LinkListener, |
| 204 public base::SupportsWeakPtr<AccountChooser> { | 204 public base::SupportsWeakPtr<AccountChooser> { |
| 205 public: | 205 public: |
| 206 explicit AccountChooser(AutofillDialogController* controller); | 206 explicit AccountChooser(AutofillDialogViewDelegate* delegate); |
| 207 virtual ~AccountChooser(); | 207 virtual ~AccountChooser(); |
| 208 | 208 |
| 209 // Updates the view based on the state that |controller_| reports. | 209 // Updates the view based on the state that |delegate_| reports. |
| 210 void Update(); | 210 void Update(); |
| 211 | 211 |
| 212 // views::View implementation. | 212 // views::View implementation. |
| 213 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; | 213 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; |
| 214 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE; | 214 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE; |
| 215 | 215 |
| 216 // views::LinkListener implementation. | 216 // views::LinkListener implementation. |
| 217 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; | 217 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; |
| 218 | 218 |
| 219 private: | 219 private: |
| 220 // The icon for the currently in-use account. | 220 // The icon for the currently in-use account. |
| 221 views::ImageView* image_; | 221 views::ImageView* image_; |
| 222 | 222 |
| 223 // The label for the currently in-use account. | 223 // The label for the currently in-use account. |
| 224 views::Label* label_; | 224 views::Label* label_; |
| 225 | 225 |
| 226 // The drop arrow. | 226 // The drop arrow. |
| 227 views::ImageView* arrow_; | 227 views::ImageView* arrow_; |
| 228 | 228 |
| 229 // The sign in link. | 229 // The sign in link. |
| 230 views::Link* link_; | 230 views::Link* link_; |
| 231 | 231 |
| 232 // The controller |this| queries for logic and state. | 232 // The delegate |this| queries for logic and state. |
| 233 AutofillDialogController* controller_; | 233 AutofillDialogViewDelegate* delegate_; |
| 234 | 234 |
| 235 // Runs the suggestion menu (triggered by each section's |suggested_button|. | 235 // Runs the suggestion menu (triggered by each section's |suggested_button|. |
| 236 scoped_ptr<views::MenuRunner> menu_runner_; | 236 scoped_ptr<views::MenuRunner> menu_runner_; |
| 237 | 237 |
| 238 DISALLOW_COPY_AND_ASSIGN(AccountChooser); | 238 DISALLOW_COPY_AND_ASSIGN(AccountChooser); |
| 239 }; | 239 }; |
| 240 | 240 |
| 241 // A view which displays an image, optionally some messages and a button. Used | 241 // A view which displays an image, optionally some messages and a button. Used |
| 242 // for the splash page as well as the Wallet interstitial. | 242 // for the splash page as well as the Wallet interstitial. |
| 243 class OverlayView : public views::View, | 243 class OverlayView : public views::View, |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 // dialog behind the overlay). This avoids cross-fade. | 289 // dialog behind the overlay). This avoids cross-fade. |
| 290 scoped_ptr<ui::MultiAnimation> fade_out_; | 290 scoped_ptr<ui::MultiAnimation> fade_out_; |
| 291 | 291 |
| 292 DISALLOW_COPY_AND_ASSIGN(OverlayView); | 292 DISALLOW_COPY_AND_ASSIGN(OverlayView); |
| 293 }; | 293 }; |
| 294 | 294 |
| 295 // An area for notifications. Some notifications point at the account chooser. | 295 // An area for notifications. Some notifications point at the account chooser. |
| 296 class NotificationArea : public views::View, | 296 class NotificationArea : public views::View, |
| 297 public views::ButtonListener { | 297 public views::ButtonListener { |
| 298 public: | 298 public: |
| 299 explicit NotificationArea(AutofillDialogController* controller); | 299 explicit NotificationArea(AutofillDialogViewDelegate* delegate); |
| 300 virtual ~NotificationArea(); | 300 virtual ~NotificationArea(); |
| 301 | 301 |
| 302 // Displays the given notifications. | 302 // Displays the given notifications. |
| 303 void SetNotifications(const std::vector<DialogNotification>& notifications); | 303 void SetNotifications(const std::vector<DialogNotification>& notifications); |
| 304 | 304 |
| 305 // views::View implementation. | 305 // views::View implementation. |
| 306 virtual gfx::Size GetPreferredSize() OVERRIDE; | 306 virtual gfx::Size GetPreferredSize() OVERRIDE; |
| 307 virtual const char* GetClassName() const OVERRIDE; | 307 virtual const char* GetClassName() const OVERRIDE; |
| 308 virtual void PaintChildren(gfx::Canvas* canvas) OVERRIDE; | 308 virtual void PaintChildren(gfx::Canvas* canvas) OVERRIDE; |
| 309 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 309 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
| 310 | 310 |
| 311 // views::ButtonListener implementation: | 311 // views::ButtonListener implementation: |
| 312 virtual void ButtonPressed(views::Button* sender, | 312 virtual void ButtonPressed(views::Button* sender, |
| 313 const ui::Event& event) OVERRIDE; | 313 const ui::Event& event) OVERRIDE; |
| 314 | 314 |
| 315 void set_arrow_centering_anchor( | 315 void set_arrow_centering_anchor( |
| 316 const base::WeakPtr<views::View>& arrow_centering_anchor) { | 316 const base::WeakPtr<views::View>& arrow_centering_anchor) { |
| 317 arrow_centering_anchor_ = arrow_centering_anchor; | 317 arrow_centering_anchor_ = arrow_centering_anchor; |
| 318 } | 318 } |
| 319 | 319 |
| 320 private: | 320 private: |
| 321 // Utility function for determining whether an arrow should be drawn | 321 // Utility function for determining whether an arrow should be drawn |
| 322 // pointing at |arrow_centering_anchor_|. | 322 // pointing at |arrow_centering_anchor_|. |
| 323 bool HasArrow(); | 323 bool HasArrow(); |
| 324 | 324 |
| 325 // A reference to the controller than owns this view. Used to report when | 325 // A reference to the delegate/controller than owns this view. |
| 326 // checkboxes change their values. | 326 // Used to report when checkboxes change their values. |
| 327 AutofillDialogController* controller_; // weak | 327 AutofillDialogViewDelegate* delegate_; // weak |
| 328 | 328 |
| 329 // The currently showing checkbox, or NULL if none exists. | 329 // The currently showing checkbox, or NULL if none exists. |
| 330 views::Checkbox* checkbox_; // weak | 330 views::Checkbox* checkbox_; // weak |
| 331 | 331 |
| 332 // If HasArrow() is true, the arrow should point at this. | 332 // If HasArrow() is true, the arrow should point at this. |
| 333 base::WeakPtr<views::View> arrow_centering_anchor_; | 333 base::WeakPtr<views::View> arrow_centering_anchor_; |
| 334 | 334 |
| 335 std::vector<DialogNotification> notifications_; | 335 std::vector<DialogNotification> notifications_; |
| 336 | 336 |
| 337 DISALLOW_COPY_AND_ASSIGN(NotificationArea); | 337 DISALLOW_COPY_AND_ASSIGN(NotificationArea); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 | 486 |
| 487 // Creates the view that holds controls for inputing or selecting data for | 487 // Creates the view that holds controls for inputing or selecting data for |
| 488 // a given section. | 488 // a given section. |
| 489 views::View* CreateInputsContainer(DialogSection section); | 489 views::View* CreateInputsContainer(DialogSection section); |
| 490 | 490 |
| 491 // Creates a grid of textfield views for the given section, and stores them | 491 // Creates a grid of textfield views for the given section, and stores them |
| 492 // in the appropriate DetailsGroup. The top level View in the hierarchy is | 492 // in the appropriate DetailsGroup. The top level View in the hierarchy is |
| 493 // returned. | 493 // returned. |
| 494 views::View* InitInputsView(DialogSection section); | 494 views::View* InitInputsView(DialogSection section); |
| 495 | 495 |
| 496 // Updates the given section to match the state provided by |controller_|. If | 496 // Updates the given section to match the state provided by |delegate_|. If |
| 497 // |clobber_inputs| is true, the current state of the textfields will be | 497 // |clobber_inputs| is true, the current state of the textfields will be |
| 498 // ignored, otherwise their contents will be preserved. | 498 // ignored, otherwise their contents will be preserved. |
| 499 void UpdateSectionImpl(DialogSection section, bool clobber_inputs); | 499 void UpdateSectionImpl(DialogSection section, bool clobber_inputs); |
| 500 | 500 |
| 501 // Updates the visual state of the given group as per the model. | 501 // Updates the visual state of the given group as per the model. |
| 502 void UpdateDetailsGroupState(const DetailsGroup& group); | 502 void UpdateDetailsGroupState(const DetailsGroup& group); |
| 503 | 503 |
| 504 // Gets a pointer to the DetailsGroup that's associated with the given section | 504 // Gets a pointer to the DetailsGroup that's associated with the given section |
| 505 // of the dialog. | 505 // of the dialog. |
| 506 DetailsGroup* GroupForSection(DialogSection section); | 506 DetailsGroup* GroupForSection(DialogSection section); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 525 | 525 |
| 526 // Checks all manual inputs in |group| for validity. Decorates the invalid | 526 // Checks all manual inputs in |group| for validity. Decorates the invalid |
| 527 // ones and returns true if all were valid. | 527 // ones and returns true if all were valid. |
| 528 bool ValidateGroup(const DetailsGroup& group, ValidationType type); | 528 bool ValidateGroup(const DetailsGroup& group, ValidationType type); |
| 529 | 529 |
| 530 // Checks all manual inputs in the form for validity. Decorates the invalid | 530 // Checks all manual inputs in the form for validity. Decorates the invalid |
| 531 // ones and returns true if all were valid. | 531 // ones and returns true if all were valid. |
| 532 bool ValidateForm(); | 532 bool ValidateForm(); |
| 533 | 533 |
| 534 // When an input textfield is edited (its contents change) or activated | 534 // When an input textfield is edited (its contents change) or activated |
| 535 // (clicked while focused), this function will inform the controller that it's | 535 // (clicked while focused), this function will inform the delegate that it's |
| 536 // time to show a suggestion popup and possibly reset the validity state of | 536 // time to show a suggestion popup and possibly reset the validity state of |
| 537 // the input. | 537 // the input. |
| 538 void TextfieldEditedOrActivated(views::Textfield* textfield, bool was_edit); | 538 void TextfieldEditedOrActivated(views::Textfield* textfield, bool was_edit); |
| 539 | 539 |
| 540 // Updates the views in the button strip. | 540 // Updates the views in the button strip. |
| 541 void UpdateButtonStripExtraView(); | 541 void UpdateButtonStripExtraView(); |
| 542 | 542 |
| 543 // Call this when the size of anything in |contents_| might've changed. | 543 // Call this when the size of anything in |contents_| might've changed. |
| 544 void ContentsPreferredSizeChanged(); | 544 void ContentsPreferredSizeChanged(); |
| 545 | 545 |
| 546 // Gets the textfield view that is shown for the given DetailInput model, or | 546 // Gets the textfield view that is shown for the given DetailInput model, or |
| 547 // NULL. | 547 // NULL. |
| 548 views::Textfield* TextfieldForInput(const DetailInput& input); | 548 views::Textfield* TextfieldForInput(const DetailInput& input); |
| 549 | 549 |
| 550 // Gets the combobox view that is shown for the given DetailInput model, or | 550 // Gets the combobox view that is shown for the given DetailInput model, or |
| 551 // NULL. | 551 // NULL. |
| 552 views::Combobox* ComboboxForInput(const DetailInput& input); | 552 views::Combobox* ComboboxForInput(const DetailInput& input); |
| 553 | 553 |
| 554 // Called when the details container changes in size or position. | 554 // Called when the details container changes in size or position. |
| 555 void DetailsContainerBoundsChanged(); | 555 void DetailsContainerBoundsChanged(); |
| 556 | 556 |
| 557 // The controller that drives this view. Weak pointer, always non-NULL. | 557 // The delegate that drives this view. Weak pointer, always non-NULL. |
| 558 AutofillDialogController* const controller_; | 558 AutofillDialogViewDelegate* const delegate_; |
| 559 | 559 |
| 560 // The window that displays |contents_|. Weak pointer; may be NULL when the | 560 // The window that displays |contents_|. Weak pointer; may be NULL when the |
| 561 // dialog is closing. | 561 // dialog is closing. |
| 562 views::Widget* window_; | 562 views::Widget* window_; |
| 563 | 563 |
| 564 // A DialogSection-keyed map of the DetailGroup structs. | 564 // A DialogSection-keyed map of the DetailGroup structs. |
| 565 DetailGroupMap detail_groups_; | 565 DetailGroupMap detail_groups_; |
| 566 | 566 |
| 567 // Somewhere to show notification messages about errors, warnings, or promos. | 567 // Somewhere to show notification messages about errors, warnings, or promos. |
| 568 NotificationArea* notification_area_; | 568 NotificationArea* notification_area_; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 | 632 |
| 633 // Delegate for the sign-in dialog's webview. | 633 // Delegate for the sign-in dialog's webview. |
| 634 scoped_ptr<AutofillDialogSignInDelegate> sign_in_delegate_; | 634 scoped_ptr<AutofillDialogSignInDelegate> sign_in_delegate_; |
| 635 | 635 |
| 636 DISALLOW_COPY_AND_ASSIGN(AutofillDialogViews); | 636 DISALLOW_COPY_AND_ASSIGN(AutofillDialogViews); |
| 637 }; | 637 }; |
| 638 | 638 |
| 639 } // namespace autofill | 639 } // namespace autofill |
| 640 | 640 |
| 641 #endif // CHROME_BROWSER_UI_VIEWS_AUTOFILL_AUTOFILL_DIALOG_VIEWS_H_ | 641 #endif // CHROME_BROWSER_UI_VIEWS_AUTOFILL_AUTOFILL_DIALOG_VIEWS_H_ |
| OLD | NEW |