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 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 IPC_MESSAGE_HANDLER(AutofillHostMsg_HideAutofillPopup, | 353 IPC_MESSAGE_HANDLER(AutofillHostMsg_HideAutofillPopup, |
353 OnHideAutofillPopup) | 354 OnHideAutofillPopup) |
354 IPC_MESSAGE_HANDLER(AutofillHostMsg_ShowPasswordGenerationPopup, | 355 IPC_MESSAGE_HANDLER(AutofillHostMsg_ShowPasswordGenerationPopup, |
355 OnShowPasswordGenerationPopup) | 356 OnShowPasswordGenerationPopup) |
356 IPC_MESSAGE_HANDLER(AutofillHostMsg_AddPasswordFormMapping, | 357 IPC_MESSAGE_HANDLER(AutofillHostMsg_AddPasswordFormMapping, |
357 OnAddPasswordFormMapping) | 358 OnAddPasswordFormMapping) |
358 IPC_MESSAGE_HANDLER(AutofillHostMsg_ShowPasswordSuggestions, | 359 IPC_MESSAGE_HANDLER(AutofillHostMsg_ShowPasswordSuggestions, |
359 OnShowPasswordSuggestions) | 360 OnShowPasswordSuggestions) |
360 IPC_MESSAGE_HANDLER(AutofillHostMsg_SetDataList, | 361 IPC_MESSAGE_HANDLER(AutofillHostMsg_SetDataList, |
361 OnSetDataList) | 362 OnSetDataList) |
| 363 IPC_MESSAGE_HANDLER(AutofillHostMsg_RequestAutocomplete, |
| 364 OnRequestAutocomplete) |
362 IPC_MESSAGE_UNHANDLED(handled = false) | 365 IPC_MESSAGE_UNHANDLED(handled = false) |
363 IPC_END_MESSAGE_MAP() | 366 IPC_END_MESSAGE_MAP() |
364 | 367 |
365 return handled; | 368 return handled; |
366 } | 369 } |
367 | 370 |
368 void AutofillManager::WebContentsDestroyed(content::WebContents* web_contents) { | 371 void AutofillManager::WebContentsDestroyed(content::WebContents* web_contents) { |
369 ProfileSyncServiceBase* service = manager_delegate_->GetProfileSyncService(); | 372 ProfileSyncServiceBase* service = manager_delegate_->GetProfileSyncService(); |
370 if (service && service->HasObserver(this)) | 373 if (service && service->HasObserver(this)) |
371 service->RemoveObserver(this); | 374 service->RemoveObserver(this); |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
789 const std::vector<string16>& icons, | 792 const std::vector<string16>& icons, |
790 const std::vector<int>& unique_ids) { | 793 const std::vector<int>& unique_ids) { |
791 if (external_delegate_) { | 794 if (external_delegate_) { |
792 external_delegate_->SetCurrentDataListValues(values, | 795 external_delegate_->SetCurrentDataListValues(values, |
793 labels, | 796 labels, |
794 icons, | 797 icons, |
795 unique_ids); | 798 unique_ids); |
796 } | 799 } |
797 } | 800 } |
798 | 801 |
| 802 void AutofillManager::OnRequestAutocomplete(const FormData& form) { |
| 803 RenderViewHost* host = web_contents()->GetRenderViewHost(); |
| 804 if (!host) |
| 805 return; |
| 806 |
| 807 // TODO(dbeam): implement interactive autocomplete UI. Just send an error |
| 808 // right away until we have an implementation. (http://webk.it/100560) |
| 809 host->Send(new AutofillMsg_RequestAutocompleteFinished( |
| 810 host->GetRoutingID(), WebKit::WebFormElement::AutocompleteError)); |
| 811 } |
| 812 |
799 void AutofillManager::OnLoadedServerPredictions( | 813 void AutofillManager::OnLoadedServerPredictions( |
800 const std::string& response_xml) { | 814 const std::string& response_xml) { |
801 // Parse and store the server predictions. | 815 // Parse and store the server predictions. |
802 FormStructure::ParseQueryResponse(response_xml, | 816 FormStructure::ParseQueryResponse(response_xml, |
803 form_structures_.get(), | 817 form_structures_.get(), |
804 *metric_logger_); | 818 *metric_logger_); |
805 | 819 |
806 // If the corresponding flag is set, annotate forms with the predicted types. | 820 // If the corresponding flag is set, annotate forms with the predicted types. |
807 SendAutofillTypePredictions(form_structures_.get()); | 821 SendAutofillTypePredictions(form_structures_.get()); |
808 } | 822 } |
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1412 *profile_guid = IDToGUID(profile_id); | 1426 *profile_guid = IDToGUID(profile_id); |
1413 } | 1427 } |
1414 | 1428 |
1415 void AutofillManager::UpdateInitialInteractionTimestamp( | 1429 void AutofillManager::UpdateInitialInteractionTimestamp( |
1416 const TimeTicks& interaction_timestamp) { | 1430 const TimeTicks& interaction_timestamp) { |
1417 if (initial_interaction_timestamp_.is_null() || | 1431 if (initial_interaction_timestamp_.is_null() || |
1418 interaction_timestamp < initial_interaction_timestamp_) { | 1432 interaction_timestamp < initial_interaction_timestamp_) { |
1419 initial_interaction_timestamp_ = interaction_timestamp; | 1433 initial_interaction_timestamp_ = interaction_timestamp; |
1420 } | 1434 } |
1421 } | 1435 } |
OLD | NEW |