| 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/autocomplete_history_manager.h" | 5 #include "components/autofill/core/browser/autocomplete_history_manager.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "components/autofill/core/browser/autofill_driver.h" | 12 #include "components/autofill/core/browser/autofill_driver.h" |
| 13 #include "components/autofill/core/browser/autofill_external_delegate.h" | 13 #include "components/autofill/core/browser/autofill_external_delegate.h" |
| 14 #include "components/autofill/core/browser/autofill_manager_delegate.h" | 14 #include "components/autofill/core/browser/autofill_manager_delegate.h" |
| 15 #include "components/autofill/core/browser/validation.h" | 15 #include "components/autofill/core/browser/validation.h" |
| 16 #include "components/autofill/core/common/autofill_messages.h" | 16 #include "components/autofill/core/common/autofill_messages.h" |
| 17 #include "components/autofill/core/common/autofill_pref_names.h" | 17 #include "components/autofill/core/common/autofill_pref_names.h" |
| 18 #include "components/autofill/core/common/form_data.h" | 18 #include "components/autofill/core/common/form_data.h" |
| 19 #include "content/public/browser/browser_context.h" | |
| 20 #include "content/public/browser/web_contents.h" | |
| 21 | |
| 22 using content::BrowserContext; | |
| 23 using content::WebContents; | |
| 24 | 19 |
| 25 namespace autofill { | 20 namespace autofill { |
| 26 namespace { | 21 namespace { |
| 27 | 22 |
| 28 // Limit on the number of suggestions to appear in the pop-up menu under an | 23 // Limit on the number of suggestions to appear in the pop-up menu under an |
| 29 // text input element in a form. | 24 // text input element in a form. |
| 30 const int kMaxAutocompleteMenuItems = 6; | 25 const int kMaxAutocompleteMenuItems = 6; |
| 31 | 26 |
| 32 bool IsTextField(const FormFieldData& field) { | 27 bool IsTextField(const FormFieldData& field) { |
| 33 return | 28 return |
| 34 field.form_control_type == "text" || | 29 field.form_control_type == "text" || |
| 35 field.form_control_type == "search" || | 30 field.form_control_type == "search" || |
| 36 field.form_control_type == "tel" || | 31 field.form_control_type == "tel" || |
| 37 field.form_control_type == "url" || | 32 field.form_control_type == "url" || |
| 38 field.form_control_type == "email"; | 33 field.form_control_type == "email"; |
| 39 } | 34 } |
| 40 | 35 |
| 41 } // namespace | 36 } // namespace |
| 42 | 37 |
| 43 AutocompleteHistoryManager::AutocompleteHistoryManager( | 38 AutocompleteHistoryManager::AutocompleteHistoryManager( |
| 44 AutofillDriver* driver, | 39 AutofillDriver* driver, |
| 45 AutofillManagerDelegate* manager_delegate) | 40 AutofillManagerDelegate* manager_delegate) |
| 46 : browser_context_(driver->GetWebContents()->GetBrowserContext()), | 41 : driver_(driver), |
| 47 driver_(driver), | 42 autofill_data_(manager_delegate->GetAutofillWebDataService()), |
| 48 autofill_data_( | |
| 49 AutofillWebDataService::FromBrowserContext(browser_context_)), | |
| 50 pending_query_handle_(0), | 43 pending_query_handle_(0), |
| 51 query_id_(0), | 44 query_id_(0), |
| 52 external_delegate_(NULL), | 45 external_delegate_(NULL), |
| 53 manager_delegate_(manager_delegate), | 46 manager_delegate_(manager_delegate), |
| 54 send_ipc_(true) { | 47 send_ipc_(true) { |
| 55 DCHECK(manager_delegate_); | 48 DCHECK(manager_delegate_); |
| 56 } | 49 } |
| 57 | 50 |
| 58 AutocompleteHistoryManager::~AutocompleteHistoryManager() { | 51 AutocompleteHistoryManager::~AutocompleteHistoryManager() { |
| 59 CancelPendingQuery(); | 52 CancelPendingQuery(); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 autofill_unique_ids_); | 188 autofill_unique_ids_); |
| 196 | 189 |
| 197 query_id_ = 0; | 190 query_id_ = 0; |
| 198 autofill_values_.clear(); | 191 autofill_values_.clear(); |
| 199 autofill_labels_.clear(); | 192 autofill_labels_.clear(); |
| 200 autofill_icons_.clear(); | 193 autofill_icons_.clear(); |
| 201 autofill_unique_ids_.clear(); | 194 autofill_unique_ids_.clear(); |
| 202 } | 195 } |
| 203 | 196 |
| 204 } // namespace autofill | 197 } // namespace autofill |
| OLD | NEW |