| 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 #include <set> | 9 #include <set> |
| 10 | 10 |
| 11 #include "base/memory/scoped_vector.h" | 11 #include "base/memory/scoped_vector.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "base/scoped_observer.h" | 13 #include "base/scoped_observer.h" |
| 14 #include "chrome/browser/ui/autofill/autofill_dialog_types.h" | 14 #include "chrome/browser/ui/autofill/autofill_dialog_types.h" |
| 15 #include "chrome/browser/ui/autofill/autofill_dialog_view.h" | 15 #include "chrome/browser/ui/autofill/autofill_dialog_view.h" |
| 16 #include "chrome/browser/ui/autofill/autofill_dialog_view_delegate.h" | 16 #include "chrome/browser/ui/autofill/autofill_dialog_view_delegate.h" |
| 17 #include "chrome/browser/ui/autofill/testable_autofill_dialog_view.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" | 18 #include "ui/views/controls/button/button.h" |
| 20 #include "ui/views/controls/button/menu_button.h" | 19 #include "ui/views/controls/button/menu_button.h" |
| 21 #include "ui/views/controls/button/menu_button_listener.h" | 20 #include "ui/views/controls/button/menu_button_listener.h" |
| 22 #include "ui/views/controls/combobox/combobox_listener.h" | 21 #include "ui/views/controls/combobox/combobox_listener.h" |
| 23 #include "ui/views/controls/link_listener.h" | 22 #include "ui/views/controls/link_listener.h" |
| 24 #include "ui/views/controls/progress_bar.h" | 23 #include "ui/views/controls/progress_bar.h" |
| 25 #include "ui/views/controls/scroll_view.h" | 24 #include "ui/views/controls/scroll_view.h" |
| 26 #include "ui/views/controls/styled_label_listener.h" | 25 #include "ui/views/controls/styled_label_listener.h" |
| 27 #include "ui/views/controls/textfield/textfield_controller.h" | 26 #include "ui/views/controls/textfield/textfield_controller.h" |
| 28 #include "ui/views/focus/focus_manager.h" | 27 #include "ui/views/focus/focus_manager.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 50 | 49 |
| 51 namespace ui { | 50 namespace ui { |
| 52 class ComboboxModel; | 51 class ComboboxModel; |
| 53 class KeyEvent; | 52 class KeyEvent; |
| 54 } | 53 } |
| 55 | 54 |
| 56 namespace autofill { | 55 namespace autofill { |
| 57 | 56 |
| 58 class AutofillDialogSignInDelegate; | 57 class AutofillDialogSignInDelegate; |
| 59 class DecoratedTextfield; | 58 class DecoratedTextfield; |
| 59 class InfoBubble; |
| 60 | 60 |
| 61 // Views toolkit implementation of the Autofill dialog that handles the | 61 // Views toolkit implementation of the Autofill dialog that handles the |
| 62 // imperative autocomplete API call. | 62 // imperative autocomplete API call. |
| 63 class AutofillDialogViews : public AutofillDialogView, | 63 class AutofillDialogViews : public AutofillDialogView, |
| 64 public TestableAutofillDialogView, | 64 public TestableAutofillDialogView, |
| 65 public views::DialogDelegateView, | 65 public views::DialogDelegateView, |
| 66 public views::WidgetObserver, | 66 public views::WidgetObserver, |
| 67 public views::TextfieldController, | 67 public views::TextfieldController, |
| 68 public views::FocusChangeListener, | 68 public views::FocusChangeListener, |
| 69 public views::ComboboxListener, | 69 public views::ComboboxListener, |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 | 179 |
| 180 private: | 180 private: |
| 181 // What the entire dialog should be doing (e.g. gathering info from the user, | 181 // What the entire dialog should be doing (e.g. gathering info from the user, |
| 182 // asking the user to sign in, etc.). | 182 // asking the user to sign in, etc.). |
| 183 enum DialogMode { | 183 enum DialogMode { |
| 184 DETAIL_INPUT, | 184 DETAIL_INPUT, |
| 185 LOADING, | 185 LOADING, |
| 186 SIGN_IN, | 186 SIGN_IN, |
| 187 }; | 187 }; |
| 188 | 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 | 189 // A View which displays the currently selected account and lets the user |
| 235 // switch accounts. | 190 // switch accounts. |
| 236 class AccountChooser : public views::View, | 191 class AccountChooser : public views::View, |
| 237 public views::LinkListener, | 192 public views::LinkListener, |
| 238 public views::MenuButtonListener, | 193 public views::MenuButtonListener, |
| 239 public base::SupportsWeakPtr<AccountChooser> { | 194 public base::SupportsWeakPtr<AccountChooser> { |
| 240 public: | 195 public: |
| 241 explicit AccountChooser(AutofillDialogViewDelegate* delegate); | 196 explicit AccountChooser(AutofillDialogViewDelegate* delegate); |
| 242 virtual ~AccountChooser(); | 197 virtual ~AccountChooser(); |
| 243 | 198 |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 705 // strip. Used to display legal document links. | 660 // strip. Used to display legal document links. |
| 706 views::View* footnote_view_; | 661 views::View* footnote_view_; |
| 707 | 662 |
| 708 // The legal document text and links. | 663 // The legal document text and links. |
| 709 views::StyledLabel* legal_document_view_; | 664 views::StyledLabel* legal_document_view_; |
| 710 | 665 |
| 711 // The focus manager for |window_|. | 666 // The focus manager for |window_|. |
| 712 views::FocusManager* focus_manager_; | 667 views::FocusManager* focus_manager_; |
| 713 | 668 |
| 714 // The object that manages the error bubble widget. | 669 // The object that manages the error bubble widget. |
| 715 ErrorBubble* error_bubble_; // Weak; owns itself. | 670 InfoBubble* error_bubble_; // Weak; owns itself. |
| 716 | 671 |
| 717 // Map from input view (textfield or combobox) to error string. | 672 // Map from input view (textfield or combobox) to error string. |
| 718 std::map<views::View*, base::string16> validity_map_; | 673 std::map<views::View*, base::string16> validity_map_; |
| 719 | 674 |
| 720 ScopedObserver<views::Widget, AutofillDialogViews> observer_; | 675 ScopedObserver<views::Widget, AutofillDialogViews> observer_; |
| 721 | 676 |
| 722 // Delegate for the sign-in dialog's webview. | 677 // Delegate for the sign-in dialog's webview. |
| 723 scoped_ptr<AutofillDialogSignInDelegate> sign_in_delegate_; | 678 scoped_ptr<AutofillDialogSignInDelegate> sign_in_delegate_; |
| 724 | 679 |
| 725 DISALLOW_COPY_AND_ASSIGN(AutofillDialogViews); | 680 DISALLOW_COPY_AND_ASSIGN(AutofillDialogViews); |
| 726 }; | 681 }; |
| 727 | 682 |
| 728 } // namespace autofill | 683 } // namespace autofill |
| 729 | 684 |
| 730 #endif // CHROME_BROWSER_UI_VIEWS_AUTOFILL_AUTOFILL_DIALOG_VIEWS_H_ | 685 #endif // CHROME_BROWSER_UI_VIEWS_AUTOFILL_AUTOFILL_DIALOG_VIEWS_H_ |
| OLD | NEW |