Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(212)

Side by Side Diff: chrome/browser/ui/views/autofill/autofill_dialog_views.h

Issue 273223002: views: Make view::Views::GetPreferredSize() const. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More compile fix for ToT Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 FieldValueMap* output) OVERRIDE; 91 FieldValueMap* output) OVERRIDE;
92 virtual base::string16 GetCvc() OVERRIDE; 92 virtual base::string16 GetCvc() OVERRIDE;
93 virtual bool SaveDetailsLocally() OVERRIDE; 93 virtual bool SaveDetailsLocally() OVERRIDE;
94 virtual const content::NavigationController* ShowSignIn() OVERRIDE; 94 virtual const content::NavigationController* ShowSignIn() OVERRIDE;
95 virtual void HideSignIn() OVERRIDE; 95 virtual void HideSignIn() OVERRIDE;
96 virtual void ModelChanged() OVERRIDE; 96 virtual void ModelChanged() OVERRIDE;
97 virtual void OnSignInResize(const gfx::Size& pref_size) OVERRIDE; 97 virtual void OnSignInResize(const gfx::Size& pref_size) OVERRIDE;
98 virtual void ValidateSection(DialogSection section) OVERRIDE; 98 virtual void ValidateSection(DialogSection section) OVERRIDE;
99 99
100 // views::View implementation. 100 // views::View implementation.
101 virtual gfx::Size GetPreferredSize() OVERRIDE; 101 virtual gfx::Size GetPreferredSize() const OVERRIDE;
102 virtual gfx::Size GetMinimumSize() OVERRIDE; 102 virtual gfx::Size GetMinimumSize() const OVERRIDE;
103 virtual void Layout() OVERRIDE; 103 virtual void Layout() OVERRIDE;
104 virtual void OnNativeThemeChanged(const ui::NativeTheme* theme) OVERRIDE; 104 virtual void OnNativeThemeChanged(const ui::NativeTheme* theme) OVERRIDE;
105 105
106 // views::DialogDelegate implementation: 106 // views::DialogDelegate implementation:
107 virtual base::string16 GetWindowTitle() const OVERRIDE; 107 virtual base::string16 GetWindowTitle() const OVERRIDE;
108 virtual void WindowClosing() OVERRIDE; 108 virtual void WindowClosing() OVERRIDE;
109 virtual void DeleteDelegate() OVERRIDE; 109 virtual void DeleteDelegate() OVERRIDE;
110 virtual views::View* CreateOverlayView() OVERRIDE; 110 virtual views::View* CreateOverlayView() OVERRIDE;
111 virtual int GetDialogButtons() const OVERRIDE; 111 virtual int GetDialogButtons() const OVERRIDE;
112 virtual int GetDefaultDialogButton() const OVERRIDE; 112 virtual int GetDefaultDialogButton() const OVERRIDE;
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 // An area for notifications. Some notifications point at the account chooser. 252 // An area for notifications. Some notifications point at the account chooser.
253 class NotificationArea : public views::View { 253 class NotificationArea : public views::View {
254 public: 254 public:
255 explicit NotificationArea(AutofillDialogViewDelegate* delegate); 255 explicit NotificationArea(AutofillDialogViewDelegate* delegate);
256 virtual ~NotificationArea(); 256 virtual ~NotificationArea();
257 257
258 // Displays the given notifications. 258 // Displays the given notifications.
259 void SetNotifications(const std::vector<DialogNotification>& notifications); 259 void SetNotifications(const std::vector<DialogNotification>& notifications);
260 260
261 // views::View implementation. 261 // views::View implementation.
262 virtual gfx::Size GetPreferredSize() OVERRIDE; 262 virtual gfx::Size GetPreferredSize() const OVERRIDE;
263 virtual const char* GetClassName() const OVERRIDE; 263 virtual const char* GetClassName() const OVERRIDE;
264 virtual void PaintChildren(gfx::Canvas* canvas, 264 virtual void PaintChildren(gfx::Canvas* canvas,
265 const views::CullSet& cull_set) OVERRIDE; 265 const views::CullSet& cull_set) OVERRIDE;
266 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; 266 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
267 267
268 void set_arrow_centering_anchor( 268 void set_arrow_centering_anchor(
269 const base::WeakPtr<views::View>& arrow_centering_anchor) { 269 const base::WeakPtr<views::View>& arrow_centering_anchor) {
270 arrow_centering_anchor_ = arrow_centering_anchor; 270 arrow_centering_anchor_ = arrow_centering_anchor;
271 } 271 }
272 272
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 DISALLOW_COPY_AND_ASSIGN(SectionContainer); 333 DISALLOW_COPY_AND_ASSIGN(SectionContainer);
334 }; 334 };
335 335
336 // A button to show address or billing suggestions. 336 // A button to show address or billing suggestions.
337 class SuggestedButton : public views::MenuButton { 337 class SuggestedButton : public views::MenuButton {
338 public: 338 public:
339 explicit SuggestedButton(views::MenuButtonListener* listener); 339 explicit SuggestedButton(views::MenuButtonListener* listener);
340 virtual ~SuggestedButton(); 340 virtual ~SuggestedButton();
341 341
342 // views::MenuButton implementation. 342 // views::MenuButton implementation.
343 virtual gfx::Size GetPreferredSize() OVERRIDE; 343 virtual gfx::Size GetPreferredSize() const OVERRIDE;
344 virtual const char* GetClassName() const OVERRIDE; 344 virtual const char* GetClassName() const OVERRIDE;
345 virtual void PaintChildren(gfx::Canvas* canvas, 345 virtual void PaintChildren(gfx::Canvas* canvas,
346 const views::CullSet& cull_set) OVERRIDE; 346 const views::CullSet& cull_set) OVERRIDE;
347 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; 347 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
348 348
349 private: 349 private:
350 // Returns the corred resource ID (i.e. IDR_*) for the current |state()|. 350 // Returns the corred resource ID (i.e. IDR_*) for the current |state()|.
351 int ResourceIDForState() const; 351 int ResourceIDForState() const;
352 352
353 DISALLOW_COPY_AND_ASSIGN(SuggestedButton); 353 DISALLOW_COPY_AND_ASSIGN(SuggestedButton);
(...skipping 25 matching lines...) Expand all
379 379
380 // A view that contains a suggestion (such as a known address). 380 // A view that contains a suggestion (such as a known address).
381 class SuggestionView : public views::View { 381 class SuggestionView : public views::View {
382 public: 382 public:
383 explicit SuggestionView(AutofillDialogViews* autofill_dialog); 383 explicit SuggestionView(AutofillDialogViews* autofill_dialog);
384 virtual ~SuggestionView(); 384 virtual ~SuggestionView();
385 385
386 void SetState(const SuggestionState& state); 386 void SetState(const SuggestionState& state);
387 387
388 // views::View implementation. 388 // views::View implementation.
389 virtual gfx::Size GetPreferredSize() OVERRIDE; 389 virtual gfx::Size GetPreferredSize() const OVERRIDE;
390 virtual int GetHeightForWidth(int width) OVERRIDE; 390 virtual int GetHeightForWidth(int width) const OVERRIDE;
391 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; 391 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE;
392 392
393 ExpandingTextfield* textfield() { return textfield_; } 393 ExpandingTextfield* textfield() { return textfield_; }
394 394
395 private: 395 private:
396 // Returns whether there's room to display |state_.vertically_compact_text| 396 // Returns whether there's room to display |state_.vertically_compact_text|
397 // without resorting to an ellipsis for a pixel width of |available_width|. 397 // without resorting to an ellipsis for a pixel width of |available_width|.
398 // Fills in |resulting_height| with the amount of space required to display 398 // Fills in |resulting_height| with the amount of space required to display
399 // |vertically_compact_text| or |horizontally_compact_text| as the case may 399 // |vertically_compact_text| or |horizontally_compact_text| as the case may
400 // be. 400 // be.
401 bool CanUseVerticallyCompactText(int available_width, 401 bool CanUseVerticallyCompactText(int available_width,
402 int* resulting_height); 402 int* resulting_height) const;
403 403
404 // Sets the display text of the suggestion. 404 // Sets the display text of the suggestion.
405 void SetLabelText(const base::string16& text); 405 void SetLabelText(const base::string16& text);
406 406
407 // Sets the icon which should be displayed ahead of the text. 407 // Sets the icon which should be displayed ahead of the text.
408 void SetIcon(const gfx::Image& image); 408 void SetIcon(const gfx::Image& image);
409 409
410 // Shows an auxiliary textfield to the right of the suggestion icon and 410 // Shows an auxiliary textfield to the right of the suggestion icon and
411 // text. This is currently only used to show a CVC field for the CC section. 411 // text. This is currently only used to show a CVC field for the CC section.
412 void SetTextfield(const base::string16& placeholder_text, 412 void SetTextfield(const base::string16& placeholder_text,
413 const gfx::Image& icon); 413 const gfx::Image& icon);
414 414
415 // Calls SetLabelText() with the appropriate text based on current bounds. 415 // Calls SetLabelText() with the appropriate text based on current bounds.
416 void UpdateLabelText(); 416 void UpdateLabelText();
417 417
418 // The state of |this|. 418 // The state of |this|.
419 SuggestionState state_; 419 SuggestionState state_;
420 420
421 // This caches preferred heights for given widths. The key is a preferred 421 // This caches preferred heights for given widths. The key is a preferred
422 // width, the value is a cached result of CanUseVerticallyCompactText. 422 // width, the value is a cached result of CanUseVerticallyCompactText.
423 std::map<int, std::pair<bool, int> > calculated_heights_; 423 mutable std::map<int, std::pair<bool, int> > calculated_heights_;
424 424
425 // The label that holds the suggestion description text. 425 // The label that holds the suggestion description text.
426 views::Label* label_; 426 views::Label* label_;
427 // The second (and greater) line of text that describes the suggestion. 427 // The second (and greater) line of text that describes the suggestion.
428 views::Label* label_line_2_; 428 views::Label* label_line_2_;
429 // The icon that comes just before |label_|. 429 // The icon that comes just before |label_|.
430 views::ImageView* icon_; 430 views::ImageView* icon_;
431 // The input set by ShowTextfield. 431 // The input set by ShowTextfield.
432 ExpandingTextfield* textfield_; 432 ExpandingTextfield* textfield_;
433 433
(...skipping 19 matching lines...) Expand all
453 // The view that holds the text of the suggested data. This will be 453 // The view that holds the text of the suggested data. This will be
454 // visible IFF |manual_input| is not visible. 454 // visible IFF |manual_input| is not visible.
455 SuggestionView* suggested_info; 455 SuggestionView* suggested_info;
456 // The view that allows selecting other data suggestions. 456 // The view that allows selecting other data suggestions.
457 SuggestedButton* suggested_button; 457 SuggestedButton* suggested_button;
458 }; 458 };
459 459
460 typedef std::map<DialogSection, DetailsGroup> DetailGroupMap; 460 typedef std::map<DialogSection, DetailsGroup> DetailGroupMap;
461 461
462 // Returns the preferred size or minimum size (if |get_minimum_size| is true). 462 // Returns the preferred size or minimum size (if |get_minimum_size| is true).
463 gfx::Size CalculatePreferredSize(bool get_minimum_size); 463 gfx::Size CalculatePreferredSize(bool get_minimum_size) const;
464 464
465 // Returns the minimum size of the sign in view for this dialog. 465 // Returns the minimum size of the sign in view for this dialog.
466 gfx::Size GetMinimumSignInViewSize() const; 466 gfx::Size GetMinimumSignInViewSize() const;
467 467
468 // Returns the maximum size of the sign in view for this dialog. 468 // Returns the maximum size of the sign in view for this dialog.
469 gfx::Size GetMaximumSignInViewSize() const; 469 gfx::Size GetMaximumSignInViewSize() const;
470 470
471 // Returns which section should currently be used for credit card info. 471 // Returns which section should currently be used for credit card info.
472 DialogSection GetCreditCardSection() const; 472 DialogSection GetCreditCardSection() const;
473 473
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 // state. 585 // state.
586 void SetEditabilityForSection(DialogSection section); 586 void SetEditabilityForSection(DialogSection section);
587 587
588 // Handles mouse presses on the non-client view. 588 // Handles mouse presses on the non-client view.
589 void NonClientMousePressed(); 589 void NonClientMousePressed();
590 590
591 // The delegate that drives this view. Weak pointer, always non-NULL. 591 // The delegate that drives this view. Weak pointer, always non-NULL.
592 AutofillDialogViewDelegate* const delegate_; 592 AutofillDialogViewDelegate* const delegate_;
593 593
594 // The preferred size of the view, cached to avoid needless recomputation. 594 // The preferred size of the view, cached to avoid needless recomputation.
595 gfx::Size preferred_size_; 595 mutable gfx::Size preferred_size_;
596 596
597 // The current number of unmatched calls to UpdatesStarted. 597 // The current number of unmatched calls to UpdatesStarted.
598 int updates_scope_; 598 int updates_scope_;
599 599
600 // True when there's been a call to ContentsPreferredSizeChanged() suppressed 600 // True when there's been a call to ContentsPreferredSizeChanged() suppressed
601 // due to an unmatched UpdatesStarted. 601 // due to an unmatched UpdatesStarted.
602 bool needs_update_; 602 bool needs_update_;
603 603
604 // The window that displays |contents_|. Weak pointer; may be NULL when the 604 // The window that displays |contents_|. Weak pointer; may be NULL when the
605 // dialog is closing. 605 // dialog is closing.
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 677
678 // Used to tell the delegate when focus moves to hide the Autofill popup. 678 // Used to tell the delegate when focus moves to hide the Autofill popup.
679 scoped_ptr<ui::EventHandler> event_handler_; 679 scoped_ptr<ui::EventHandler> event_handler_;
680 680
681 DISALLOW_COPY_AND_ASSIGN(AutofillDialogViews); 681 DISALLOW_COPY_AND_ASSIGN(AutofillDialogViews);
682 }; 682 };
683 683
684 } // namespace autofill 684 } // namespace autofill
685 685
686 #endif // CHROME_BROWSER_UI_VIEWS_AUTOFILL_AUTOFILL_DIALOG_VIEWS_H_ 686 #endif // CHROME_BROWSER_UI_VIEWS_AUTOFILL_AUTOFILL_DIALOG_VIEWS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698