Chromium Code Reviews| 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 // Prefer the vertically compact text when it fits. If it doesn't fit, fall | |
| 309 // back to the horizontally compact text. | |
| 310 NSString* vertically_compact_text = | |
| 311 base::SysUTF16ToNSString(suggestionState.vertically_compact_text); | |
| 312 [suggestContainer_ setSuggestionText:vertically_compact_text | |
| 313 icon:suggestionState.icon.AsNSImage() | |
| 314 wrapText:NO]; | |
| 315 if ([suggestContainer_ preferredSize].width > kDetailsWidth) { | |
|
groby-ooo-7-16
2013/12/14 04:39:19
Shouldn't that logic just happen in the suggestCon
Ilya Sherman
2013/12/14 05:02:27
Done.
| |
| 316 NSString* horizontally_compact_text = | |
| 317 base::SysUTF16ToNSString(suggestionState.horizontally_compact_text); | |
| 318 [suggestContainer_ setSuggestionText:horizontally_compact_text | |
| 319 icon:suggestionState.icon.AsNSImage() | |
| 320 wrapText:YES]; | |
| 321 } | |
| 322 | |
| 312 [view_ setShouldHighlightOnHover:showSuggestions_]; | 323 [view_ setShouldHighlightOnHover:showSuggestions_]; |
| 313 if (showSuggestions_) | 324 if (showSuggestions_) |
| 314 [view_ setClickTarget:suggestButton_]; | 325 [view_ setClickTarget:suggestButton_]; |
| 315 else | 326 else |
| 316 [view_ setClickTarget:nil]; | 327 [view_ setClickTarget:nil]; |
| 317 [view_ setHidden:!delegate_->SectionIsActive(section_)]; | 328 [view_ setHidden:!delegate_->SectionIsActive(section_)]; |
| 318 } | 329 } |
| 319 | 330 |
| 320 - (void)update { | 331 - (void)update { |
| 321 [self updateAndClobber:YES]; | 332 [self updateAndClobber:YES]; |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 675 - (void)activateFieldForInput:(const autofill::DetailInput&)input { | 686 - (void)activateFieldForInput:(const autofill::DetailInput&)input { |
| 676 if ([self detailInputForType:input.type] != &input) | 687 if ([self detailInputForType:input.type] != &input) |
| 677 return; | 688 return; |
| 678 | 689 |
| 679 NSControl<AutofillInputField>* field = [inputs_ viewWithTag:input.type]; | 690 NSControl<AutofillInputField>* field = [inputs_ viewWithTag:input.type]; |
| 680 [[field window] makeFirstResponder:field]; | 691 [[field window] makeFirstResponder:field]; |
| 681 [self textfieldEditedOrActivated:field edited:NO]; | 692 [self textfieldEditedOrActivated:field edited:NO]; |
| 682 } | 693 } |
| 683 | 694 |
| 684 @end | 695 @end |
| OLD | NEW |