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

Side by Side Diff: chrome/browser/ui/cocoa/autofill/autofill_popup_view_cocoa.mm

Issue 2563863003: [Autofill] Remove AutofillPopupController::IsWarning() (Closed)
Patch Set: fix Created 4 years 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
« no previous file with comments | « chrome/browser/ui/cocoa/autofill/autofill_popup_base_view_cocoa.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #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/strings/sys_string_conversions.h" 8 #include "base/strings/sys_string_conversions.h"
9 #include "chrome/browser/ui/autofill/autofill_popup_controller.h" 9 #include "chrome/browser/ui/autofill/autofill_popup_controller.h"
10 #include "chrome/browser/ui/autofill/autofill_popup_layout_model.h" 10 #include "chrome/browser/ui/autofill/autofill_popup_layout_model.h"
11 #include "chrome/browser/ui/autofill/popup_constants.h" 11 #include "chrome/browser/ui/autofill/popup_constants.h"
12 #include "chrome/browser/ui/cocoa/autofill/autofill_popup_view_bridge.h" 12 #include "chrome/browser/ui/cocoa/autofill/autofill_popup_view_bridge.h"
13 #include "components/autofill/core/browser/popup_item_ids.h" 13 #include "components/autofill/core/browser/popup_item_ids.h"
14 #include "components/autofill/core/browser/suggestion.h" 14 #include "components/autofill/core/browser/suggestion.h"
15 #include "skia/ext/skia_utils_mac.h" 15 #include "skia/ext/skia_utils_mac.h"
16 #include "third_party/skia/include/core/SkColor.h" 16 #include "third_party/skia/include/core/SkColor.h"
17 #include "ui/base/cocoa/window_size_constants.h" 17 #include "ui/base/cocoa/window_size_constants.h"
18 #include "ui/base/resource/resource_bundle.h" 18 #include "ui/base/resource/resource_bundle.h"
19 #include "ui/gfx/color_palette.h"
Robert Sesek 2016/12/14 20:14:21 Unused include?
19 #include "ui/gfx/font_list.h" 20 #include "ui/gfx/font_list.h"
20 #include "ui/gfx/geometry/point.h" 21 #include "ui/gfx/geometry/point.h"
21 #include "ui/gfx/geometry/rect.h" 22 #include "ui/gfx/geometry/rect.h"
22 #include "ui/gfx/image/image.h" 23 #include "ui/gfx/image/image.h"
23 24
24 using autofill::AutofillPopupView; 25 using autofill::AutofillPopupView;
25 using autofill::AutofillPopupLayoutModel; 26 using autofill::AutofillPopupLayoutModel;
26 27
27 @interface AutofillPopupViewCocoa () 28 @interface AutofillPopupViewCocoa ()
28 29
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 bounds:bounds 191 bounds:bounds
191 textYOffset:textYOffset]; 192 textYOffset:textYOffset];
192 } 193 }
193 194
194 - (CGFloat)drawName:(NSString*)name 195 - (CGFloat)drawName:(NSString*)name
195 atX:(CGFloat)x 196 atX:(CGFloat)x
196 index:(size_t)index 197 index:(size_t)index
197 rightAlign:(BOOL)rightAlign 198 rightAlign:(BOOL)rightAlign
198 bounds:(NSRect)bounds 199 bounds:(NSRect)bounds
199 textYOffset:(CGFloat)textYOffset { 200 textYOffset:(CGFloat)textYOffset {
200 // TODO(crbug.com/666189): Use 201 SkColor skColor = controller_->layout_model().GetValueFontColorForRow(index);
201 // AutofillPopupLayoutModel::GetValueFontColorForRow() instead and remove 202 NSColor* nameColor = skia::SkColorToSRGBNSColor(skColor);
Robert Sesek 2016/12/14 20:14:21 Since skColor is only used here you could just do:
202 // IsWarning() method.
203 NSColor* nameColor =
204 controller_->IsWarning(index) ? [self warningColor] : [self nameColor];
205 NSDictionary* nameAttributes = [NSDictionary 203 NSDictionary* nameAttributes = [NSDictionary
206 dictionaryWithObjectsAndKeys:controller_->layout_model() 204 dictionaryWithObjectsAndKeys:controller_->layout_model()
207 .GetValueFontListForRow(index) 205 .GetValueFontListForRow(index)
208 .GetPrimaryFont() 206 .GetPrimaryFont()
209 .GetNativeFont(), 207 .GetNativeFont(),
210 NSFontAttributeName, nameColor, 208 NSFontAttributeName, nameColor,
211 NSForegroundColorAttributeName, nil]; 209 NSForegroundColorAttributeName, nil];
212 NSSize nameSize = [name sizeWithAttributes:nameAttributes]; 210 NSSize nameSize = [name sizeWithAttributes:nameAttributes];
213 x -= rightAlign ? nameSize.width : 0; 211 x -= rightAlign ? nameSize.width : 0;
214 CGFloat y = bounds.origin.y + (bounds.size.height - nameSize.height) / 2; 212 CGFloat y = bounds.origin.y + (bounds.size.height - nameSize.height) / 2;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 return nil; 269 return nil;
272 270
273 int iconId = delegate_->GetIconResourceID(icon); 271 int iconId = delegate_->GetIconResourceID(icon);
274 DCHECK_NE(-1, iconId); 272 DCHECK_NE(-1, iconId);
275 273
276 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 274 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
277 return rb.GetNativeImageNamed(iconId).ToNSImage(); 275 return rb.GetNativeImageNamed(iconId).ToNSImage();
278 } 276 }
279 277
280 @end 278 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/autofill/autofill_popup_base_view_cocoa.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698