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 // TODO(erikchen): Get real asset. | |
96 if (manager_->ShouldShowAccessMacContacts(query_form_, query_field_)) { | |
97 values.push_back( | |
98 l10n_util::GetStringUTF16(IDS_AUTOFILL_ACCESS_MAC_CONTACTS)); | |
99 labels.push_back(base::ASCIIToUTF16("")); | |
Ilya Sherman
2014/05/16 22:54:02
nit: "base::ASCIIToUTF16("")" -> "base::string16()
erikchen
2014/05/19 20:58:32
Done.
| |
100 icons.push_back(base::ASCIIToUTF16("americanExpressCC")); | |
Ilya Sherman
2014/05/16 22:54:02
I'd rather have no icon than a bizarre one for now
erikchen
2014/05/19 20:58:32
Done.
| |
101 ids.push_back(POPUP_ITEM_ID_MAC_ACCESS_CONTACTS); | |
102 } | |
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 // User wants to give Chromium access to user's address book. | |
173 manager_->AccessMacContacts(); | |
160 } else { | 174 } else { |
161 FillAutofillFormData(identifier, false); | 175 FillAutofillFormData(identifier, false); |
162 } | 176 } |
163 | 177 |
164 manager_->delegate()->HideAutofillPopup(); | 178 manager_->delegate()->HideAutofillPopup(); |
165 } | 179 } |
166 | 180 |
167 void AutofillExternalDelegate::RemoveSuggestion(const base::string16& value, | 181 void AutofillExternalDelegate::RemoveSuggestion(const base::string16& value, |
168 int identifier) { | 182 int identifier) { |
169 if (identifier > 0) | 183 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. | 316 // Set the values that all datalist elements share. |
303 icons->insert(icons->begin(), | 317 icons->insert(icons->begin(), |
304 data_list_values_.size(), | 318 data_list_values_.size(), |
305 base::string16()); | 319 base::string16()); |
306 unique_ids->insert(unique_ids->begin(), | 320 unique_ids->insert(unique_ids->begin(), |
307 data_list_values_.size(), | 321 data_list_values_.size(), |
308 POPUP_ITEM_ID_DATALIST_ENTRY); | 322 POPUP_ITEM_ID_DATALIST_ENTRY); |
309 } | 323 } |
310 | 324 |
311 } // namespace autofill | 325 } // namespace autofill |
OLD | NEW |