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

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: 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 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 icons, 774 icons,
775 unique_ids); 775 unique_ids);
776 } 776 }
777 } 777 }
778 778
779 void AutofillManager::OnRequestAutocomplete( 779 void AutofillManager::OnRequestAutocomplete(
780 const FormData& form, 780 const FormData& form,
781 const GURL& frame_url, 781 const GURL& frame_url,
782 const content::SSLStatus& ssl_status) { 782 const content::SSLStatus& ssl_status) {
783 if (!IsAutofillEnabled()) { 783 if (!IsAutofillEnabled()) {
784 ReturnAutocompleteError(); 784 ReturnAutocompleteResult(WebFormElement::AutocompleteResultErrorDisabled,
785 FormData());
785 return; 786 return;
786 } 787 }
787 788
788 base::Callback<void(const FormStructure*)> callback = 789 base::Callback<void(const FormStructure*)> callback =
789 base::Bind(&AutofillManager::ReturnAutocompleteData, this); 790 base::Bind(&AutofillManager::ReturnAutocompleteData, this);
790 autofill::AutofillDialogController* controller = 791 autofill::AutofillDialogController* controller =
791 new autofill::AutofillDialogController(web_contents(), 792 new autofill::AutofillDialogController(web_contents(),
792 form, 793 form,
793 frame_url, 794 frame_url,
794 ssl_status, 795 ssl_status,
795 callback); 796 callback);
796 controller->Show(); 797 controller->Show();
797 } 798 }
798 799
799 void AutofillManager::ReturnAutocompleteError() { 800 void AutofillManager::ReturnAutocompleteResult(
801 WebFormElement::AutocompleteResult result, const FormData& form_data) {
800 RenderViewHost* host = web_contents()->GetRenderViewHost(); 802 RenderViewHost* host = web_contents()->GetRenderViewHost();
801 if (!host) 803 if (!host)
802 return; 804 return;
803 805
804 host->Send(new AutofillMsg_RequestAutocompleteError(host->GetRoutingID())); 806 host->Send(new AutofillMsg_RequestAutocompleteResult(host->GetRoutingID(),
807 result,
808 form_data));
805 } 809 }
806 810
807 void AutofillManager::ReturnAutocompleteData(const FormStructure* result) { 811 void AutofillManager::ReturnAutocompleteData(const FormStructure* result) {
808 // web_contents() will be NULL when the interactive autocomplete is closed due 812 // web_contents() will be NULL when the interactive autocomplete is closed due
809 // to a tab or browser window closing. 813 // to a tab or browser window closing.
810 if (!web_contents()) 814 if (!web_contents())
811 return; 815 return;
812 816
813 RenderViewHost* host = web_contents()->GetRenderViewHost();
814 if (!host)
815 return;
816
817 if (!result) { 817 if (!result) {
818 ReturnAutocompleteError(); 818 ReturnAutocompleteResult(WebFormElement::AutocompleteResultErrorCancel,
819 return; 819 FormData());
820 } else {
821 ReturnAutocompleteResult(WebFormElement::AutocompleteResultSuccess,
822 result->ToFormData());
820 } 823 }
821
822 host->Send(new AutofillMsg_RequestAutocompleteSuccess(host->GetRoutingID(),
823 result->ToFormData()));
824 } 824 }
825 825
826 void AutofillManager::OnLoadedServerPredictions( 826 void AutofillManager::OnLoadedServerPredictions(
827 const std::string& response_xml) { 827 const std::string& response_xml) {
828 // Parse and store the server predictions. 828 // Parse and store the server predictions.
829 FormStructure::ParseQueryResponse(response_xml, 829 FormStructure::ParseQueryResponse(response_xml,
830 form_structures_.get(), 830 form_structures_.get(),
831 *metric_logger_); 831 *metric_logger_);
832 832
833 // If the corresponding flag is set, annotate forms with the predicted types. 833 // If the corresponding flag is set, annotate forms with the predicted types.
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
1277 *profile_guid = IDToGUID(profile_id); 1277 *profile_guid = IDToGUID(profile_id);
1278 } 1278 }
1279 1279
1280 void AutofillManager::UpdateInitialInteractionTimestamp( 1280 void AutofillManager::UpdateInitialInteractionTimestamp(
1281 const TimeTicks& interaction_timestamp) { 1281 const TimeTicks& interaction_timestamp) {
1282 if (initial_interaction_timestamp_.is_null() || 1282 if (initial_interaction_timestamp_.is_null() ||
1283 interaction_timestamp < initial_interaction_timestamp_) { 1283 interaction_timestamp < initial_interaction_timestamp_) {
1284 initial_interaction_timestamp_ = interaction_timestamp; 1284 initial_interaction_timestamp_ = interaction_timestamp;
1285 } 1285 }
1286 } 1286 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698