Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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_AUTOFILL_AUTOFILL_POPUP_LAYOUT_MODEL_H_ | 5 #ifndef CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_LAYOUT_MODEL_H_ |
| 6 #define CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_LAYOUT_MODEL_H_ | 6 #define CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_LAYOUT_MODEL_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 namespace ui { | 23 namespace ui { |
| 24 class KeyEvent; | 24 class KeyEvent; |
| 25 } | 25 } |
| 26 | 26 |
| 27 namespace autofill { | 27 namespace autofill { |
| 28 | 28 |
| 29 // Helper class which keeps tracks of popup bounds and related view information. | 29 // Helper class which keeps tracks of popup bounds and related view information. |
| 30 // TODO(mathp): investigate moving ownership of this class to the view. | 30 // TODO(mathp): investigate moving ownership of this class to the view. |
| 31 class AutofillPopupLayoutModel { | 31 class AutofillPopupLayoutModel { |
| 32 public: | 32 public: |
| 33 explicit AutofillPopupLayoutModel(AutofillPopupViewDelegate* delegate); | 33 AutofillPopupLayoutModel(AutofillPopupViewDelegate* delegate, |
| 34 bool is_credit_card_field); | |
|
Mathieu
2016/12/01 21:59:47
nit: the name makes it seem like there is one layo
csashi
2016/12/02 05:15:29
Done.
| |
| 35 | |
| 34 ~AutofillPopupLayoutModel(); | 36 ~AutofillPopupLayoutModel(); |
| 35 | 37 |
| 36 // The minimum amount of padding between the Autofill name and subtext, | 38 // The minimum amount of padding between the Autofill name and subtext, |
| 37 // in pixels. | 39 // in pixels. |
| 38 static const int kNamePadding = 15; | 40 static const int kNamePadding = 15; |
| 39 | 41 |
| 40 // The amount of padding between icons in pixels. | 42 // The amount of padding between icons in pixels. |
| 41 static const int kIconPadding = 5; | 43 static const int kIconPadding = 5; |
| 42 | 44 |
| 43 // The amount of padding at the end of the popup in pixels. | 45 // The amount of padding at the end of the popup in pixels. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 79 const gfx::Rect popup_bounds() const { return popup_bounds_; } | 81 const gfx::Rect popup_bounds() const { return popup_bounds_; } |
| 80 | 82 |
| 81 // Returns the bounds of the item at |index| in the popup, relative to | 83 // Returns the bounds of the item at |index| in the popup, relative to |
| 82 // the top left of the popup. | 84 // the top left of the popup. |
| 83 gfx::Rect GetRowBounds(size_t index) const; | 85 gfx::Rect GetRowBounds(size_t index) const; |
| 84 | 86 |
| 85 // Gets the resource value for the given resource, returning -1 if the | 87 // Gets the resource value for the given resource, returning -1 if the |
| 86 // resource isn't recognized. | 88 // resource isn't recognized. |
| 87 int GetIconResourceID(const base::string16& resource_name) const; | 89 int GetIconResourceID(const base::string16& resource_name) const; |
| 88 | 90 |
| 91 // Returns whether |GetBackgroundColor, GetDividerColor| returns a custom | |
| 92 // color configured in an experiment to tweak autofill popup layout. | |
| 93 bool IsPopupLayoutExperimentEnabled() const; | |
| 94 | |
| 95 // Returns the background color for the autofill popup, or | |
| 96 // |SK_ColorTRANSPARENT| if not in an experiment to tweak autofill popup | |
| 97 // layout. | |
| 98 SkColor GetBackgroundColor() const; | |
| 99 | |
| 100 // Returns the divider color for the autofill popup, or | |
| 101 // |SK_ColorTRANSPARENT| if not in an experiment to tweak autofill popup | |
| 102 // layout. | |
| 103 SkColor GetDividerColor() const; | |
| 104 | |
| 105 // Returns the dropdown item height, or 0 if the dropdown item height isn't | |
| 106 // configured in an experiment to tweak autofill popup layout. | |
| 107 unsigned int GetDropdownItemHeight() const; | |
| 108 | |
| 109 // Returns true if suggestion icon must be displayed to left of suggestion | |
| 110 // text. | |
| 111 bool IsIconAtLeft() const; | |
| 112 | |
| 89 private: | 113 private: |
| 90 // Returns the enclosing rectangle for the element_bounds. | 114 // Returns the enclosing rectangle for the element_bounds. |
| 91 const gfx::Rect RoundedElementBounds() const; | 115 const gfx::Rect RoundedElementBounds() const; |
| 92 | 116 |
| 93 #if !defined(OS_ANDROID) | 117 #if !defined(OS_ANDROID) |
| 94 // The fonts for the popup text. | 118 // The fonts for the popup text. |
| 95 // Normal font (readable size, non bold). | 119 // Normal font (readable size, non bold). |
| 96 gfx::FontList normal_font_list_; | 120 gfx::FontList normal_font_list_; |
| 97 // Slightly smaller than the normal font. | 121 // Slightly smaller than the normal font. |
| 98 gfx::FontList smaller_font_list_; | 122 gfx::FontList smaller_font_list_; |
| 99 // Bold version of the normal font. | 123 // Bold version of the normal font. |
| 100 gfx::FontList bold_font_list_; | 124 gfx::FontList bold_font_list_; |
| 101 // Font used for the warning dialog, which may be italic or not depending on | 125 // Font used for the warning dialog, which may be italic or not depending on |
| 102 // the platform. | 126 // the platform. |
| 103 gfx::FontList warning_font_list_; | 127 gfx::FontList warning_font_list_; |
| 104 #endif | 128 #endif |
| 105 | 129 |
| 106 // The bounds of the Autofill popup. | 130 // The bounds of the Autofill popup. |
| 107 gfx::Rect popup_bounds_; | 131 gfx::Rect popup_bounds_; |
| 108 | 132 |
| 109 PopupViewCommon view_common_; | 133 PopupViewCommon view_common_; |
| 110 | 134 |
| 111 AutofillPopupViewDelegate* delegate_; // Weak reference. | 135 AutofillPopupViewDelegate* delegate_; // Weak reference. |
| 112 | 136 |
| 137 const bool is_credit_card_field_; | |
| 138 | |
| 113 DISALLOW_COPY_AND_ASSIGN(AutofillPopupLayoutModel); | 139 DISALLOW_COPY_AND_ASSIGN(AutofillPopupLayoutModel); |
| 114 }; | 140 }; |
| 115 | 141 |
| 116 } // namespace autofill | 142 } // namespace autofill |
| 117 | 143 |
| 118 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_LAYOUT_MODEL_H_ | 144 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_LAYOUT_MODEL_H_ |
| OLD | NEW |