OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #include "components/autofill/core/browser/autofill_external_delegate.h" | 5 #include "components/autofill/core/browser/autofill_external_delegate.h" |
6 | 6 |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "components/autofill/core/browser/autocomplete_history_manager.h" | 8 #include "components/autofill/core/browser/autocomplete_history_manager.h" |
9 #include "components/autofill/core/browser/autofill_driver.h" | 9 #include "components/autofill/core/browser/autofill_driver.h" |
10 #include "components/autofill/core/browser/autofill_manager.h" | 10 #include "components/autofill/core/browser/autofill_manager.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
84 labels.pop_back(); | 84 labels.pop_back(); |
85 icons.pop_back(); | 85 icons.pop_back(); |
86 ids.pop_back(); | 86 ids.pop_back(); |
87 } | 87 } |
88 | 88 |
89 // If anything else is added to modify the values after inserting the data | 89 // If anything else is added to modify the values after inserting the data |
90 // list, AutofillPopupControllerImpl::UpdateDataListValues will need to be | 90 // list, AutofillPopupControllerImpl::UpdateDataListValues will need to be |
91 // updated to match. | 91 // updated to match. |
92 InsertDataListValues(&values, &labels, &icons, &ids); | 92 InsertDataListValues(&values, &labels, &icons, &ids); |
93 | 93 |
94 #if defined(OS_MACOSX) | |
95 if (values.empty() && !manager_->HasPromptedForAccessToAddressBook() && | |
96 manager_->FieldSupportsAddressBookAutofill(query_form_, query_field_)) { | |
97 values.push_back( | |
98 l10n_util::GetStringUTF16(IDS_AUTOFILL_ACCESS_MAC_CONTACTS)); | |
99 labels.push_back(base::string16()); | |
100 icons.push_back(base::string16()); | |
101 ids.push_back(POPUP_ITEM_ID_MAC_ACCESS_CONTACTS); | |
102 } | |
Ilya Sherman
2014/05/21 11:29:15
Sorry, I think I gave you bad advice earlier about
erikchen
2014/05/21 22:00:54
I don't think that your suggestion will work as yo
| |
103 #endif | |
104 | |
94 if (values.empty()) { | 105 if (values.empty()) { |
95 // No suggestions, any popup currently showing is obsolete. | 106 // No suggestions, any popup currently showing is obsolete. |
96 manager_->delegate()->HideAutofillPopup(); | 107 manager_->delegate()->HideAutofillPopup(); |
97 return; | 108 return; |
98 } | 109 } |
99 | 110 |
100 // Send to display. | 111 // Send to display. |
101 if (query_field_.is_focusable) { | 112 if (query_field_.is_focusable) { |
102 manager_->delegate()->ShowAutofillPopup( | 113 manager_->delegate()->ShowAutofillPopup( |
103 element_bounds_, | 114 element_bounds_, |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
150 } else if (identifier == POPUP_ITEM_ID_CLEAR_FORM) { | 161 } else if (identifier == POPUP_ITEM_ID_CLEAR_FORM) { |
151 // User selected 'Clear form'. | 162 // User selected 'Clear form'. |
152 driver_->RendererShouldClearFilledForm(); | 163 driver_->RendererShouldClearFilledForm(); |
153 } else if (identifier == POPUP_ITEM_ID_PASSWORD_ENTRY) { | 164 } else if (identifier == POPUP_ITEM_ID_PASSWORD_ENTRY) { |
154 NOTREACHED(); // Should be handled elsewhere. | 165 NOTREACHED(); // Should be handled elsewhere. |
155 } else if (identifier == POPUP_ITEM_ID_DATALIST_ENTRY) { | 166 } else if (identifier == POPUP_ITEM_ID_DATALIST_ENTRY) { |
156 driver_->RendererShouldAcceptDataListSuggestion(value); | 167 driver_->RendererShouldAcceptDataListSuggestion(value); |
157 } else if (identifier == POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY) { | 168 } else if (identifier == POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY) { |
158 // User selected an Autocomplete, so we fill directly. | 169 // User selected an Autocomplete, so we fill directly. |
159 driver_->RendererShouldFillFieldWithValue(value); | 170 driver_->RendererShouldFillFieldWithValue(value); |
171 } else if (identifier == POPUP_ITEM_ID_MAC_ACCESS_CONTACTS) { | |
172 #if defined(OS_MACOSX) | |
173 // User wants to give Chromium access to user's address book. | |
174 manager_->AccessAddressBook(); | |
Ilya Sherman
2014/05/21 11:29:15
This should also re-issue the Autofill query, sinc
erikchen
2014/05/21 22:00:54
Good point. I've updated the logic to do this.
| |
175 #else | |
176 NOTREACHED(); | |
177 #endif | |
160 } else { | 178 } else { |
161 FillAutofillFormData(identifier, false); | 179 FillAutofillFormData(identifier, false); |
162 } | 180 } |
163 | 181 |
164 manager_->delegate()->HideAutofillPopup(); | 182 manager_->delegate()->HideAutofillPopup(); |
165 } | 183 } |
166 | 184 |
167 void AutofillExternalDelegate::RemoveSuggestion(const base::string16& value, | 185 void AutofillExternalDelegate::RemoveSuggestion(const base::string16& value, |
168 int identifier) { | 186 int identifier) { |
169 if (identifier > 0) | 187 if (identifier > 0) |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
302 // Set the values that all datalist elements share. | 320 // Set the values that all datalist elements share. |
303 icons->insert(icons->begin(), | 321 icons->insert(icons->begin(), |
304 data_list_values_.size(), | 322 data_list_values_.size(), |
305 base::string16()); | 323 base::string16()); |
306 unique_ids->insert(unique_ids->begin(), | 324 unique_ids->insert(unique_ids->begin(), |
307 data_list_values_.size(), | 325 data_list_values_.size(), |
308 POPUP_ITEM_ID_DATALIST_ENTRY); | 326 POPUP_ITEM_ID_DATALIST_ENTRY); |
309 } | 327 } |
310 | 328 |
311 } // namespace autofill | 329 } // namespace autofill |
OLD | NEW |