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 using switches::kEnableAutofillFeedback; | 68 using switches::kEnableAutofillFeedback; |
68 | 69 |
69 namespace { | 70 namespace { |
70 | 71 |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
353 IPC_MESSAGE_HANDLER(AutofillHostMsg_HideAutofillPopup, | 354 IPC_MESSAGE_HANDLER(AutofillHostMsg_HideAutofillPopup, |
354 OnHideAutofillPopup) | 355 OnHideAutofillPopup) |
355 IPC_MESSAGE_HANDLER(AutofillHostMsg_ShowPasswordGenerationPopup, | 356 IPC_MESSAGE_HANDLER(AutofillHostMsg_ShowPasswordGenerationPopup, |
356 OnShowPasswordGenerationPopup) | 357 OnShowPasswordGenerationPopup) |
357 IPC_MESSAGE_HANDLER(AutofillHostMsg_AddPasswordFormMapping, | 358 IPC_MESSAGE_HANDLER(AutofillHostMsg_AddPasswordFormMapping, |
358 OnAddPasswordFormMapping) | 359 OnAddPasswordFormMapping) |
359 IPC_MESSAGE_HANDLER(AutofillHostMsg_ShowPasswordSuggestions, | 360 IPC_MESSAGE_HANDLER(AutofillHostMsg_ShowPasswordSuggestions, |
360 OnShowPasswordSuggestions) | 361 OnShowPasswordSuggestions) |
361 IPC_MESSAGE_HANDLER(AutofillHostMsg_SetDataList, | 362 IPC_MESSAGE_HANDLER(AutofillHostMsg_SetDataList, |
362 OnSetDataList) | 363 OnSetDataList) |
364 IPC_MESSAGE_HANDLER(AutofillHostMsg_RequestAutocomplete, | |
365 OnRequestAutocomplete) | |
363 IPC_MESSAGE_UNHANDLED(handled = false) | 366 IPC_MESSAGE_UNHANDLED(handled = false) |
364 IPC_END_MESSAGE_MAP() | 367 IPC_END_MESSAGE_MAP() |
365 | 368 |
366 return handled; | 369 return handled; |
367 } | 370 } |
368 | 371 |
369 void AutofillManager::WebContentsDestroyed(content::WebContents* web_contents) { | 372 void AutofillManager::WebContentsDestroyed(content::WebContents* web_contents) { |
370 ProfileSyncServiceBase* service = manager_delegate_->GetProfileSyncService(); | 373 ProfileSyncServiceBase* service = manager_delegate_->GetProfileSyncService(); |
371 if (service && service->HasObserver(this)) | 374 if (service && service->HasObserver(this)) |
372 service->RemoveObserver(this); | 375 service->RemoveObserver(this); |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
790 const std::vector<string16>& icons, | 793 const std::vector<string16>& icons, |
791 const std::vector<int>& unique_ids) { | 794 const std::vector<int>& unique_ids) { |
792 if (external_delegate_) { | 795 if (external_delegate_) { |
793 external_delegate_->SetCurrentDataListValues(values, | 796 external_delegate_->SetCurrentDataListValues(values, |
794 labels, | 797 labels, |
795 icons, | 798 icons, |
796 unique_ids); | 799 unique_ids); |
797 } | 800 } |
798 } | 801 } |
799 | 802 |
803 void AutofillManager::OnRequestAutocomplete(int unique_id, | |
804 const FormData& form) { | |
805 // TODO(dbeam): implement interactive autocomplete UI. | |
806 | |
807 RenderViewHost* host = web_contents()->GetRenderViewHost(); | |
808 if (!host) | |
809 return; | |
810 | |
811 // Just send an error right away until webkit changes land | |
812 // (https://bugs.webkit.org/show_bug.cgi?id=100557). | |
Evan Stade
2012/10/29 17:54:28
nit: it doesn't depend on webkit. It's more like "
Dan Beam
2012/10/29 19:17:05
Done.
| |
813 host->Send(new AutofillMsg_RequestAutocompleteFinished( | |
814 host->GetRoutingID(), | |
815 unique_id, | |
816 WebKit::WebFormElement::AutocompleteError)); | |
817 } | |
818 | |
800 void AutofillManager::OnLoadedServerPredictions( | 819 void AutofillManager::OnLoadedServerPredictions( |
801 const std::string& response_xml) { | 820 const std::string& response_xml) { |
802 // Parse and store the server predictions. | 821 // Parse and store the server predictions. |
803 FormStructure::ParseQueryResponse(response_xml, | 822 FormStructure::ParseQueryResponse(response_xml, |
804 form_structures_.get(), | 823 form_structures_.get(), |
805 *metric_logger_); | 824 *metric_logger_); |
806 | 825 |
807 // If the corresponding flag is set, annotate forms with the predicted types. | 826 // If the corresponding flag is set, annotate forms with the predicted types. |
808 SendAutofillTypePredictions(form_structures_.get()); | 827 SendAutofillTypePredictions(form_structures_.get()); |
809 } | 828 } |
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1413 *profile_guid = IDToGUID(profile_id); | 1432 *profile_guid = IDToGUID(profile_id); |
1414 } | 1433 } |
1415 | 1434 |
1416 void AutofillManager::UpdateInitialInteractionTimestamp( | 1435 void AutofillManager::UpdateInitialInteractionTimestamp( |
1417 const TimeTicks& interaction_timestamp) { | 1436 const TimeTicks& interaction_timestamp) { |
1418 if (initial_interaction_timestamp_.is_null() || | 1437 if (initial_interaction_timestamp_.is_null() || |
1419 interaction_timestamp < initial_interaction_timestamp_) { | 1438 interaction_timestamp < initial_interaction_timestamp_) { |
1420 initial_interaction_timestamp_ = interaction_timestamp; | 1439 initial_interaction_timestamp_ = interaction_timestamp; |
1421 } | 1440 } |
1422 } | 1441 } |
OLD | NEW |