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 controller_->SuggestionStateForSection(section_); | 285 controller_->SuggestionStateForSection(section_); |
286 bool showSuggestions = !suggestionState.text.empty(); | 286 // TODO(estade): use |horizontally_compact_text| when |
| 287 // |vertically_compact_text| doesn't fit. |
| 288 const base::string16& text = suggestionState.vertically_compact_text; |
| 289 bool showSuggestions = suggestionState.visible; |
287 | 290 |
288 [[suggestContainer_ view] setHidden:!showSuggestions]; | 291 [[suggestContainer_ view] setHidden:!showSuggestions]; |
289 [inputs_ setHidden:showSuggestions]; | 292 [inputs_ setHidden:showSuggestions]; |
290 | 293 |
291 string16 line1; | 294 base::string16 line1; |
292 string16 line2; | 295 base::string16 line2; |
293 BreakSuggestionText(suggestionState.text, &line1, &line2); | 296 BreakSuggestionText(text, &line1, &line2); |
294 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 297 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) | 298 [suggestContainer_ setSuggestionText:base::SysUTF16ToNSString(line1) |
298 line2:base::SysUTF16ToNSString(line2) | 299 line2:base::SysUTF16ToNSString(line2)]; |
299 withFont:font.GetNativeFont()]; | |
300 [suggestContainer_ setIcon:suggestionState.icon.AsNSImage()]; | 300 [suggestContainer_ setIcon:suggestionState.icon.AsNSImage()]; |
301 if (!suggestionState.extra_text.empty()) { | 301 if (!suggestionState.extra_text.empty()) { |
302 NSString* extraText = | 302 NSString* extraText = |
303 base::SysUTF16ToNSString(suggestionState.extra_text); | 303 base::SysUTF16ToNSString(suggestionState.extra_text); |
304 NSImage* extraIcon = suggestionState.extra_icon.AsNSImage(); | 304 NSImage* extraIcon = suggestionState.extra_icon.AsNSImage(); |
305 [suggestContainer_ showInputField:extraText withIcon:extraIcon]; | 305 [suggestContainer_ showInputField:extraText withIcon:extraIcon]; |
306 } | 306 } |
307 [view_ setShouldHighlightOnHover:showSuggestions]; | 307 [view_ setShouldHighlightOnHover:showSuggestions]; |
308 [view_ setHidden:!controller_->SectionIsActive(section_)]; | 308 [view_ setHidden:!controller_->SectionIsActive(section_)]; |
309 } | 309 } |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
623 | 623 |
624 - (void)activateFieldForInput:(const autofill::DetailInput&)input { | 624 - (void)activateFieldForInput:(const autofill::DetailInput&)input { |
625 if ([self detailInputForType:input.type] != &input) | 625 if ([self detailInputForType:input.type] != &input) |
626 return; | 626 return; |
627 | 627 |
628 NSControl<AutofillInputField>* field = [inputs_ viewWithTag:input.type]; | 628 NSControl<AutofillInputField>* field = [inputs_ viewWithTag:input.type]; |
629 [[field window] makeFirstResponder:field]; | 629 [[field window] makeFirstResponder:field]; |
630 } | 630 } |
631 | 631 |
632 @end | 632 @end |
OLD | NEW |