Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7181)

Unified Diff: chrome/browser/ui/cocoa/autofill/autofill_section_container.mm

Issue 63053003: Ask libaddressinput for address components to use in requestAutocomplete(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tests Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 fd38bd5bed82c2108454262c65d7e75ede7bbaa1..3c52798e571b8584df4aef157ae314fd34ce148a 100644
--- a/chrome/browser/ui/cocoa/autofill/autofill_section_container.mm
+++ b/chrome/browser/ui/cocoa/autofill/autofill_section_container.mm
@@ -103,8 +103,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_|.
groby-ooo-7-16 2013/12/05 02:56:10 Should probably mention that it replaces the old i
+- (void)makeInputControls;
// Refresh all field icons based on |delegate_| status.
- (void)updateFieldIcons;
@@ -158,27 +158,7 @@ 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);
- }
-
- inputs_.reset([[self makeInputControls] retain]);
+ [self makeInputControls];
string16 labelText = delegate_->LabelForSection(section_);
label_.reset(
[[self makeDetailSectionLabel:base::SysUTF16ToNSString(labelText)]
@@ -289,6 +269,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];
}
@@ -490,6 +478,9 @@ bool ShouldOverwriteComboboxes(autofill::DialogSection section,
}
- (void)updateAndClobber:(BOOL)shouldClobber {
+ if (shouldClobber)
+ [self makeInputControls];
+
const autofill::DetailInputs& updatedInputs =
delegate_->RequestedFieldsForSection(section_);
@@ -547,7 +538,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))];
@@ -597,7 +610,7 @@ 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)];
[field setDefaultValue:@""];
control.reset(field.release());
}
@@ -612,12 +625,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];
groby-ooo-7-16 2013/12/05 02:56:10 This must be called _after_ updating inputs_ - upd
- return view.autorelease();
+
+ if (inputs_)
+ [[self view] replaceSubview:inputs_ with:view];
+
+ inputs_ = view;
}
- (void)updateFieldIcons {
@@ -646,7 +665,8 @@ bool ShouldOverwriteComboboxes(autofill::DialogSection section,
for (NSControl<AutofillInputField>* control in controls.get()) {
autofill::ServerFieldType type = [self fieldTypeForControl:control];
const autofill::DetailInput* input = [self detailInputForType:type];
groby-ooo-7-16 2013/12/05 02:56:10 Why can this now be zero?
- [control setEnabled:delegate_->InputIsEditable(*input, section_)];
+ if (input)
+ [control setEnabled:delegate_->InputIsEditable(*input, section_)];
}
}

Powered by Google App Engine
This is Rietveld 408576698