| 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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 - (void)didEndEditing:(id)sender { | 289 - (void)didEndEditing:(id)sender { |
| 290 delegate_->FocusMoved(); | 290 delegate_->FocusMoved(); |
| 291 [validationDelegate_ hideErrorBubble]; | 291 [validationDelegate_ hideErrorBubble]; |
| 292 [self validateFor:autofill::VALIDATE_EDIT]; | 292 [self validateFor:autofill::VALIDATE_EDIT]; |
| 293 [self updateEditability]; | 293 [self updateEditability]; |
| 294 } | 294 } |
| 295 | 295 |
| 296 - (void)updateSuggestionState { | 296 - (void)updateSuggestionState { |
| 297 const autofill::SuggestionState& suggestionState = | 297 const autofill::SuggestionState& suggestionState = |
| 298 delegate_->SuggestionStateForSection(section_); | 298 delegate_->SuggestionStateForSection(section_); |
| 299 // TODO(estade): use |vertically_compact_text| when it fits. | |
| 300 const base::string16& text = suggestionState.horizontally_compact_text; | |
| 301 showSuggestions_ = suggestionState.visible; | 299 showSuggestions_ = suggestionState.visible; |
| 302 | 300 |
| 303 [suggestContainer_ setSuggestionText:base::SysUTF16ToNSString(text) | |
| 304 icon:suggestionState.icon.AsNSImage()]; | |
| 305 | |
| 306 if (!suggestionState.extra_text.empty()) { | 301 if (!suggestionState.extra_text.empty()) { |
| 307 NSString* extraText = | 302 NSString* extraText = |
| 308 base::SysUTF16ToNSString(suggestionState.extra_text); | 303 base::SysUTF16ToNSString(suggestionState.extra_text); |
| 309 NSImage* extraIcon = suggestionState.extra_icon.AsNSImage(); | 304 NSImage* extraIcon = suggestionState.extra_icon.AsNSImage(); |
| 310 [suggestContainer_ showInputField:extraText withIcon:extraIcon]; | 305 [suggestContainer_ showInputField:extraText withIcon:extraIcon]; |
| 311 } | 306 } |
| 307 |
| 308 // NOTE: It's important to set the input field, if there is one, _before_ |
| 309 // setting the suggestion text, since the suggestion container needs to |
| 310 // account for the input field's width when deciding which of the two string |
| 311 // representations to use. |
| 312 NSString* verticallyCompactText = |
| 313 base::SysUTF16ToNSString(suggestionState.vertically_compact_text); |
| 314 NSString* horizontallyCompactText = |
| 315 base::SysUTF16ToNSString(suggestionState.horizontally_compact_text); |
| 316 [suggestContainer_ |
| 317 setSuggestionWithVerticallyCompactText:verticallyCompactText |
| 318 horizontallyCompactText:horizontallyCompactText |
| 319 icon:suggestionState.icon.AsNSImage() |
| 320 maxWidth:kDetailsWidth]; |
| 321 |
| 312 [view_ setShouldHighlightOnHover:showSuggestions_]; | 322 [view_ setShouldHighlightOnHover:showSuggestions_]; |
| 313 if (showSuggestions_) | 323 if (showSuggestions_) |
| 314 [view_ setClickTarget:suggestButton_]; | 324 [view_ setClickTarget:suggestButton_]; |
| 315 else | 325 else |
| 316 [view_ setClickTarget:nil]; | 326 [view_ setClickTarget:nil]; |
| 317 [view_ setHidden:!delegate_->SectionIsActive(section_)]; | 327 [view_ setHidden:!delegate_->SectionIsActive(section_)]; |
| 318 } | 328 } |
| 319 | 329 |
| 320 - (void)update { | 330 - (void)update { |
| 321 [self updateAndClobber:YES]; | 331 [self updateAndClobber:YES]; |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 - (void)activateFieldForInput:(const autofill::DetailInput&)input { | 685 - (void)activateFieldForInput:(const autofill::DetailInput&)input { |
| 676 if ([self detailInputForType:input.type] != &input) | 686 if ([self detailInputForType:input.type] != &input) |
| 677 return; | 687 return; |
| 678 | 688 |
| 679 NSControl<AutofillInputField>* field = [inputs_ viewWithTag:input.type]; | 689 NSControl<AutofillInputField>* field = [inputs_ viewWithTag:input.type]; |
| 680 [[field window] makeFirstResponder:field]; | 690 [[field window] makeFirstResponder:field]; |
| 681 [self textfieldEditedOrActivated:field edited:NO]; | 691 [self textfieldEditedOrActivated:field edited:NO]; |
| 682 } | 692 } |
| 683 | 693 |
| 684 @end | 694 @end |
| OLD | NEW |