| 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 "chrome/browser/ui/autofill/autofill_dialog_controller.h" | 8 #include "chrome/browser/ui/autofill/autofill_dialog_controller.h" |
| 9 #include "chrome/browser/ui/autofill/autofill_dialog_view.h" | 9 #include "chrome/browser/ui/autofill/autofill_dialog_view.h" |
| 10 #include "ui/views/controls/button/button.h" | 10 #include "ui/views/controls/button/button.h" |
| 11 #include "ui/views/controls/button/menu_button_listener.h" | 11 #include "ui/views/controls/button/menu_button_listener.h" |
| 12 #include "ui/views/controls/textfield/textfield_controller.h" | 12 #include "ui/views/controls/textfield/textfield_controller.h" |
| 13 #include "ui/views/focus/focus_manager.h" | 13 #include "ui/views/focus/focus_manager.h" |
| 14 #include "ui/views/window/dialog_delegate.h" | 14 #include "ui/views/window/dialog_delegate.h" |
| 15 | 15 |
| 16 class ConstrainedWindowViews; | 16 class ConstrainedWindowViews; |
| 17 | 17 |
| 18 namespace views { | 18 namespace views { |
| 19 class Checkbox; | 19 class Checkbox; |
| 20 class Combobox; | 20 class Combobox; |
| 21 class ImageButton; |
| 21 class Label; | 22 class Label; |
| 22 class MenuButton; | |
| 23 class MenuRunner; | 23 class MenuRunner; |
| 24 class Textfield; | 24 class Textfield; |
| 25 } | 25 } |
| 26 | 26 |
| 27 namespace ui { | 27 namespace ui { |
| 28 class ComboboxModel; | 28 class ComboboxModel; |
| 29 class KeyEvent; | 29 class KeyEvent; |
| 30 } | 30 } |
| 31 | 31 |
| 32 namespace autofill { | 32 namespace autofill { |
| 33 | 33 |
| 34 struct DetailInput; | 34 struct DetailInput; |
| 35 | 35 |
| 36 // Views toolkit implementation of the Autofill dialog that handles the | 36 // Views toolkit implementation of the Autofill dialog that handles the |
| 37 // imperative autocomplete API call. | 37 // imperative autocomplete API call. |
| 38 class AutofillDialogViews : public AutofillDialogView, | 38 class AutofillDialogViews : public AutofillDialogView, |
| 39 public views::DialogDelegate, | 39 public views::DialogDelegate, |
| 40 public views::ButtonListener, | 40 public views::ButtonListener, |
| 41 public views::MenuButtonListener, | |
| 42 public views::TextfieldController, | 41 public views::TextfieldController, |
| 43 public views::FocusChangeListener { | 42 public views::FocusChangeListener { |
| 44 public: | 43 public: |
| 45 explicit AutofillDialogViews(AutofillDialogController* controller); | 44 explicit AutofillDialogViews(AutofillDialogController* controller); |
| 46 virtual ~AutofillDialogViews(); | 45 virtual ~AutofillDialogViews(); |
| 47 | 46 |
| 48 // AutofillDialogView implementation: | 47 // AutofillDialogView implementation: |
| 49 virtual void Show() OVERRIDE; | 48 virtual void Show() OVERRIDE; |
| 50 virtual void UpdateSection(DialogSection section) OVERRIDE; | 49 virtual void UpdateSection(DialogSection section) OVERRIDE; |
| 51 virtual void GetUserInput(DialogSection section, | 50 virtual void GetUserInput(DialogSection section, |
| 52 DetailOutputMap* output) OVERRIDE; | 51 DetailOutputMap* output) OVERRIDE; |
| 53 virtual bool UseBillingForShipping() OVERRIDE; | 52 virtual bool UseBillingForShipping() OVERRIDE; |
| 54 | 53 |
| 55 // views::DialogDelegate implementation: | 54 // views::DialogDelegate implementation: |
| 56 virtual string16 GetWindowTitle() const OVERRIDE; | 55 virtual string16 GetWindowTitle() const OVERRIDE; |
| 57 virtual void WindowClosing() OVERRIDE; | 56 virtual void WindowClosing() OVERRIDE; |
| 58 virtual void DeleteDelegate() OVERRIDE; | 57 virtual void DeleteDelegate() OVERRIDE; |
| 59 virtual views::Widget* GetWidget() OVERRIDE; | 58 virtual views::Widget* GetWidget() OVERRIDE; |
| 60 virtual const views::Widget* GetWidget() const OVERRIDE; | 59 virtual const views::Widget* GetWidget() const OVERRIDE; |
| 61 virtual views::View* GetContentsView() OVERRIDE; | 60 virtual views::View* GetContentsView() OVERRIDE; |
| 62 virtual string16 GetDialogButtonLabel(ui::DialogButton button) const OVERRIDE; | 61 virtual string16 GetDialogButtonLabel(ui::DialogButton button) const OVERRIDE; |
| 63 virtual bool IsDialogButtonEnabled(ui::DialogButton button) const OVERRIDE; | 62 virtual bool IsDialogButtonEnabled(ui::DialogButton button) const OVERRIDE; |
| 64 virtual bool Cancel() OVERRIDE; | 63 virtual bool Cancel() OVERRIDE; |
| 65 virtual bool Accept() OVERRIDE; | 64 virtual bool Accept() OVERRIDE; |
| 66 | 65 |
| 67 // views::ButtonListener implementation: | 66 // views::ButtonListener implementation: |
| 68 virtual void ButtonPressed(views::Button* sender, | 67 virtual void ButtonPressed(views::Button* sender, |
| 69 const ui::Event& event) OVERRIDE; | 68 const ui::Event& event) OVERRIDE; |
| 70 | 69 |
| 71 // views::MenuButtonListener implementation: | |
| 72 virtual void OnMenuButtonClicked(views::View* source, | |
| 73 const gfx::Point& point) OVERRIDE; | |
| 74 | |
| 75 // views::TextfieldController implementation: | 70 // views::TextfieldController implementation: |
| 76 virtual void ContentsChanged(views::Textfield* sender, | 71 virtual void ContentsChanged(views::Textfield* sender, |
| 77 const string16& new_contents) OVERRIDE; | 72 const string16& new_contents) OVERRIDE; |
| 78 virtual bool HandleKeyEvent(views::Textfield* sender, | 73 virtual bool HandleKeyEvent(views::Textfield* sender, |
| 79 const ui::KeyEvent& key_event) OVERRIDE; | 74 const ui::KeyEvent& key_event) OVERRIDE; |
| 80 | 75 |
| 81 // views::FocusChangeListener implementation. | 76 // views::FocusChangeListener implementation. |
| 82 virtual void OnWillChangeFocus(views::View* focused_before, | 77 virtual void OnWillChangeFocus(views::View* focused_before, |
| 83 views::View* focused_now) OVERRIDE; | 78 views::View* focused_now) OVERRIDE; |
| 84 virtual void OnDidChangeFocus(views::View* focused_before, | 79 virtual void OnDidChangeFocus(views::View* focused_before, |
| 85 views::View* focused_now) OVERRIDE; | 80 views::View* focused_now) OVERRIDE; |
| 86 | 81 |
| 87 private: | 82 private: |
| 88 typedef std::map<const DetailInput*, views::Textfield*> TextfieldMap; | 83 typedef std::map<const DetailInput*, views::Textfield*> TextfieldMap; |
| 89 typedef std::map<const DetailInput*, views::Combobox*> ComboboxMap; | 84 typedef std::map<const DetailInput*, views::Combobox*> ComboboxMap; |
| 90 | 85 |
| 86 // A view that packs a label on the left and some related controls |
| 87 // on the right. |
| 88 class SectionContainer : public views::View { |
| 89 public: |
| 90 SectionContainer(const string16& label, |
| 91 views::View* controls, |
| 92 views::Button* proxy_button); |
| 93 virtual ~SectionContainer(); |
| 94 |
| 95 // Sets whether mouse events should be forwarded to |proxy_button_|. |
| 96 void SetForwardMouseEvents(bool forward); |
| 97 |
| 98 // views::View implementation. |
| 99 virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE; |
| 100 virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE; |
| 101 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; |
| 102 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE; |
| 103 |
| 104 private: |
| 105 // Converts |event| to one suitable for |proxy_button_|. |
| 106 static ui::MouseEvent ProxyEvent(const ui::MouseEvent& event); |
| 107 |
| 108 // Mouse events on |this| are sent to this button. |
| 109 views::Button* proxy_button_; // Weak reference. |
| 110 |
| 111 // When true, mouse events will be forwarded to |proxy_button_|. |
| 112 bool forward_mouse_events_; |
| 113 |
| 114 DISALLOW_COPY_AND_ASSIGN(SectionContainer); |
| 115 }; |
| 116 |
| 91 // A convenience struct for holding pointers to views within each detail | 117 // A convenience struct for holding pointers to views within each detail |
| 92 // section. None of the member pointers are owned. | 118 // section. None of the member pointers are owned. |
| 93 struct DetailsGroup { | 119 struct DetailsGroup { |
| 94 explicit DetailsGroup(DialogSection section); | 120 explicit DetailsGroup(DialogSection section); |
| 95 ~DetailsGroup(); | 121 ~DetailsGroup(); |
| 96 | 122 |
| 97 // The section this group is associated with. | 123 // The section this group is associated with. |
| 98 const DialogSection section; | 124 const DialogSection section; |
| 99 // The view that contains the entire section (label + input). | 125 // The view that contains the entire section (label + input). |
| 100 views::View* container; | 126 SectionContainer* container; |
| 101 // The view that allows manual input. | 127 // The view that allows manual input. |
| 102 views::View* manual_input; | 128 views::View* manual_input; |
| 103 // The textfields in |manual_input|, tracked by their DetailInput. | 129 // The textfields in |manual_input|, tracked by their DetailInput. |
| 104 TextfieldMap textfields; | 130 TextfieldMap textfields; |
| 105 // The comboboxes in |manual_input|, tracked by their DetailInput. | 131 // The comboboxes in |manual_input|, tracked by their DetailInput. |
| 106 ComboboxMap comboboxes; | 132 ComboboxMap comboboxes; |
| 107 // The label that holds the text of the suggested data. This will be | 133 // The label that holds the text of the suggested data. This will be |
| 108 // visible IFF |manual_input| is not visible. | 134 // visible IFF |manual_input| is not visible. |
| 109 views::Label* suggested_info; | 135 views::Label* suggested_info; |
| 110 // The view that allows selecting other data suggestions. | 136 // The view that allows selecting other data suggestions. |
| 111 views::MenuButton* suggested_button; | 137 views::ImageButton* suggested_button; |
| 112 }; | 138 }; |
| 113 | 139 |
| 114 void InitChildViews(); | 140 void InitChildViews(); |
| 115 | 141 |
| 116 // Creates and returns a view that holds all detail sections. | 142 // Creates and returns a view that holds all detail sections. |
| 117 views::View* CreateDetailsContainer(); | 143 views::View* CreateDetailsContainer(); |
| 118 | 144 |
| 119 // Creates and returns a view that holds the requesting host and intro text. | 145 // Creates and returns a view that holds the requesting host and intro text. |
| 120 views::View* CreateIntroContainer(); | 146 views::View* CreateIntroContainer(); |
| 121 | 147 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 | 195 |
| 170 // Runs the suggestion menu (triggered by each section's |suggested_button|. | 196 // Runs the suggestion menu (triggered by each section's |suggested_button|. |
| 171 scoped_ptr<views::MenuRunner> menu_runner_; | 197 scoped_ptr<views::MenuRunner> menu_runner_; |
| 172 | 198 |
| 173 DISALLOW_COPY_AND_ASSIGN(AutofillDialogViews); | 199 DISALLOW_COPY_AND_ASSIGN(AutofillDialogViews); |
| 174 }; | 200 }; |
| 175 | 201 |
| 176 } // namespace autofill | 202 } // namespace autofill |
| 177 | 203 |
| 178 #endif // CHROME_BROWSER_UI_VIEWS_AUTOFILL_AUTOFILL_DIALOG_VIEWS_H_ | 204 #endif // CHROME_BROWSER_UI_VIEWS_AUTOFILL_AUTOFILL_DIALOG_VIEWS_H_ |
| OLD | NEW |