| 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" |
| 11 #include "chrome/browser/ui/autofill/autofill_popup_view_delegate.h" | 11 #include "chrome/browser/ui/autofill/autofill_popup_view_delegate.h" |
| 12 #include "chrome/browser/ui/autofill/popup_view_common.h" | 12 #include "chrome/browser/ui/autofill/popup_view_common.h" |
| 13 #include "third_party/skia/include/core/SkColor.h" | 13 #include "third_party/skia/include/core/SkColor.h" |
| 14 #include "ui/gfx/font_list.h" | 14 #include "ui/gfx/font_list.h" |
| 15 #include "ui/gfx/geometry/rect.h" | 15 #include "ui/gfx/geometry/rect.h" |
| 16 #include "ui/gfx/native_widget_types.h" | 16 #include "ui/gfx/native_widget_types.h" |
| 17 | 17 |
| 18 namespace gfx { | 18 namespace gfx { |
| 19 class ImageSkia; | 19 class ImageSkia; |
| 20 } | 20 } |
| 21 | 21 |
| 22 namespace autofill { | 22 namespace autofill { |
| 23 | 23 |
| 24 // Helper class which keeps tracks of popup bounds and related view information. | 24 // Helper class which keeps tracks of popup bounds and related view information. |
| 25 // TODO(mathp): investigate moving ownership of this class to the view. | 25 // TODO(mathp): investigate moving ownership of this class to the view. |
| 26 class AutofillPopupLayoutModel { | 26 class AutofillPopupLayoutModel { |
| 27 public: | 27 public: |
| 28 explicit AutofillPopupLayoutModel(AutofillPopupViewDelegate* delegate); | 28 AutofillPopupLayoutModel(AutofillPopupViewDelegate* delegate, |
| 29 bool is_credit_card_popup); |
| 30 |
| 29 ~AutofillPopupLayoutModel(); | 31 ~AutofillPopupLayoutModel(); |
| 30 | 32 |
| 31 // The minimum amount of padding between the Autofill name and subtext, | 33 // The minimum amount of padding between the Autofill name and subtext, |
| 32 // in pixels. | 34 // in pixels. |
| 33 static const int kNamePadding = 15; | 35 static const int kNamePadding = 15; |
| 34 | 36 |
| 35 // The minimum amount of padding between the Autofill http warning message | 37 // The minimum amount of padding between the Autofill http warning message |
| 36 // name and subtext, in pixels. | 38 // name and subtext, in pixels. |
| 37 static const int kHttpWarningNamePadding = 8; | 39 static const int kHttpWarningNamePadding = 8; |
| 38 | 40 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 const gfx::Rect popup_bounds() const { return popup_bounds_; } | 87 const gfx::Rect popup_bounds() const { return popup_bounds_; } |
| 86 | 88 |
| 87 // Returns the bounds of the item at |index| in the popup, relative to | 89 // Returns the bounds of the item at |index| in the popup, relative to |
| 88 // the top left of the popup. | 90 // the top left of the popup. |
| 89 gfx::Rect GetRowBounds(size_t index) const; | 91 gfx::Rect GetRowBounds(size_t index) const; |
| 90 | 92 |
| 91 // Gets the resource value for the given resource, returning -1 if the | 93 // Gets the resource value for the given resource, returning -1 if the |
| 92 // resource isn't recognized. | 94 // resource isn't recognized. |
| 93 int GetIconResourceID(const base::string16& resource_name) const; | 95 int GetIconResourceID(const base::string16& resource_name) const; |
| 94 | 96 |
| 97 // Returns whether |GetBackgroundColor, GetDividerColor| returns a custom |
| 98 // color configured in an experiment to tweak autofill popup layout. |
| 99 bool IsPopupLayoutExperimentEnabled() const; |
| 100 |
| 101 // Returns the background color for the autofill popup, or |
| 102 // |SK_ColorTRANSPARENT| if not in an experiment to tweak autofill popup |
| 103 // layout. |
| 104 SkColor GetBackgroundColor() const; |
| 105 |
| 106 // Returns the divider color for the autofill popup, or |
| 107 // |SK_ColorTRANSPARENT| if not in an experiment to tweak autofill popup |
| 108 // layout. |
| 109 SkColor GetDividerColor() const; |
| 110 |
| 111 // Returns the dropdown item height, or 0 if the dropdown item height isn't |
| 112 // configured in an experiment to tweak autofill popup layout. |
| 113 unsigned int GetDropdownItemHeight() const; |
| 114 |
| 115 // Returns true if suggestion icon must be displayed before suggestion text. |
| 116 bool IsIconAtStart(int frontend_id) const; |
| 117 |
| 95 private: | 118 private: |
| 96 // Returns the enclosing rectangle for the element_bounds. | 119 // Returns the enclosing rectangle for the element_bounds. |
| 97 const gfx::Rect RoundedElementBounds() const; | 120 const gfx::Rect RoundedElementBounds() const; |
| 98 | 121 |
| 99 #if !defined(OS_ANDROID) | 122 #if !defined(OS_ANDROID) |
| 100 // The fonts for the popup text. | 123 // The fonts for the popup text. |
| 101 // Normal font (readable size, non bold). | 124 // Normal font (readable size, non bold). |
| 102 gfx::FontList normal_font_list_; | 125 gfx::FontList normal_font_list_; |
| 103 // Slightly smaller than the normal font. | 126 // Slightly smaller than the normal font. |
| 104 gfx::FontList smaller_font_list_; | 127 gfx::FontList smaller_font_list_; |
| 105 // Bold version of the normal font. | 128 // Bold version of the normal font. |
| 106 gfx::FontList bold_font_list_; | 129 gfx::FontList bold_font_list_; |
| 107 // Font used for the warning dialog, which may be italic or not depending on | 130 // Font used for the warning dialog, which may be italic or not depending on |
| 108 // the platform. | 131 // the platform. |
| 109 gfx::FontList warning_font_list_; | 132 gfx::FontList warning_font_list_; |
| 110 #endif | 133 #endif |
| 111 | 134 |
| 112 // The bounds of the Autofill popup. | 135 // The bounds of the Autofill popup. |
| 113 gfx::Rect popup_bounds_; | 136 gfx::Rect popup_bounds_; |
| 114 | 137 |
| 115 PopupViewCommon view_common_; | 138 PopupViewCommon view_common_; |
| 116 | 139 |
| 117 AutofillPopupViewDelegate* delegate_; // Weak reference. | 140 AutofillPopupViewDelegate* delegate_; // Weak reference. |
| 118 | 141 |
| 142 const bool is_credit_card_popup_; |
| 143 |
| 119 DISALLOW_COPY_AND_ASSIGN(AutofillPopupLayoutModel); | 144 DISALLOW_COPY_AND_ASSIGN(AutofillPopupLayoutModel); |
| 120 }; | 145 }; |
| 121 | 146 |
| 122 } // namespace autofill | 147 } // namespace autofill |
| 123 | 148 |
| 124 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_LAYOUT_MODEL_H_ | 149 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_LAYOUT_MODEL_H_ |
| OLD | NEW |