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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 should_show_cc_signin_promo_ = | 76 should_show_cc_signin_promo_ = |
77 manager_->ShouldShowCreditCardSigninPromo(query_form_, query_field_); | 77 manager_->ShouldShowCreditCardSigninPromo(query_form_, query_field_); |
78 } | 78 } |
79 | 79 |
80 void AutofillExternalDelegate::OnSuggestionsReturned( | 80 void AutofillExternalDelegate::OnSuggestionsReturned( |
81 int query_id, | 81 int query_id, |
82 const std::vector<Suggestion>& input_suggestions) { | 82 const std::vector<Suggestion>& input_suggestions) { |
83 if (query_id != query_id_) | 83 if (query_id != query_id_) |
84 return; | 84 return; |
85 | 85 |
86 // The suggestions and warnings are "above the fold" and are separated from | |
87 // other menu items with a separator. | |
88 std::vector<Suggestion> suggestions(input_suggestions); | 86 std::vector<Suggestion> suggestions(input_suggestions); |
| 87 |
89 // Hide warnings as appropriate. | 88 // Hide warnings as appropriate. |
90 PossiblyRemoveAutofillWarnings(&suggestions); | 89 PossiblyRemoveAutofillWarnings(&suggestions); |
91 | 90 |
92 #if !defined(OS_ANDROID) | 91 #if !defined(OS_ANDROID) |
93 // If there are above the fold suggestions at this point, add a separator to | 92 // If there are above the fold suggestions at this point, add a separator to |
94 // go between the values and menu items. | 93 // go between the values and menu items. |
95 if (!suggestions.empty()) { | 94 if (!suggestions.empty()) { |
96 suggestions.push_back(Suggestion()); | 95 suggestions.push_back(Suggestion()); |
97 suggestions.back().frontend_id = POPUP_ITEM_ID_SEPARATOR; | 96 suggestions.back().frontend_id = POPUP_ITEM_ID_SEPARATOR; |
98 } | 97 } |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 } | 331 } |
333 } | 332 } |
334 | 333 |
335 void AutofillExternalDelegate::ApplyAutofillOptions( | 334 void AutofillExternalDelegate::ApplyAutofillOptions( |
336 std::vector<Suggestion>* suggestions) { | 335 std::vector<Suggestion>* suggestions) { |
337 // The form has been auto-filled, so give the user the chance to clear the | 336 // The form has been auto-filled, so give the user the chance to clear the |
338 // form. Append the 'Clear form' menu item. | 337 // form. Append the 'Clear form' menu item. |
339 if (query_field_.is_autofilled) { | 338 if (query_field_.is_autofilled) { |
340 base::string16 value = | 339 base::string16 value = |
341 l10n_util::GetStringUTF16(IDS_AUTOFILL_CLEAR_FORM_MENU_ITEM); | 340 l10n_util::GetStringUTF16(IDS_AUTOFILL_CLEAR_FORM_MENU_ITEM); |
| 341 #if defined(OS_ANDROID) |
342 if (IsKeyboardAccessoryEnabled()) | 342 if (IsKeyboardAccessoryEnabled()) |
343 value = base::i18n::ToUpper(value); | 343 value = base::i18n::ToUpper(value); |
| 344 #endif |
344 | 345 |
345 suggestions->push_back(Suggestion(value)); | 346 suggestions->push_back(Suggestion(value)); |
346 suggestions->back().frontend_id = POPUP_ITEM_ID_CLEAR_FORM; | 347 suggestions->back().frontend_id = POPUP_ITEM_ID_CLEAR_FORM; |
347 } | 348 } |
348 | 349 |
349 // Append the 'Chrome Autofill options' menu item, or the menu item specified | 350 // Append the 'Chrome Autofill options' menu item, or the menu item specified |
350 // in the popup layout experiment. | 351 // in the popup layout experiment. If we do not include |
| 352 // |POPUP_ITEM_ID_CLEAR_FORM|, include a hint for keyboard accessory. |
351 suggestions->push_back(Suggestion(GetSettingsSuggestionValue())); | 353 suggestions->push_back(Suggestion(GetSettingsSuggestionValue())); |
352 suggestions->back().frontend_id = POPUP_ITEM_ID_AUTOFILL_OPTIONS; | 354 suggestions->back().frontend_id = POPUP_ITEM_ID_AUTOFILL_OPTIONS; |
353 if (IsKeyboardAccessoryEnabled()) | 355 #if defined(OS_ANDROID) |
| 356 if (IsKeyboardAccessoryEnabled()) { |
354 suggestions->back().icon = base::ASCIIToUTF16("settings"); | 357 suggestions->back().icon = base::ASCIIToUTF16("settings"); |
| 358 if (IsHintEnabledInKeyboardAccessory() && !query_field_.is_autofilled) { |
| 359 Suggestion create_icon; |
| 360 create_icon.icon = base::ASCIIToUTF16("create"); |
| 361 create_icon.frontend_id = POPUP_ITEM_ID_CREATE_HINT; |
| 362 suggestions->push_back(create_icon); |
| 363 } |
| 364 } |
| 365 #endif |
355 } | 366 } |
356 | 367 |
357 void AutofillExternalDelegate::InsertDataListValues( | 368 void AutofillExternalDelegate::InsertDataListValues( |
358 std::vector<Suggestion>* suggestions) { | 369 std::vector<Suggestion>* suggestions) { |
359 if (data_list_values_.empty()) | 370 if (data_list_values_.empty()) |
360 return; | 371 return; |
361 | 372 |
362 // Go through the list of autocomplete values and remove them if they are in | 373 // Go through the list of autocomplete values and remove them if they are in |
363 // the list of datalist values. | 374 // the list of datalist values. |
364 std::set<base::string16> data_list_set(data_list_values_.begin(), | 375 std::set<base::string16> data_list_set(data_list_values_.begin(), |
(...skipping 30 matching lines...) Expand all Loading... |
395 const { | 406 const { |
396 if (IsKeyboardAccessoryEnabled()) { | 407 if (IsKeyboardAccessoryEnabled()) { |
397 return l10n_util::GetStringUTF16(IDS_AUTOFILL_OPTIONS_CONTENT_DESCRIPTION); | 408 return l10n_util::GetStringUTF16(IDS_AUTOFILL_OPTIONS_CONTENT_DESCRIPTION); |
398 } | 409 } |
399 return l10n_util::GetStringUTF16(is_credit_card_popup_ ? | 410 return l10n_util::GetStringUTF16(is_credit_card_popup_ ? |
400 IDS_AUTOFILL_CREDIT_CARD_OPTIONS_POPUP : | 411 IDS_AUTOFILL_CREDIT_CARD_OPTIONS_POPUP : |
401 IDS_AUTOFILL_OPTIONS_POPUP); | 412 IDS_AUTOFILL_OPTIONS_POPUP); |
402 } | 413 } |
403 | 414 |
404 } // namespace autofill | 415 } // namespace autofill |
OLD | NEW |