| 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 "chrome/browser/ui/autofill/autofill_dialog_controller.h" | 11 #include "chrome/browser/ui/autofill/autofill_dialog_controller.h" |
| 11 #include "chrome/browser/ui/autofill/autofill_dialog_view.h" | 12 #include "chrome/browser/ui/autofill/autofill_dialog_view.h" |
| 12 #include "ui/views/controls/button/button.h" | 13 #include "ui/views/controls/button/button.h" |
| 13 #include "ui/views/controls/button/menu_button_listener.h" | 14 #include "ui/views/controls/button/menu_button_listener.h" |
| 14 #include "ui/views/controls/link_listener.h" | 15 #include "ui/views/controls/link_listener.h" |
| 15 #include "ui/views/controls/progress_bar.h" | 16 #include "ui/views/controls/progress_bar.h" |
| 16 #include "ui/views/controls/textfield/textfield_controller.h" | 17 #include "ui/views/controls/textfield/textfield_controller.h" |
| 17 #include "ui/views/focus/focus_manager.h" | 18 #include "ui/views/focus/focus_manager.h" |
| 18 #include "ui/views/window/dialog_delegate.h" | 19 #include "ui/views/window/dialog_delegate.h" |
| 19 | 20 |
| 20 class ConstrainedWindowViews; | 21 class ConstrainedWindowViews; |
| 21 | 22 |
| 22 namespace content { | 23 namespace content { |
| 23 class KeyboardListener; | 24 class KeyboardListener; |
| 24 } | 25 } |
| 25 | 26 |
| 26 namespace gfx { | 27 namespace gfx { |
| 28 class Font; |
| 27 class Image; | 29 class Image; |
| 28 } | 30 } |
| 29 | 31 |
| 30 namespace views { | 32 namespace views { |
| 31 class Checkbox; | 33 class Checkbox; |
| 32 class Combobox; | 34 class Combobox; |
| 33 class FocusManager; | 35 class FocusManager; |
| 36 class GridLayout; |
| 34 class ImageButton; | 37 class ImageButton; |
| 35 class ImageView; | 38 class ImageView; |
| 36 class Label; | 39 class Label; |
| 37 class Link; | 40 class Link; |
| 38 class MenuRunner; | 41 class MenuRunner; |
| 39 class TextButton; | 42 class TextButton; |
| 40 class Textfield; | 43 class Textfield; |
| 41 class WebView; | 44 class WebView; |
| 42 } | 45 } |
| 43 | 46 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 69 virtual void UpdateNotificationArea() OVERRIDE; | 72 virtual void UpdateNotificationArea() OVERRIDE; |
| 70 virtual void UpdateSection(DialogSection section) OVERRIDE; | 73 virtual void UpdateSection(DialogSection section) OVERRIDE; |
| 71 virtual void GetUserInput(DialogSection section, | 74 virtual void GetUserInput(DialogSection section, |
| 72 DetailOutputMap* output) OVERRIDE; | 75 DetailOutputMap* output) OVERRIDE; |
| 73 virtual string16 GetCvc() OVERRIDE; | 76 virtual string16 GetCvc() OVERRIDE; |
| 74 virtual bool UseBillingForShipping() OVERRIDE; | 77 virtual bool UseBillingForShipping() OVERRIDE; |
| 75 virtual bool SaveDetailsLocally() OVERRIDE; | 78 virtual bool SaveDetailsLocally() OVERRIDE; |
| 76 virtual const content::NavigationController& ShowSignIn() OVERRIDE; | 79 virtual const content::NavigationController& ShowSignIn() OVERRIDE; |
| 77 virtual void HideSignIn() OVERRIDE; | 80 virtual void HideSignIn() OVERRIDE; |
| 78 virtual void UpdateProgressBar(double value) OVERRIDE; | 81 virtual void UpdateProgressBar(double value) OVERRIDE; |
| 82 virtual void UpdateFootnote() OVERRIDE; |
| 79 | 83 |
| 80 // views::DialogDelegate implementation: | 84 // views::DialogDelegate implementation: |
| 81 virtual string16 GetWindowTitle() const OVERRIDE; | 85 virtual string16 GetWindowTitle() const OVERRIDE; |
| 82 virtual void WindowClosing() OVERRIDE; | 86 virtual void WindowClosing() OVERRIDE; |
| 83 virtual void DeleteDelegate() OVERRIDE; | 87 virtual void DeleteDelegate() OVERRIDE; |
| 84 virtual views::Widget* GetWidget() OVERRIDE; | 88 virtual views::Widget* GetWidget() OVERRIDE; |
| 85 virtual const views::Widget* GetWidget() const OVERRIDE; | 89 virtual const views::Widget* GetWidget() const OVERRIDE; |
| 86 virtual views::View* GetContentsView() OVERRIDE; | 90 virtual views::View* GetContentsView() OVERRIDE; |
| 87 virtual string16 GetDialogButtonLabel(ui::DialogButton button) const OVERRIDE; | 91 virtual string16 GetDialogButtonLabel(ui::DialogButton button) const OVERRIDE; |
| 88 virtual bool IsDialogButtonEnabled(ui::DialogButton button) const OVERRIDE; | 92 virtual bool IsDialogButtonEnabled(ui::DialogButton button) const OVERRIDE; |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 // visible IFF |manual_input| is not visible. | 259 // visible IFF |manual_input| is not visible. |
| 256 SuggestionView* suggested_info; | 260 SuggestionView* suggested_info; |
| 257 // The view that allows selecting other data suggestions. | 261 // The view that allows selecting other data suggestions. |
| 258 views::ImageButton* suggested_button; | 262 views::ImageButton* suggested_button; |
| 259 }; | 263 }; |
| 260 | 264 |
| 261 class AutocheckoutProgressBar : public views::ProgressBar { | 265 class AutocheckoutProgressBar : public views::ProgressBar { |
| 262 public: | 266 public: |
| 263 AutocheckoutProgressBar(); | 267 AutocheckoutProgressBar(); |
| 264 | 268 |
| 265 private: | |
| 266 // Overidden from View: | 269 // Overidden from View: |
| 267 virtual gfx::Size GetPreferredSize() OVERRIDE; | 270 virtual gfx::Size GetPreferredSize() OVERRIDE; |
| 268 | 271 |
| 272 private: |
| 269 DISALLOW_COPY_AND_ASSIGN(AutocheckoutProgressBar); | 273 DISALLOW_COPY_AND_ASSIGN(AutocheckoutProgressBar); |
| 270 }; | 274 }; |
| 271 | 275 |
| 276 class FootnoteView : public views::View { |
| 277 public: |
| 278 FootnoteView(); |
| 279 virtual ~FootnoteView(); |
| 280 |
| 281 void AddLabel(views::Label* label, bool is_link); |
| 282 int IndexOfLink(views::Label* link); // Returns -1 if not found. |
| 283 |
| 284 // views::View implementation. |
| 285 virtual std::string GetClassName() const OVERRIDE; |
| 286 virtual void Layout() OVERRIDE; |
| 287 |
| 288 private: |
| 289 struct FootnoteLabel { |
| 290 scoped_ptr<views::Label> label; |
| 291 bool is_link; |
| 292 }; |
| 293 |
| 294 void StartRow(); |
| 295 views::View* CurrentRow(); |
| 296 void ResetLayoutManager(); |
| 297 void ResetRows(); |
| 298 |
| 299 void AppendText(const string16& text_part); |
| 300 const string16& CurrentText() const; |
| 301 void ResetText(); |
| 302 |
| 303 void AddWidth(size_t width); |
| 304 size_t CurrentWidth() const; |
| 305 int ParentWidth(); |
| 306 void ResetWidth(); |
| 307 int WidthRemaining(); |
| 308 |
| 309 void AddCloneWithWidth(views::Label* label, size_t width); |
| 310 views::Label* CloneLabel(const string16& text, |
| 311 const gfx::Font& font, |
| 312 bool is_link); |
| 313 void TransferListener(views::Label* from_label, views::Label* to_label); |
| 314 |
| 315 void Reset(); |
| 316 |
| 317 ScopedVector<FootnoteLabel> footnote_labels_; // owned by us. |
| 318 std::vector<views::Label*> links_; // weak. |
| 319 string16 current_text_; |
| 320 |
| 321 size_t current_width_; |
| 322 views::GridLayout* layout_; // weak; owned by view hierarchy. |
| 323 int previous_parent_width_; |
| 324 const int single_column_set_; |
| 325 |
| 326 DISALLOW_COPY_AND_ASSIGN(FootnoteView); |
| 327 }; |
| 328 |
| 272 typedef std::map<DialogSection, DetailsGroup> DetailGroupMap; | 329 typedef std::map<DialogSection, DetailsGroup> DetailGroupMap; |
| 273 | 330 |
| 274 void InitChildViews(); | 331 void InitChildViews(); |
| 275 | 332 |
| 276 // Creates and returns a view that holds all detail sections. | 333 // Creates and returns a view that holds all detail sections. |
| 277 views::View* CreateDetailsContainer(); | 334 views::View* CreateDetailsContainer(); |
| 278 | 335 |
| 279 // Creates and returns a view that holds the requesting host and intro text. | 336 // Creates and returns a view that holds the requesting host and intro text. |
| 280 views::View* CreateNotificationArea(); | 337 views::View* CreateNotificationArea(); |
| 281 | 338 |
| 339 // Creates and returns a view that holds the main controls of this dialog. |
| 340 views::View* CreateMainContainer(); |
| 341 |
| 282 // Creates and returns a view that holds a sign in page and related controls. | 342 // Creates and returns a view that holds a sign in page and related controls. |
| 283 views::View* CreateSignInContainer(); | 343 views::View* CreateSignInContainer(); |
| 284 | 344 |
| 285 // Creates and returns a view that holds the main controls of this dialog. | 345 // Creates footnote container. |
| 286 views::View* CreateMainContainer(); | 346 void CreateFootnoteView(); |
| 347 |
| 348 // [Re-]populates footnote links based on the controller's link text parts. |
| 349 void PopulateFootnoteLinks(); |
| 287 | 350 |
| 288 // Creates a detail section (Shipping, Email, etc.) with the given label, | 351 // Creates a detail section (Shipping, Email, etc.) with the given label, |
| 289 // inputs View, and suggestion model. Relevant pointers are stored in |group|. | 352 // inputs View, and suggestion model. Relevant pointers are stored in |group|. |
| 290 void CreateDetailsSection(DialogSection section); | 353 void CreateDetailsSection(DialogSection section); |
| 291 | 354 |
| 292 // Like CreateDetailsSection, but creates the combined billing/cc section, | 355 // Like CreateDetailsSection, but creates the combined billing/cc section, |
| 293 // which is somewhat more complicated than the others. | 356 // which is somewhat more complicated than the others. |
| 294 void CreateBillingSection(); | 357 void CreateBillingSection(); |
| 295 | 358 |
| 296 // Creates the view that holds controls for inputing or selecting data for | 359 // Creates the view that holds controls for inputing or selecting data for |
| (...skipping 19 matching lines...) Expand all Loading... |
| 316 // Checks all manual inputs in the form for validity. Decorates the invalid | 379 // Checks all manual inputs in the form for validity. Decorates the invalid |
| 317 // ones and returns true if all were valid. | 380 // ones and returns true if all were valid. |
| 318 bool ValidateForm(); | 381 bool ValidateForm(); |
| 319 | 382 |
| 320 // When an input textfield is edited (its contents change) or activated | 383 // When an input textfield is edited (its contents change) or activated |
| 321 // (clicked while focused), this function will inform the controller that it's | 384 // (clicked while focused), this function will inform the controller that it's |
| 322 // time to show a suggestion popup and possibly reset the validity state of | 385 // time to show a suggestion popup and possibly reset the validity state of |
| 323 // the input. | 386 // the input. |
| 324 void TextfieldEditedOrActivated(views::Textfield* textfield, bool was_edit); | 387 void TextfieldEditedOrActivated(views::Textfield* textfield, bool was_edit); |
| 325 | 388 |
| 389 // When something inside of |contents_| could've changed in height, call this |
| 390 // to ensure |contents_|' preferred size is correct. |
| 391 void ContentsResized(); |
| 392 |
| 326 // The controller that drives this view. Weak pointer, always non-NULL. | 393 // The controller that drives this view. Weak pointer, always non-NULL. |
| 327 AutofillDialogController* const controller_; | 394 AutofillDialogController* const controller_; |
| 328 | 395 |
| 329 // True if the termination action was a submit. | 396 // True if the termination action was a submit. |
| 330 bool did_submit_; | 397 bool did_submit_; |
| 331 | 398 |
| 332 // The window that displays |contents_|. Weak pointer; may be NULL when the | 399 // The window that displays |contents_|. Weak pointer; may be NULL when the |
| 333 // dialog is closing. | 400 // dialog is closing. |
| 334 ConstrainedWindowViews* window_; | 401 ConstrainedWindowViews* window_; |
| 335 | 402 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 // This checkbox controls whether new details are saved to the Autofill | 439 // This checkbox controls whether new details are saved to the Autofill |
| 373 // database. It lives in |extra_view_|. | 440 // database. It lives in |extra_view_|. |
| 374 views::Checkbox* save_in_chrome_checkbox_; | 441 views::Checkbox* save_in_chrome_checkbox_; |
| 375 | 442 |
| 376 // View to host |autocheckout_progress_bar_| and its label. | 443 // View to host |autocheckout_progress_bar_| and its label. |
| 377 views::View* autocheckout_progress_bar_view_; | 444 views::View* autocheckout_progress_bar_view_; |
| 378 | 445 |
| 379 // Progress bar for displaying Autocheckout progress. | 446 // Progress bar for displaying Autocheckout progress. |
| 380 AutocheckoutProgressBar* autocheckout_progress_bar_; | 447 AutocheckoutProgressBar* autocheckout_progress_bar_; |
| 381 | 448 |
| 449 // View shown when accepting of a new Terms of Service is required. Lives |
| 450 // below the Cancel/Submit buttons. |
| 451 FootnoteView* footnote_view_; |
| 452 |
| 382 // The focus manager for |window_|. | 453 // The focus manager for |window_|. |
| 383 views::FocusManager* focus_manager_; | 454 views::FocusManager* focus_manager_; |
| 384 | 455 |
| 385 DISALLOW_COPY_AND_ASSIGN(AutofillDialogViews); | 456 DISALLOW_COPY_AND_ASSIGN(AutofillDialogViews); |
| 386 }; | 457 }; |
| 387 | 458 |
| 388 } // namespace autofill | 459 } // namespace autofill |
| 389 | 460 |
| 390 #endif // CHROME_BROWSER_UI_VIEWS_AUTOFILL_AUTOFILL_DIALOG_VIEWS_H_ | 461 #endif // CHROME_BROWSER_UI_VIEWS_AUTOFILL_AUTOFILL_DIALOG_VIEWS_H_ |
| OLD | NEW |