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

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

Issue 144073004: rAc: remove bold section labels on linux_aura. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ui::ResourceBundle::BoldOnlyIfItLooksGood() Created 6 years, 11 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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_section_container.h" 5 #import "chrome/browser/ui/cocoa/autofill/autofill_section_container.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/mac/foundation_util.h" 9 #include "base/mac/foundation_util.h"
10 #include "base/strings/sys_string_conversions.h" 10 #include "base/strings/sys_string_conversions.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 92
93 // Updates input fields based on delegate status. If |shouldClobber| is YES, 93 // Updates input fields based on delegate status. If |shouldClobber| is YES,
94 // will clobber existing data and reset fields to the initial values. 94 // will clobber existing data and reset fields to the initial values.
95 - (void)updateAndClobber:(BOOL)shouldClobber; 95 - (void)updateAndClobber:(BOOL)shouldClobber;
96 96
97 // Return YES if this is a section that contains CC info. (And, more 97 // Return YES if this is a section that contains CC info. (And, more
98 // importantly, a potential CVV field) 98 // importantly, a potential CVV field)
99 - (BOOL)isCreditCardSection; 99 - (BOOL)isCreditCardSection;
100 100
101 // Create properly styled label for section. Autoreleased. 101 // Create properly styled label for section. Autoreleased.
102 - (NSTextField*)makeDetailSectionLabel:(NSString*)labelText; 102 - (NSTextField*)makeDetailSectionLabel:(const autofill::SectionLabel&)label;
103 103
104 // Create a button offering input suggestions. 104 // Create a button offering input suggestions.
105 - (MenuButton*)makeSuggestionButton; 105 - (MenuButton*)makeSuggestionButton;
106 106
107 // Create a view with all inputs requested by |delegate_| and resets |input_|. 107 // Create a view with all inputs requested by |delegate_| and resets |input_|.
108 - (void)makeInputControls; 108 - (void)makeInputControls;
109 109
110 // Refresh all field icons based on |delegate_| status. 110 // Refresh all field icons based on |delegate_| status.
111 - (void)updateFieldIcons; 111 - (void)updateFieldIcons;
112 112
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 154
155 // Always request re-layout on state change. 155 // Always request re-layout on state change.
156 id delegate = [[view_ window] windowController]; 156 id delegate = [[view_ window] windowController];
157 if ([delegate respondsToSelector:@selector(requestRelayout)]) 157 if ([delegate respondsToSelector:@selector(requestRelayout)])
158 [delegate performSelector:@selector(requestRelayout)]; 158 [delegate performSelector:@selector(requestRelayout)];
159 } 159 }
160 160
161 - (void)loadView { 161 - (void)loadView {
162 [self makeInputControls]; 162 [self makeInputControls];
163 163
164 base::string16 labelText = delegate_->LabelForSection(section_); 164 const autofill::SectionLabel label = delegate_->LabelForSection(section_);
165 label_.reset( 165 label_.reset([[self makeDetailSectionLabel:label] retain]);
166 [[self makeDetailSectionLabel:base::SysUTF16ToNSString(labelText)]
167 retain]);
168 166
169 suggestButton_.reset([[self makeSuggestionButton] retain]); 167 suggestButton_.reset([[self makeSuggestionButton] retain]);
170 suggestContainer_.reset([[AutofillSuggestionContainer alloc] init]); 168 suggestContainer_.reset([[AutofillSuggestionContainer alloc] init]);
171 169
172 view_.reset([[AutofillSectionView alloc] initWithFrame:NSZeroRect]); 170 view_.reset([[AutofillSectionView alloc] initWithFrame:NSZeroRect]);
173 [self setView:view_]; 171 [self setView:view_];
174 [view_ setSubviews: 172 [view_ setSubviews:
175 @[label_, inputs_, [suggestContainer_ view], suggestButton_]]; 173 @[label_, inputs_, [suggestContainer_ view], suggestButton_]];
176 if (tooltipController_) { 174 if (tooltipController_) {
177 [view_ addSubview:[tooltipController_ view] 175 [view_ addSubview:[tooltipController_ view]
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 fromControls:(NSArray*)controls { 469 fromControls:(NSArray*)controls {
472 for (NSControl<AutofillInputField>* input in controls) { 470 for (NSControl<AutofillInputField>* input in controls) {
473 DCHECK([input isKindOfClass:[NSControl class]]); 471 DCHECK([input isKindOfClass:[NSControl class]]);
474 DCHECK([input conformsToProtocol:@protocol(AutofillInputField)]); 472 DCHECK([input conformsToProtocol:@protocol(AutofillInputField)]);
475 outputs->insert(std::make_pair( 473 outputs->insert(std::make_pair(
476 [self fieldTypeForControl:input], 474 [self fieldTypeForControl:input],
477 base::SysNSStringToUTF16([input fieldValue]))); 475 base::SysNSStringToUTF16([input fieldValue])));
478 } 476 }
479 } 477 }
480 478
481 - (NSTextField*)makeDetailSectionLabel:(NSString*)labelText { 479 - (NSTextField*)makeDetailSectionLabel:(const autofill::SectionLabel&)label {
482 base::scoped_nsobject<NSTextField> label([[NSTextField alloc] init]); 480 base::scoped_nsobject<NSTextField> textfield([[NSTextField alloc] init]);
483 [label setFont: 481 if (label.font & ui::ResourceBundle::BoldFont) {
Nico 2014/01/23 03:13:56 bitmasks in an api are bad api
484 [[NSFontManager sharedFontManager] convertFont:[label font] 482 [textfield setFont:
485 toHaveTrait:NSBoldFontMask]]; 483 [[NSFontManager sharedFontManager] convertFont:[textfield font]
486 [label setStringValue:labelText]; 484 toHaveTrait:NSBoldFontMask]];
487 [label setEditable:NO]; 485 }
488 [label setBordered:NO]; 486 [textfield setStringValue:base::SysUTF16ToNSString(label.text)];
489 [label setDrawsBackground:NO]; 487 [textfield setEditable:NO];
490 [label sizeToFit]; 488 [textfield setBordered:NO];
491 return label.autorelease(); 489 [textfield setDrawsBackground:NO];
490 [textfield sizeToFit];
491 return textfield.autorelease();
492 } 492 }
493 493
494 - (void)updateAndClobber:(BOOL)shouldClobber { 494 - (void)updateAndClobber:(BOOL)shouldClobber {
495 if (shouldClobber) { 495 if (shouldClobber) {
496 [self makeInputControls]; 496 [self makeInputControls];
497 } else { 497 } else {
498 const autofill::DetailInputs& updatedInputs = 498 const autofill::DetailInputs& updatedInputs =
499 delegate_->RequestedFieldsForSection(section_); 499 delegate_->RequestedFieldsForSection(section_);
500 500
501 for (autofill::DetailInputs::const_iterator iter = updatedInputs.begin(); 501 for (autofill::DetailInputs::const_iterator iter = updatedInputs.begin();
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 731
732 - (void)activateFieldForType:(autofill::ServerFieldType)type { 732 - (void)activateFieldForType:(autofill::ServerFieldType)type {
733 NSControl<AutofillInputField>* field = [inputs_ viewWithTag:type]; 733 NSControl<AutofillInputField>* field = [inputs_ viewWithTag:type];
734 if (field) { 734 if (field) {
735 [[field window] makeFirstResponder:field]; 735 [[field window] makeFirstResponder:field];
736 [self fieldEditedOrActivated:field edited:NO]; 736 [self fieldEditedOrActivated:field edited:NO];
737 } 737 }
738 } 738 }
739 739
740 @end 740 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698