| 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_manager.h" | 5 #include "components/autofill/core/browser/autofill_manager.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <limits> | 9 #include <limits> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 #include "components/autofill/core/common/autofill_messages.h" | 40 #include "components/autofill/core/common/autofill_messages.h" |
| 41 #include "components/autofill/core/common/autofill_pref_names.h" | 41 #include "components/autofill/core/common/autofill_pref_names.h" |
| 42 #include "components/autofill/core/common/autofill_switches.h" | 42 #include "components/autofill/core/common/autofill_switches.h" |
| 43 #include "components/autofill/core/common/form_data.h" | 43 #include "components/autofill/core/common/form_data.h" |
| 44 #include "components/autofill/core/common/form_data_predictions.h" | 44 #include "components/autofill/core/common/form_data_predictions.h" |
| 45 #include "components/autofill/core/common/form_field_data.h" | 45 #include "components/autofill/core/common/form_field_data.h" |
| 46 #include "components/autofill/core/common/password_form_fill_data.h" | 46 #include "components/autofill/core/common/password_form_fill_data.h" |
| 47 #include "components/user_prefs/pref_registry_syncable.h" | 47 #include "components/user_prefs/pref_registry_syncable.h" |
| 48 #include "content/public/browser/browser_context.h" | 48 #include "content/public/browser/browser_context.h" |
| 49 #include "content/public/browser/browser_thread.h" | 49 #include "content/public/browser/browser_thread.h" |
| 50 #include "content/public/browser/navigation_details.h" | |
| 51 #include "content/public/browser/render_view_host.h" | 50 #include "content/public/browser/render_view_host.h" |
| 52 #include "content/public/browser/web_contents.h" | 51 #include "content/public/browser/web_contents.h" |
| 53 #include "content/public/browser/web_contents_view.h" | 52 #include "content/public/browser/web_contents_view.h" |
| 54 #include "content/public/common/frame_navigate_params.h" | |
| 55 #include "content/public/common/url_constants.h" | 53 #include "content/public/common/url_constants.h" |
| 56 #include "googleurl/src/gurl.h" | 54 #include "googleurl/src/gurl.h" |
| 57 #include "grit/component_strings.h" | 55 #include "grit/component_strings.h" |
| 58 #include "ipc/ipc_message_macros.h" | |
| 59 #include "third_party/WebKit/public/web/WebAutofillClient.h" | 56 #include "third_party/WebKit/public/web/WebAutofillClient.h" |
| 60 #include "ui/base/l10n/l10n_util.h" | 57 #include "ui/base/l10n/l10n_util.h" |
| 61 #include "ui/gfx/rect.h" | 58 #include "ui/gfx/rect.h" |
| 62 | 59 |
| 63 namespace autofill { | 60 namespace autofill { |
| 64 | 61 |
| 65 typedef PersonalDataManager::GUIDPair GUIDPair; | 62 typedef PersonalDataManager::GUIDPair GUIDPair; |
| 66 | 63 |
| 67 using base::TimeTicks; | 64 using base::TimeTicks; |
| 68 using content::BrowserThread; | 65 using content::BrowserThread; |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 registry->RegisterDoublePref( | 230 registry->RegisterDoublePref( |
| 234 prefs::kAutofillPositiveUploadRate, | 231 prefs::kAutofillPositiveUploadRate, |
| 235 kAutofillPositiveUploadRateDefaultValue, | 232 kAutofillPositiveUploadRateDefaultValue, |
| 236 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 233 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 237 registry->RegisterDoublePref( | 234 registry->RegisterDoublePref( |
| 238 prefs::kAutofillNegativeUploadRate, | 235 prefs::kAutofillNegativeUploadRate, |
| 239 kAutofillNegativeUploadRateDefaultValue, | 236 kAutofillNegativeUploadRateDefaultValue, |
| 240 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 237 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 241 } | 238 } |
| 242 | 239 |
| 243 void AutofillManager::DidNavigateMainFrame( | |
| 244 const content::LoadCommittedDetails& details, | |
| 245 const content::FrameNavigateParams& params) { | |
| 246 if (details.is_navigation_to_different_page()) | |
| 247 Reset(); | |
| 248 } | |
| 249 | |
| 250 void AutofillManager::SetExternalDelegate(AutofillExternalDelegate* delegate) { | 240 void AutofillManager::SetExternalDelegate(AutofillExternalDelegate* delegate) { |
| 251 // TODO(jrg): consider passing delegate into the ctor. That won't | 241 // TODO(jrg): consider passing delegate into the ctor. That won't |
| 252 // work if the delegate has a pointer to the AutofillManager, but | 242 // work if the delegate has a pointer to the AutofillManager, but |
| 253 // future directions may not need such a pointer. | 243 // future directions may not need such a pointer. |
| 254 external_delegate_ = delegate; | 244 external_delegate_ = delegate; |
| 255 autocomplete_history_manager_.SetExternalDelegate(delegate); | 245 autocomplete_history_manager_.SetExternalDelegate(delegate); |
| 256 } | 246 } |
| 257 | 247 |
| 258 bool AutofillManager::IsNativeUiEnabled() { | 248 bool AutofillManager::IsNativeUiEnabled() { |
| 259 return external_delegate_ != NULL; | 249 return external_delegate_ != NULL; |
| 260 } | 250 } |
| 261 | 251 |
| 262 bool AutofillManager::OnMessageReceived(const IPC::Message& message) { | |
| 263 bool handled = true; | |
| 264 IPC_BEGIN_MESSAGE_MAP(AutofillManager, message) | |
| 265 IPC_MESSAGE_HANDLER(AutofillHostMsg_FormsSeen, OnFormsSeen) | |
| 266 IPC_MESSAGE_HANDLER(AutofillHostMsg_FormSubmitted, OnFormSubmitted) | |
| 267 IPC_MESSAGE_HANDLER(AutofillHostMsg_TextFieldDidChange, | |
| 268 OnTextFieldDidChange) | |
| 269 IPC_MESSAGE_HANDLER(AutofillHostMsg_QueryFormFieldAutofill, | |
| 270 OnQueryFormFieldAutofill) | |
| 271 IPC_MESSAGE_HANDLER(AutofillHostMsg_ShowAutofillDialog, | |
| 272 OnShowAutofillDialog) | |
| 273 IPC_MESSAGE_HANDLER(AutofillHostMsg_FillAutofillFormData, | |
| 274 OnFillAutofillFormData) | |
| 275 IPC_MESSAGE_HANDLER(AutofillHostMsg_DidPreviewAutofillFormData, | |
| 276 OnDidPreviewAutofillFormData) | |
| 277 IPC_MESSAGE_HANDLER(AutofillHostMsg_DidFillAutofillFormData, | |
| 278 OnDidFillAutofillFormData) | |
| 279 IPC_MESSAGE_HANDLER(AutofillHostMsg_DidShowAutofillSuggestions, | |
| 280 OnDidShowAutofillSuggestions) | |
| 281 IPC_MESSAGE_HANDLER(AutofillHostMsg_DidEndTextFieldEditing, | |
| 282 OnDidEndTextFieldEditing) | |
| 283 IPC_MESSAGE_HANDLER(AutofillHostMsg_HideAutofillUi, | |
| 284 OnHideAutofillUi) | |
| 285 IPC_MESSAGE_HANDLER(AutofillHostMsg_AddPasswordFormMapping, | |
| 286 OnAddPasswordFormMapping) | |
| 287 IPC_MESSAGE_HANDLER(AutofillHostMsg_ShowPasswordSuggestions, | |
| 288 OnShowPasswordSuggestions) | |
| 289 IPC_MESSAGE_HANDLER(AutofillHostMsg_SetDataList, | |
| 290 OnSetDataList) | |
| 291 IPC_MESSAGE_HANDLER(AutofillHostMsg_RequestAutocomplete, | |
| 292 OnRequestAutocomplete) | |
| 293 IPC_MESSAGE_HANDLER(AutofillHostMsg_ClickFailed, | |
| 294 OnClickFailed) | |
| 295 IPC_MESSAGE_HANDLER(AutofillHostMsg_MaybeShowAutocheckoutBubble, | |
| 296 OnMaybeShowAutocheckoutBubble) | |
| 297 IPC_MESSAGE_HANDLER(AutofillHostMsg_RemoveAutocompleteEntry, | |
| 298 RemoveAutocompleteEntry) | |
| 299 IPC_MESSAGE_UNHANDLED(handled = false) | |
| 300 IPC_END_MESSAGE_MAP() | |
| 301 | |
| 302 return handled; | |
| 303 } | |
| 304 | |
| 305 bool AutofillManager::OnFormSubmitted(const FormData& form, | 252 bool AutofillManager::OnFormSubmitted(const FormData& form, |
| 306 const TimeTicks& timestamp) { | 253 const TimeTicks& timestamp) { |
| 307 // Let AutoComplete know as well. | 254 // Let AutoComplete know as well. |
| 308 autocomplete_history_manager_.OnFormSubmitted(form); | 255 autocomplete_history_manager_.OnFormSubmitted(form); |
| 309 | 256 |
| 310 if (!IsAutofillEnabled()) | 257 if (!IsAutofillEnabled()) |
| 311 return false; | 258 return false; |
| 312 | 259 |
| 313 if (driver_->GetWebContents()->GetBrowserContext()->IsOffTheRecord()) | 260 if (driver_->GetWebContents()->GetBrowserContext()->IsOffTheRecord()) |
| 314 return false; | 261 return false; |
| (...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1293 | 1240 |
| 1294 void AutofillManager::UpdateInitialInteractionTimestamp( | 1241 void AutofillManager::UpdateInitialInteractionTimestamp( |
| 1295 const TimeTicks& interaction_timestamp) { | 1242 const TimeTicks& interaction_timestamp) { |
| 1296 if (initial_interaction_timestamp_.is_null() || | 1243 if (initial_interaction_timestamp_.is_null() || |
| 1297 interaction_timestamp < initial_interaction_timestamp_) { | 1244 interaction_timestamp < initial_interaction_timestamp_) { |
| 1298 initial_interaction_timestamp_ = interaction_timestamp; | 1245 initial_interaction_timestamp_ = interaction_timestamp; |
| 1299 } | 1246 } |
| 1300 } | 1247 } |
| 1301 | 1248 |
| 1302 } // namespace autofill | 1249 } // namespace autofill |
| OLD | NEW |