| 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 #import "chrome/browser/ui/cocoa/autofill/autofill_popup_view_cocoa.h" | 5 #import "chrome/browser/ui/cocoa/autofill/autofill_popup_view_cocoa.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/mac/mac_util.h" | 8 #include "base/mac/mac_util.h" |
| 9 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "chrome/browser/ui/autofill/autofill_popup_controller.h" | 11 #include "chrome/browser/ui/autofill/autofill_popup_controller.h" |
| 12 #include "chrome/browser/ui/autofill/autofill_popup_layout_model.h" | 12 #include "chrome/browser/ui/autofill/autofill_popup_layout_model.h" |
| 13 #include "chrome/browser/ui/autofill/popup_constants.h" | |
| 14 #include "chrome/browser/ui/cocoa/autofill/autofill_popup_view_bridge.h" | 13 #include "chrome/browser/ui/cocoa/autofill/autofill_popup_view_bridge.h" |
| 15 #include "components/autofill/core/browser/popup_item_ids.h" | 14 #include "components/autofill/core/browser/popup_item_ids.h" |
| 16 #include "components/autofill/core/browser/suggestion.h" | 15 #include "components/autofill/core/browser/suggestion.h" |
| 17 #include "skia/ext/skia_utils_mac.h" | 16 #include "skia/ext/skia_utils_mac.h" |
| 18 #include "third_party/skia/include/core/SkColor.h" | 17 #include "third_party/skia/include/core/SkColor.h" |
| 19 #include "ui/base/cocoa/window_size_constants.h" | 18 #include "ui/base/cocoa/window_size_constants.h" |
| 20 #include "ui/base/resource/resource_bundle.h" | 19 #include "ui/base/resource/resource_bundle.h" |
| 21 #include "ui/gfx/color_palette.h" | 20 #include "ui/gfx/color_palette.h" |
| 22 #include "ui/gfx/font_list.h" | 21 #include "ui/gfx/font_list.h" |
| 23 #include "ui/gfx/geometry/point.h" | 22 #include "ui/gfx/geometry/point.h" |
| 24 #include "ui/gfx/geometry/rect.h" | 23 #include "ui/gfx/geometry/rect.h" |
| 25 #include "ui/gfx/image/image.h" | 24 #include "ui/gfx/image/image.h" |
| 26 #include "ui/gfx/image/image_skia_util_mac.h" | 25 #include "ui/gfx/image/image_skia_util_mac.h" |
| 27 #include "ui/gfx/paint_vector_icon.h" | 26 #include "ui/gfx/paint_vector_icon.h" |
| 28 #include "ui/gfx/vector_icons_public.h" | 27 #include "ui/gfx/vector_icons_public.h" |
| 28 #include "ui/native_theme/native_theme.h" |
| 29 #include "ui/native_theme/native_theme_mac.h" |
| 29 | 30 |
| 30 using autofill::AutofillPopupView; | 31 using autofill::AutofillPopupView; |
| 31 using autofill::AutofillPopupLayoutModel; | 32 using autofill::AutofillPopupLayoutModel; |
| 32 | 33 |
| 33 @interface AutofillPopupViewCocoa () | 34 @interface AutofillPopupViewCocoa () |
| 34 | 35 |
| 35 #pragma mark - | 36 #pragma mark - |
| 36 #pragma mark Private methods | 37 #pragma mark Private methods |
| 37 | 38 |
| 38 // Draws an Autofill suggestion in the given |bounds|, labeled with the given | 39 // Draws an Autofill suggestion in the given |bounds|, labeled with the given |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 (controller_->GetSuggestionAt(index).frontend_id == | 164 (controller_->GetSuggestionAt(index).frontend_id == |
| 164 autofill::POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE); | 165 autofill::POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE); |
| 165 | 166 |
| 166 // If this row is selected, highlight it with this mac system color. | 167 // If this row is selected, highlight it with this mac system color. |
| 167 // Otherwise the controller may have a specific background color for this | 168 // Otherwise the controller may have a specific background color for this |
| 168 // entry. | 169 // entry. |
| 169 if (isSelected) { | 170 if (isSelected) { |
| 170 [[self highlightColor] set]; | 171 [[self highlightColor] set]; |
| 171 [NSBezierPath fillRect:bounds]; | 172 [NSBezierPath fillRect:bounds]; |
| 172 } else { | 173 } else { |
| 173 SkColor backgroundColor = controller_->GetBackgroundColorForRow(index); | 174 SkColor backgroundColor = |
| 175 ui::NativeTheme::GetInstanceForNativeUi()->GetSystemColor( |
| 176 controller_->GetBackgroundColorIDForRow(index)); |
| 174 [skia::SkColorToSRGBNSColor(backgroundColor) set]; | 177 [skia::SkColorToSRGBNSColor(backgroundColor) set]; |
| 175 [NSBezierPath fillRect:bounds]; | 178 [NSBezierPath fillRect:bounds]; |
| 176 } | 179 } |
| 177 | 180 |
| 178 BOOL isRTL = controller_->IsRTL(); | 181 BOOL isRTL = controller_->IsRTL(); |
| 179 | 182 |
| 180 // The X values of the left and right borders of the autofill widget. | 183 // The X values of the left and right borders of the autofill widget. |
| 181 CGFloat leftX = NSMinX(bounds) + AutofillPopupLayoutModel::kEndPadding; | 184 CGFloat leftX = NSMinX(bounds) + AutofillPopupLayoutModel::kEndPadding; |
| 182 CGFloat rightX = NSMaxX(bounds) - AutofillPopupLayoutModel::kEndPadding; | 185 CGFloat rightX = NSMaxX(bounds) - AutofillPopupLayoutModel::kEndPadding; |
| 183 | 186 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 206 textYOffset:textYOffset]; | 209 textYOffset:textYOffset]; |
| 207 } | 210 } |
| 208 | 211 |
| 209 - (CGFloat)drawName:(NSString*)name | 212 - (CGFloat)drawName:(NSString*)name |
| 210 atX:(CGFloat)x | 213 atX:(CGFloat)x |
| 211 index:(size_t)index | 214 index:(size_t)index |
| 212 rightAlign:(BOOL)rightAlign | 215 rightAlign:(BOOL)rightAlign |
| 213 bounds:(NSRect)bounds | 216 bounds:(NSRect)bounds |
| 214 textYOffset:(CGFloat)textYOffset { | 217 textYOffset:(CGFloat)textYOffset { |
| 215 NSColor* nameColor = skia::SkColorToSRGBNSColor( | 218 NSColor* nameColor = skia::SkColorToSRGBNSColor( |
| 216 controller_->layout_model().GetValueFontColorForRow(index)); | 219 ui::NativeTheme::GetInstanceForNativeUi()->GetSystemColor( |
| 220 controller_->layout_model().GetValueFontColorIDForRow(index))); |
| 217 NSDictionary* nameAttributes = [NSDictionary | 221 NSDictionary* nameAttributes = [NSDictionary |
| 218 dictionaryWithObjectsAndKeys:controller_->layout_model() | 222 dictionaryWithObjectsAndKeys:controller_->layout_model() |
| 219 .GetValueFontListForRow(index) | 223 .GetValueFontListForRow(index) |
| 220 .GetPrimaryFont() | 224 .GetPrimaryFont() |
| 221 .GetNativeFont(), | 225 .GetNativeFont(), |
| 222 NSFontAttributeName, nameColor, | 226 NSFontAttributeName, nameColor, |
| 223 NSForegroundColorAttributeName, nil]; | 227 NSForegroundColorAttributeName, nil]; |
| 224 NSSize nameSize = [name sizeWithAttributes:nameAttributes]; | 228 NSSize nameSize = [name sizeWithAttributes:nameAttributes]; |
| 225 x -= rightAlign ? nameSize.width : 0; | 229 x -= rightAlign ? nameSize.width : 0; |
| 226 CGFloat y = bounds.origin.y + (bounds.size.height - nameSize.height) / 2; | 230 CGFloat y = bounds.origin.y + (bounds.size.height - nameSize.height) / 2; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 } | 304 } |
| 301 | 305 |
| 302 int iconId = delegate_->GetIconResourceID(icon); | 306 int iconId = delegate_->GetIconResourceID(icon); |
| 303 DCHECK_NE(-1, iconId); | 307 DCHECK_NE(-1, iconId); |
| 304 | 308 |
| 305 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 309 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 306 return rb.GetNativeImageNamed(iconId).ToNSImage(); | 310 return rb.GetNativeImageNamed(iconId).ToNSImage(); |
| 307 } | 311 } |
| 308 | 312 |
| 309 @end | 313 @end |
| OLD | NEW |