| 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* controller); |
| 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* controller); |
| 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 |controller_| 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 controller |this| queries for logic and state. |
| 233 AutofillDialogController* controller_; | 233 AutofillDialogViewDelegate* controller_; |
| 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* controller); |
| 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 controller than owns this view. Used to report when |
| 326 // checkboxes change their values. | 326 // checkboxes change their values. |
| 327 AutofillDialogController* controller_; // weak | 327 AutofillDialogViewDelegate* controller_; // 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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 controller that drives this view. Weak pointer, always non-NULL. |
| 558 AutofillDialogController* const controller_; | 558 AutofillDialogViewDelegate* const controller_; |
| 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 | 629 |
| 630 // Delegate for the sign-in dialog's webview. | 630 // Delegate for the sign-in dialog's webview. |
| 631 scoped_ptr<AutofillDialogSignInDelegate> sign_in_delegate_; | 631 scoped_ptr<AutofillDialogSignInDelegate> sign_in_delegate_; |
| 632 | 632 |
| 633 DISALLOW_COPY_AND_ASSIGN(AutofillDialogViews); | 633 DISALLOW_COPY_AND_ASSIGN(AutofillDialogViews); |
| 634 }; | 634 }; |
| 635 | 635 |
| 636 } // namespace autofill | 636 } // namespace autofill |
| 637 | 637 |
| 638 #endif // CHROME_BROWSER_UI_VIEWS_AUTOFILL_AUTOFILL_DIALOG_VIEWS_H_ | 638 #endif // CHROME_BROWSER_UI_VIEWS_AUTOFILL_AUTOFILL_DIALOG_VIEWS_H_ |
| OLD | NEW |