Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Side by Side Diff: chrome/browser/autofill/autofill_manager.cc

Issue 11821020: Chrome-side implementation of AutocompleteErrorEvent#reason. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 #include "content/public/browser/browser_context.h" 53 #include "content/public/browser/browser_context.h"
54 #include "content/public/browser/browser_thread.h" 54 #include "content/public/browser/browser_thread.h"
55 #include "content/public/browser/notification_service.h" 55 #include "content/public/browser/notification_service.h"
56 #include "content/public/browser/notification_source.h" 56 #include "content/public/browser/notification_source.h"
57 #include "content/public/browser/render_view_host.h" 57 #include "content/public/browser/render_view_host.h"
58 #include "content/public/browser/web_contents.h" 58 #include "content/public/browser/web_contents.h"
59 #include "googleurl/src/gurl.h" 59 #include "googleurl/src/gurl.h"
60 #include "grit/generated_resources.h" 60 #include "grit/generated_resources.h"
61 #include "ipc/ipc_message_macros.h" 61 #include "ipc/ipc_message_macros.h"
62 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAutofillClient.h" 62 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAutofillClient.h"
63 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFormElement.h"
64 #include "ui/base/l10n/l10n_util.h" 63 #include "ui/base/l10n/l10n_util.h"
65 #include "ui/gfx/rect.h" 64 #include "ui/gfx/rect.h"
66 65
67 typedef PersonalDataManager::GUIDPair GUIDPair; 66 typedef PersonalDataManager::GUIDPair GUIDPair;
68 using base::TimeTicks; 67 using base::TimeTicks;
69 using content::BrowserThread; 68 using content::BrowserThread;
70 using content::RenderViewHost; 69 using content::RenderViewHost;
70 using WebKit::WebFormElement;
71 71
72 namespace { 72 namespace {
73 73
74 const char* kAutofillManagerWebContentsUserDataKey = "web_contents_autofill"; 74 const char* kAutofillManagerWebContentsUserDataKey = "web_contents_autofill";
75 75
76 // We only send a fraction of the forms to upload server. 76 // We only send a fraction of the forms to upload server.
77 // The rate for positive/negative matches potentially could be different. 77 // The rate for positive/negative matches potentially could be different.
78 const double kAutofillPositiveUploadRateDefaultValue = 0.20; 78 const double kAutofillPositiveUploadRateDefaultValue = 0.20;
79 const double kAutofillNegativeUploadRateDefaultValue = 0.20; 79 const double kAutofillNegativeUploadRateDefaultValue = 0.20;
80 80
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 icons, 792 icons,
793 unique_ids); 793 unique_ids);
794 } 794 }
795 } 795 }
796 796
797 void AutofillManager::OnRequestAutocomplete( 797 void AutofillManager::OnRequestAutocomplete(
798 const FormData& form, 798 const FormData& form,
799 const GURL& frame_url, 799 const GURL& frame_url,
800 const content::SSLStatus& ssl_status) { 800 const content::SSLStatus& ssl_status) {
801 if (!IsAutofillEnabled()) { 801 if (!IsAutofillEnabled()) {
802 ReturnAutocompleteError(); 802 ReturnAutocompleteResult(WebFormElement::AutocompleteResultErrorDisabled,
803 FormData());
803 return; 804 return;
804 } 805 }
805 806
806 base::Callback<void(const FormStructure*)> callback = 807 base::Callback<void(const FormStructure*)> callback =
807 base::Bind(&AutofillManager::ReturnAutocompleteData, this); 808 base::Bind(&AutofillManager::ReturnAutocompleteData, this);
808 autofill::AutofillDialogController* controller = 809 autofill::AutofillDialogController* controller =
809 new autofill::AutofillDialogController(web_contents(), 810 new autofill::AutofillDialogController(web_contents(),
810 form, 811 form,
811 frame_url, 812 frame_url,
812 ssl_status, 813 ssl_status,
813 callback); 814 callback);
814 controller->Show(); 815 controller->Show();
815 } 816 }
816 817
817 void AutofillManager::ReturnAutocompleteError() { 818 void AutofillManager::ReturnAutocompleteResult(
819 WebFormElement::AutocompleteResult result, const FormData& form_data) {
818 RenderViewHost* host = web_contents()->GetRenderViewHost(); 820 RenderViewHost* host = web_contents()->GetRenderViewHost();
819 if (!host) 821 if (!host)
820 return; 822 return;
821 823
822 host->Send(new AutofillMsg_RequestAutocompleteError(host->GetRoutingID())); 824 host->Send(new AutofillMsg_RequestAutocompleteResult(host->GetRoutingID(),
825 result,
826 form_data));
823 } 827 }
824 828
825 void AutofillManager::ReturnAutocompleteData(const FormStructure* result) { 829 void AutofillManager::ReturnAutocompleteData(const FormStructure* result) {
826 // web_contents() will be NULL when the interactive autocomplete is closed due 830 // web_contents() will be NULL when the interactive autocomplete is closed due
827 // to a tab or browser window closing. 831 // to a tab or browser window closing.
828 if (!web_contents()) 832 if (!web_contents())
829 return; 833 return;
830 834
831 RenderViewHost* host = web_contents()->GetRenderViewHost();
832 if (!host)
833 return;
834
835 if (!result) { 835 if (!result) {
836 ReturnAutocompleteError(); 836 ReturnAutocompleteResult(WebFormElement::AutocompleteResultErrorCancel,
837 return; 837 FormData());
838 } else {
839 ReturnAutocompleteResult(WebFormElement::AutocompleteResultSuccess,
840 result->ToFormData());
838 } 841 }
839
840 host->Send(new AutofillMsg_RequestAutocompleteSuccess(host->GetRoutingID(),
841 result->ToFormData()));
842 } 842 }
843 843
844 void AutofillManager::OnLoadedServerPredictions( 844 void AutofillManager::OnLoadedServerPredictions(
845 const std::string& response_xml) { 845 const std::string& response_xml) {
846 // Parse and store the server predictions. 846 // Parse and store the server predictions.
847 FormStructure::ParseQueryResponse(response_xml, 847 FormStructure::ParseQueryResponse(response_xml,
848 form_structures_.get(), 848 form_structures_.get(),
849 *metric_logger_); 849 *metric_logger_);
850 850
851 // If the corresponding flag is set, annotate forms with the predicted types. 851 // If the corresponding flag is set, annotate forms with the predicted types.
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
1273 *profile_guid = IDToGUID(profile_id); 1273 *profile_guid = IDToGUID(profile_id);
1274 } 1274 }
1275 1275
1276 void AutofillManager::UpdateInitialInteractionTimestamp( 1276 void AutofillManager::UpdateInitialInteractionTimestamp(
1277 const TimeTicks& interaction_timestamp) { 1277 const TimeTicks& interaction_timestamp) {
1278 if (initial_interaction_timestamp_.is_null() || 1278 if (initial_interaction_timestamp_.is_null() ||
1279 interaction_timestamp < initial_interaction_timestamp_) { 1279 interaction_timestamp < initial_interaction_timestamp_) {
1280 initial_interaction_timestamp_ = interaction_timestamp; 1280 initial_interaction_timestamp_ = interaction_timestamp;
1281 } 1281 }
1282 } 1282 }
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_manager.h ('k') | chrome/browser/autofill/autofill_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698