| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/autofill/autofill_manager.h" | 5 #include "chrome/browser/autofill/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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 #include "content/public/browser/browser_context.h" | 51 #include "content/public/browser/browser_context.h" |
| 52 #include "content/public/browser/browser_thread.h" | 52 #include "content/public/browser/browser_thread.h" |
| 53 #include "content/public/browser/notification_service.h" | 53 #include "content/public/browser/notification_service.h" |
| 54 #include "content/public/browser/notification_source.h" | 54 #include "content/public/browser/notification_source.h" |
| 55 #include "content/public/browser/render_view_host.h" | 55 #include "content/public/browser/render_view_host.h" |
| 56 #include "content/public/browser/web_contents.h" | 56 #include "content/public/browser/web_contents.h" |
| 57 #include "googleurl/src/gurl.h" | 57 #include "googleurl/src/gurl.h" |
| 58 #include "grit/generated_resources.h" | 58 #include "grit/generated_resources.h" |
| 59 #include "ipc/ipc_message_macros.h" | 59 #include "ipc/ipc_message_macros.h" |
| 60 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAutofillClient.h" | 60 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAutofillClient.h" |
| 61 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFormElement.h" |
| 61 #include "ui/base/l10n/l10n_util.h" | 62 #include "ui/base/l10n/l10n_util.h" |
| 62 #include "ui/gfx/rect.h" | 63 #include "ui/gfx/rect.h" |
| 63 | 64 |
| 64 using base::TimeTicks; | 65 using base::TimeTicks; |
| 65 using content::BrowserThread; | 66 using content::BrowserThread; |
| 66 using content::RenderViewHost; | 67 using content::RenderViewHost; |
| 67 | 68 |
| 68 namespace { | 69 namespace { |
| 69 | 70 |
| 70 const char* kAutofillManagerWebContentsUserDataKey = "web_contents_autofill"; | 71 const char* kAutofillManagerWebContentsUserDataKey = "web_contents_autofill"; |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 IPC_MESSAGE_HANDLER(AutofillHostMsg_HideAutofillPopup, | 349 IPC_MESSAGE_HANDLER(AutofillHostMsg_HideAutofillPopup, |
| 349 OnHideAutofillPopup) | 350 OnHideAutofillPopup) |
| 350 IPC_MESSAGE_HANDLER(AutofillHostMsg_ShowPasswordGenerationPopup, | 351 IPC_MESSAGE_HANDLER(AutofillHostMsg_ShowPasswordGenerationPopup, |
| 351 OnShowPasswordGenerationPopup) | 352 OnShowPasswordGenerationPopup) |
| 352 IPC_MESSAGE_HANDLER(AutofillHostMsg_AddPasswordFormMapping, | 353 IPC_MESSAGE_HANDLER(AutofillHostMsg_AddPasswordFormMapping, |
| 353 OnAddPasswordFormMapping) | 354 OnAddPasswordFormMapping) |
| 354 IPC_MESSAGE_HANDLER(AutofillHostMsg_ShowPasswordSuggestions, | 355 IPC_MESSAGE_HANDLER(AutofillHostMsg_ShowPasswordSuggestions, |
| 355 OnShowPasswordSuggestions) | 356 OnShowPasswordSuggestions) |
| 356 IPC_MESSAGE_HANDLER(AutofillHostMsg_SetDataList, | 357 IPC_MESSAGE_HANDLER(AutofillHostMsg_SetDataList, |
| 357 OnSetDataList) | 358 OnSetDataList) |
| 359 IPC_MESSAGE_HANDLER(AutofillHostMsg_RequestAutocomplete, |
| 360 OnRequestAutocomplete) |
| 358 IPC_MESSAGE_UNHANDLED(handled = false) | 361 IPC_MESSAGE_UNHANDLED(handled = false) |
| 359 IPC_END_MESSAGE_MAP() | 362 IPC_END_MESSAGE_MAP() |
| 360 | 363 |
| 361 return handled; | 364 return handled; |
| 362 } | 365 } |
| 363 | 366 |
| 364 void AutofillManager::WebContentsDestroyed(content::WebContents* web_contents) { | 367 void AutofillManager::WebContentsDestroyed(content::WebContents* web_contents) { |
| 365 ProfileSyncServiceBase* service = manager_delegate_->GetProfileSyncService(); | 368 ProfileSyncServiceBase* service = manager_delegate_->GetProfileSyncService(); |
| 366 if (service && service->HasObserver(this)) | 369 if (service && service->HasObserver(this)) |
| 367 service->RemoveObserver(this); | 370 service->RemoveObserver(this); |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 785 const std::vector<string16>& icons, | 788 const std::vector<string16>& icons, |
| 786 const std::vector<int>& unique_ids) { | 789 const std::vector<int>& unique_ids) { |
| 787 if (external_delegate_) { | 790 if (external_delegate_) { |
| 788 external_delegate_->SetCurrentDataListValues(values, | 791 external_delegate_->SetCurrentDataListValues(values, |
| 789 labels, | 792 labels, |
| 790 icons, | 793 icons, |
| 791 unique_ids); | 794 unique_ids); |
| 792 } | 795 } |
| 793 } | 796 } |
| 794 | 797 |
| 798 void AutofillManager::OnRequestAutocomplete(const FormData& form) { |
| 799 RenderViewHost* host = web_contents()->GetRenderViewHost(); |
| 800 if (!host) |
| 801 return; |
| 802 |
| 803 // TODO(dbeam): implement interactive autocomplete UI. Just send an error |
| 804 // right away until we have an implementation. (http://webk.it/100560) |
| 805 host->Send(new AutofillMsg_RequestAutocompleteFinished( |
| 806 host->GetRoutingID(), WebKit::WebFormElement::AutocompleteResultError)); |
| 807 } |
| 808 |
| 795 void AutofillManager::OnLoadedServerPredictions( | 809 void AutofillManager::OnLoadedServerPredictions( |
| 796 const std::string& response_xml) { | 810 const std::string& response_xml) { |
| 797 // Parse and store the server predictions. | 811 // Parse and store the server predictions. |
| 798 FormStructure::ParseQueryResponse(response_xml, | 812 FormStructure::ParseQueryResponse(response_xml, |
| 799 form_structures_.get(), | 813 form_structures_.get(), |
| 800 *metric_logger_); | 814 *metric_logger_); |
| 801 | 815 |
| 802 // If the corresponding flag is set, annotate forms with the predicted types. | 816 // If the corresponding flag is set, annotate forms with the predicted types. |
| 803 SendAutofillTypePredictions(form_structures_.get()); | 817 SendAutofillTypePredictions(form_structures_.get()); |
| 804 } | 818 } |
| (...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1408 *profile_guid = IDToGUID(profile_id); | 1422 *profile_guid = IDToGUID(profile_id); |
| 1409 } | 1423 } |
| 1410 | 1424 |
| 1411 void AutofillManager::UpdateInitialInteractionTimestamp( | 1425 void AutofillManager::UpdateInitialInteractionTimestamp( |
| 1412 const TimeTicks& interaction_timestamp) { | 1426 const TimeTicks& interaction_timestamp) { |
| 1413 if (initial_interaction_timestamp_.is_null() || | 1427 if (initial_interaction_timestamp_.is_null() || |
| 1414 interaction_timestamp < initial_interaction_timestamp_) { | 1428 interaction_timestamp < initial_interaction_timestamp_) { |
| 1415 initial_interaction_timestamp_ = interaction_timestamp; | 1429 initial_interaction_timestamp_ = interaction_timestamp; |
| 1416 } | 1430 } |
| 1417 } | 1431 } |
| OLD | NEW |