OLD | NEW |
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 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 [self textfieldEditedOrActivated:sender edited:YES]; | 276 [self textfieldEditedOrActivated:sender edited:YES]; |
277 } | 277 } |
278 | 278 |
279 - (void)didEndEditing:(id)sender { | 279 - (void)didEndEditing:(id)sender { |
280 [self validateFor:autofill::VALIDATE_EDIT]; | 280 [self validateFor:autofill::VALIDATE_EDIT]; |
281 } | 281 } |
282 | 282 |
283 - (void)updateSuggestionState { | 283 - (void)updateSuggestionState { |
284 const autofill::SuggestionState& suggestionState = | 284 const autofill::SuggestionState& suggestionState = |
285 delegate_->SuggestionStateForSection(section_); | 285 delegate_->SuggestionStateForSection(section_); |
286 bool showSuggestions = !suggestionState.text.empty(); | 286 // TODO(estade): use |vertically_compact_text| when it fits. |
| 287 const base::string16& text = suggestionState.horizontally_compact_text; |
| 288 bool showSuggestions = suggestionState.visible; |
287 | 289 |
288 [[suggestContainer_ view] setHidden:!showSuggestions]; | 290 [[suggestContainer_ view] setHidden:!showSuggestions]; |
289 [inputs_ setHidden:showSuggestions]; | 291 [inputs_ setHidden:showSuggestions]; |
290 | 292 |
291 string16 line1; | 293 base::string16 line1; |
292 string16 line2; | 294 base::string16 line2; |
293 BreakSuggestionText(suggestionState.text, &line1, &line2); | 295 BreakSuggestionText(text, &line1, &line2); |
294 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | |
295 gfx::Font font = rb.GetFont(ui::ResourceBundle::BaseFont).DeriveFont( | |
296 0, suggestionState.text_style); | |
297 [suggestContainer_ setSuggestionText:base::SysUTF16ToNSString(line1) | 296 [suggestContainer_ setSuggestionText:base::SysUTF16ToNSString(line1) |
298 line2:base::SysUTF16ToNSString(line2) | 297 line2:base::SysUTF16ToNSString(line2)]; |
299 withFont:font.GetNativeFont()]; | |
300 [suggestContainer_ setIcon:suggestionState.icon.AsNSImage()]; | 298 [suggestContainer_ setIcon:suggestionState.icon.AsNSImage()]; |
301 if (!suggestionState.extra_text.empty()) { | 299 if (!suggestionState.extra_text.empty()) { |
302 NSString* extraText = | 300 NSString* extraText = |
303 base::SysUTF16ToNSString(suggestionState.extra_text); | 301 base::SysUTF16ToNSString(suggestionState.extra_text); |
304 NSImage* extraIcon = suggestionState.extra_icon.AsNSImage(); | 302 NSImage* extraIcon = suggestionState.extra_icon.AsNSImage(); |
305 [suggestContainer_ showInputField:extraText withIcon:extraIcon]; | 303 [suggestContainer_ showInputField:extraText withIcon:extraIcon]; |
306 } | 304 } |
307 [view_ setShouldHighlightOnHover:showSuggestions]; | 305 [view_ setShouldHighlightOnHover:showSuggestions]; |
308 [view_ setHidden:!delegate_->SectionIsActive(section_)]; | 306 [view_ setHidden:!delegate_->SectionIsActive(section_)]; |
309 } | 307 } |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
623 | 621 |
624 - (void)activateFieldForInput:(const autofill::DetailInput&)input { | 622 - (void)activateFieldForInput:(const autofill::DetailInput&)input { |
625 if ([self detailInputForType:input.type] != &input) | 623 if ([self detailInputForType:input.type] != &input) |
626 return; | 624 return; |
627 | 625 |
628 NSControl<AutofillInputField>* field = [inputs_ viewWithTag:input.type]; | 626 NSControl<AutofillInputField>* field = [inputs_ viewWithTag:input.type]; |
629 [[field window] makeFirstResponder:field]; | 627 [[field window] makeFirstResponder:field]; |
630 } | 628 } |
631 | 629 |
632 @end | 630 @end |
OLD | NEW |