| Index: chrome/browser/ui/cocoa/autofill/autofill_section_container.mm
|
| diff --git a/chrome/browser/ui/cocoa/autofill/autofill_section_container.mm b/chrome/browser/ui/cocoa/autofill/autofill_section_container.mm
|
| index 8557450ef6c25d0426130f226a837cc2f07d28c8..e83fb13004829df16e73464bad0dc9e7cd66b396 100644
|
| --- a/chrome/browser/ui/cocoa/autofill/autofill_section_container.mm
|
| +++ b/chrome/browser/ui/cocoa/autofill/autofill_section_container.mm
|
| @@ -104,8 +104,8 @@ bool ShouldOverwriteComboboxes(autofill::DialogSection section,
|
| // Create a button offering input suggestions.
|
| - (MenuButton*)makeSuggestionButton;
|
|
|
| -// Create a view with all inputs requested by |delegate_|. Autoreleased.
|
| -- (LayoutView*)makeInputControls;
|
| +// Create a view with all inputs requested by |delegate_| and resets |input_|.
|
| +- (void)makeInputControls;
|
|
|
| // Refresh all field icons based on |delegate_| status.
|
| - (void)updateFieldIcons;
|
| @@ -159,27 +159,8 @@ bool ShouldOverwriteComboboxes(autofill::DialogSection section,
|
| }
|
|
|
| - (void)loadView {
|
| - // Keep a list of weak pointers to DetailInputs.
|
| - const autofill::DetailInputs& inputs =
|
| - delegate_->RequestedFieldsForSection(section_);
|
| -
|
| - // Reverse the order of all the inputs.
|
| - for (int i = inputs.size() - 1; i >= 0; --i) {
|
| - detailInputs_.push_back(&(inputs[i]));
|
| - }
|
| -
|
| - // Then right the reversal in each row.
|
| - std::vector<const autofill::DetailInput*>::iterator it;
|
| - for (it = detailInputs_.begin(); it < detailInputs_.end(); ++it) {
|
| - std::vector<const autofill::DetailInput*>::iterator start = it;
|
| - while (it != detailInputs_.end() &&
|
| - (*it)->length != autofill::DetailInput::LONG) {
|
| - ++it;
|
| - }
|
| - std::reverse(start, it);
|
| - }
|
| + [self makeInputControls];
|
|
|
| - inputs_.reset([[self makeInputControls] retain]);
|
| base::string16 labelText = delegate_->LabelForSection(section_);
|
| label_.reset(
|
| [[self makeDetailSectionLabel:base::SysUTF16ToNSString(labelText)]
|
| @@ -303,6 +284,14 @@ bool ShouldOverwriteComboboxes(autofill::DialogSection section,
|
| - (void)didEndEditing:(id)sender {
|
| delegate_->FocusMoved();
|
| [validationDelegate_ hideErrorBubble];
|
| +
|
| + AutofillPopUpButton* popup = base::mac::ObjCCast<AutofillPopUpButton>(sender);
|
| + if (popup) {
|
| + // Add one to account for the spacer at the top of the list.
|
| + int index = [popup indexOfSelectedItem] + 1;
|
| + delegate_->ComboboxItemSelected([self fieldTypeForControl:popup], index);
|
| + }
|
| +
|
| [self validateFor:autofill::VALIDATE_EDIT];
|
| [self updateEditability];
|
| }
|
| @@ -514,23 +503,28 @@ bool ShouldOverwriteComboboxes(autofill::DialogSection section,
|
| }
|
|
|
| - (void)updateAndClobber:(BOOL)shouldClobber {
|
| - const autofill::DetailInputs& updatedInputs =
|
| - delegate_->RequestedFieldsForSection(section_);
|
| + if (shouldClobber) {
|
| + [self makeInputControls];
|
| + } else {
|
| + const autofill::DetailInputs& updatedInputs =
|
| + delegate_->RequestedFieldsForSection(section_);
|
|
|
| - for (autofill::DetailInputs::const_iterator iter = updatedInputs.begin();
|
| - iter != updatedInputs.end();
|
| - ++iter) {
|
| - NSControl<AutofillInputField>* field = [inputs_ viewWithTag:iter->type];
|
| - DCHECK(field);
|
| + for (autofill::DetailInputs::const_iterator iter = updatedInputs.begin();
|
| + iter != updatedInputs.end();
|
| + ++iter) {
|
| + NSControl<AutofillInputField>* field = [inputs_ viewWithTag:iter->type];
|
| + DCHECK(field);
|
|
|
| - if (shouldClobber || [field isDefault]) {
|
| - [field setFieldValue:base::SysUTF16ToNSString(iter->initial_value)];
|
| + if (shouldClobber || [field isDefault]) {
|
| + [field setFieldValue:base::SysUTF16ToNSString(iter->initial_value)];
|
| + }
|
| + if (shouldClobber)
|
| + [field setValidityMessage:@""];
|
| }
|
| - if (shouldClobber)
|
| - [field setValidityMessage:@""];
|
| + [self updateFieldIcons];
|
| }
|
| +
|
| [self updateEditability];
|
| - [self updateFieldIcons];
|
| [self modelChanged];
|
| }
|
|
|
| @@ -571,7 +565,29 @@ bool ShouldOverwriteComboboxes(autofill::DialogSection section,
|
|
|
| // TODO(estade): we should be using Chrome-style constrained window padding
|
| // values.
|
| -- (LayoutView*)makeInputControls {
|
| +- (void)makeInputControls {
|
| + detailInputs_.clear();
|
| +
|
| + // Keep a list of weak pointers to DetailInputs.
|
| + const autofill::DetailInputs& inputs =
|
| + delegate_->RequestedFieldsForSection(section_);
|
| +
|
| + // Reverse the order of all the inputs.
|
| + for (int i = inputs.size() - 1; i >= 0; --i) {
|
| + detailInputs_.push_back(&(inputs[i]));
|
| + }
|
| +
|
| + // Then right the reversal in each row.
|
| + std::vector<const autofill::DetailInput*>::iterator it;
|
| + for (it = detailInputs_.begin(); it < detailInputs_.end(); ++it) {
|
| + std::vector<const autofill::DetailInput*>::iterator start = it;
|
| + while (it != detailInputs_.end() &&
|
| + (*it)->length != autofill::DetailInput::LONG) {
|
| + ++it;
|
| + }
|
| + std::reverse(start, it);
|
| + }
|
| +
|
| base::scoped_nsobject<LayoutView> view([[LayoutView alloc] init]);
|
| [view setLayoutManager:
|
| scoped_ptr<SimpleGridLayout>(new SimpleGridLayout(view))];
|
| @@ -621,15 +637,15 @@ bool ShouldOverwriteComboboxes(autofill::DialogSection section,
|
| base::scoped_nsobject<AutofillTextField> field(
|
| [[AutofillTextField alloc] init]);
|
| [[field cell] setPlaceholderString:
|
| - l10n_util::GetNSStringWithFixup(input.placeholder_text_rid)];
|
| + base::SysUTF16ToNSString(input.placeholder_text)];
|
| NSString* tooltipText =
|
| base::SysUTF16ToNSString(delegate_->TooltipForField(input.type));
|
| if ([tooltipText length] > 0) {
|
| - DCHECK(!tooltipController_);
|
| - DCHECK(!tooltipField_);
|
| - tooltipController_.reset(
|
| - [[AutofillTooltipController alloc]
|
| - initWithArrowLocation:info_bubble::kTopRight]);
|
| + if (!tooltipController_) {
|
| + tooltipController_.reset(
|
| + [[AutofillTooltipController alloc]
|
| + initWithArrowLocation:info_bubble::kTopRight]);
|
| + }
|
| tooltipField_ = field.get();
|
| NSImage* icon =
|
| ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed(
|
| @@ -652,12 +668,18 @@ bool ShouldOverwriteComboboxes(autofill::DialogSection section,
|
| }
|
| layout->AddView(control);
|
|
|
| - if (input.length == autofill::DetailInput::LONG)
|
| + if (input.length == autofill::DetailInput::LONG ||
|
| + input.length == autofill::DetailInput::SHORT_EOL) {
|
| ++column_set_id;
|
| + }
|
| }
|
|
|
| [self updateFieldIcons];
|
| - return view.autorelease();
|
| +
|
| + if (inputs_)
|
| + [[self view] replaceSubview:inputs_ with:view];
|
| +
|
| + inputs_ = view;
|
| }
|
|
|
| - (void)updateFieldIcons {
|
| @@ -680,13 +702,13 @@ bool ShouldOverwriteComboboxes(autofill::DialogSection section,
|
| }
|
|
|
| - (void)updateEditability {
|
| -
|
| base::scoped_nsobject<NSMutableArray> controls([[NSMutableArray alloc] init]);
|
| [self addInputsToArray:controls];
|
| for (NSControl<AutofillInputField>* control in controls.get()) {
|
| autofill::ServerFieldType type = [self fieldTypeForControl:control];
|
| const autofill::DetailInput* input = [self detailInputForType:type];
|
| - [control setEnabled:delegate_->InputIsEditable(*input, section_)];
|
| + if (input)
|
| + [control setEnabled:delegate_->InputIsEditable(*input, section_)];
|
| }
|
| }
|
|
|
|
|