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

Side by Side Diff: chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc

Issue 12457033: Implements SendAutocheckoutStatus API calls for stats tracking. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing unit tests Created 7 years, 8 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/ui/autofill/autofill_dialog_controller_impl.h" 5 #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 } // namespace 219 } // namespace
220 220
221 AutofillDialogController::~AutofillDialogController() {} 221 AutofillDialogController::~AutofillDialogController() {}
222 222
223 AutofillDialogControllerImpl::AutofillDialogControllerImpl( 223 AutofillDialogControllerImpl::AutofillDialogControllerImpl(
224 content::WebContents* contents, 224 content::WebContents* contents,
225 const FormData& form, 225 const FormData& form,
226 const GURL& source_url, 226 const GURL& source_url,
227 const AutofillMetrics& metric_logger, 227 const AutofillMetrics& metric_logger,
228 DialogType dialog_type, 228 DialogType dialog_type,
229 const base::Callback<void(const FormStructure*)>& callback) 229 const base::Callback<void(const FormStructure*,
230 const std::string&)>& callback)
230 : profile_(Profile::FromBrowserContext(contents->GetBrowserContext())), 231 : profile_(Profile::FromBrowserContext(contents->GetBrowserContext())),
231 contents_(contents), 232 contents_(contents),
232 form_structure_(form, std::string()), 233 form_structure_(form, std::string()),
233 invoked_from_same_origin_(true), 234 invoked_from_same_origin_(true),
234 source_url_(source_url), 235 source_url_(source_url),
235 ssl_status_(form.ssl_status), 236 ssl_status_(form.ssl_status),
236 callback_(callback), 237 callback_(callback),
237 ALLOW_THIS_IN_INITIALIZER_LIST( 238 ALLOW_THIS_IN_INITIALIZER_LIST(
238 account_chooser_model_(this, profile_->GetPrefs())), 239 account_chooser_model_(this, profile_->GetPrefs())),
239 ALLOW_THIS_IN_INITIALIZER_LIST( 240 ALLOW_THIS_IN_INITIALIZER_LIST(
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 AutofillMetrics::SECURITY_METRIC_CROSS_ORIGIN_FRAME); 294 AutofillMetrics::SECURITY_METRIC_CROSS_ORIGIN_FRAME);
294 } 295 }
295 296
296 // Determine what field types should be included in the dialog. 297 // Determine what field types should be included in the dialog.
297 bool has_types = false; 298 bool has_types = false;
298 bool has_sections = false; 299 bool has_sections = false;
299 form_structure_.ParseFieldTypesFromAutocompleteAttributes(&has_types, 300 form_structure_.ParseFieldTypesFromAutocompleteAttributes(&has_types,
300 &has_sections); 301 &has_sections);
301 // Fail if the author didn't specify autocomplete types. 302 // Fail if the author didn't specify autocomplete types.
302 if (!has_types) { 303 if (!has_types) {
303 callback_.Run(NULL); 304 callback_.Run(NULL, std::string());
304 delete this; 305 delete this;
305 return; 306 return;
306 } 307 }
307 308
308 const DetailInput kEmailInputs[] = { 309 const DetailInput kEmailInputs[] = {
309 { 1, EMAIL_ADDRESS, IDS_AUTOFILL_DIALOG_PLACEHOLDER_EMAIL }, 310 { 1, EMAIL_ADDRESS, IDS_AUTOFILL_DIALOG_PLACEHOLDER_EMAIL },
310 }; 311 };
311 312
312 const DetailInput kCCInputs[] = { 313 const DetailInput kCCInputs[] = {
313 { 2, CREDIT_CARD_NUMBER, IDS_AUTOFILL_DIALOG_PLACEHOLDER_CARD_NUMBER }, 314 { 2, CREDIT_CARD_NUMBER, IDS_AUTOFILL_DIALOG_PLACEHOLDER_CARD_NUMBER },
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after
1057 metric_logger_.LogDialogUiDuration( 1058 metric_logger_.LogDialogUiDuration(
1058 base::Time::Now() - dialog_shown_timestamp_, 1059 base::Time::Now() - dialog_shown_timestamp_,
1059 dialog_type_, 1060 dialog_type_,
1060 AutofillMetrics::DIALOG_CANCELED); 1061 AutofillMetrics::DIALOG_CANCELED);
1061 } 1062 }
1062 1063
1063 // If Autocheckout has an error, it's possible that the dialog will be 1064 // If Autocheckout has an error, it's possible that the dialog will be
1064 // submitted to start the flow and then cancelled to close the dialog after 1065 // submitted to start the flow and then cancelled to close the dialog after
1065 // the error. 1066 // the error.
1066 if (!callback_.is_null()) { 1067 if (!callback_.is_null()) {
1067 callback_.Run(NULL); 1068 callback_.Run(NULL, std::string());
1068 callback_ = base::Callback<void(const FormStructure*)>(); 1069 callback_ = base::Callback<void(const FormStructure*,
1070 const std::string&)>();
1069 } 1071 }
1070 } 1072 }
1071 1073
1072 void AutofillDialogControllerImpl::OnSubmit() { 1074 void AutofillDialogControllerImpl::OnSubmit() {
1073 did_submit_ = true; 1075 did_submit_ = true;
1074 metric_logger_.LogDialogUiDuration( 1076 metric_logger_.LogDialogUiDuration(
1075 base::Time::Now() - dialog_shown_timestamp_, 1077 base::Time::Now() - dialog_shown_timestamp_,
1076 dialog_type_, 1078 dialog_type_,
1077 AutofillMetrics::DIALOG_ACCEPTED); 1079 AutofillMetrics::DIALOG_ACCEPTED);
1078 1080
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
1282 void AutofillDialogControllerImpl::OnDidSaveInstrumentAndAddress( 1284 void AutofillDialogControllerImpl::OnDidSaveInstrumentAndAddress(
1283 const std::string& instrument_id, 1285 const std::string& instrument_id,
1284 const std::string& address_id, 1286 const std::string& address_id,
1285 const std::vector<wallet::RequiredAction>& required_actions) { 1287 const std::vector<wallet::RequiredAction>& required_actions) {
1286 // TODO(dbeam): handle required actions. 1288 // TODO(dbeam): handle required actions.
1287 active_instrument_id_ = instrument_id; 1289 active_instrument_id_ = instrument_id;
1288 active_address_id_ = address_id; 1290 active_address_id_ = address_id;
1289 GetFullWallet(); 1291 GetFullWallet();
1290 } 1292 }
1291 1293
1292 void AutofillDialogControllerImpl::OnDidSendAutocheckoutStatus() {
1293 NOTIMPLEMENTED();
1294 }
1295
1296 void AutofillDialogControllerImpl::OnDidUpdateAddress( 1294 void AutofillDialogControllerImpl::OnDidUpdateAddress(
1297 const std::string& address_id, 1295 const std::string& address_id,
1298 const std::vector<wallet::RequiredAction>& required_actions) { 1296 const std::vector<wallet::RequiredAction>& required_actions) {
1299 // TODO(dbeam): Handle this callback. 1297 // TODO(dbeam): Handle this callback.
1300 NOTIMPLEMENTED() << " address_id=" << address_id; 1298 NOTIMPLEMENTED() << " address_id=" << address_id;
1301 } 1299 }
1302 1300
1303 void AutofillDialogControllerImpl::OnDidUpdateInstrument( 1301 void AutofillDialogControllerImpl::OnDidUpdateInstrument(
1304 const std::string& instrument_id, 1302 const std::string& instrument_id,
1305 const std::vector<wallet::RequiredAction>& required_actions) { 1303 const std::vector<wallet::RequiredAction>& required_actions) {
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
1802 if (ShouldUseBillingForShipping()) { 1800 if (ShouldUseBillingForShipping()) {
1803 FillOutputForSectionWithComparator( 1801 FillOutputForSectionWithComparator(
1804 SECTION_BILLING, 1802 SECTION_BILLING,
1805 base::Bind(DetailInputMatchesShippingField)); 1803 base::Bind(DetailInputMatchesShippingField));
1806 FillOutputForSectionWithComparator( 1804 FillOutputForSectionWithComparator(
1807 SECTION_CC, 1805 SECTION_CC,
1808 base::Bind(DetailInputMatchesShippingField)); 1806 base::Bind(DetailInputMatchesShippingField));
1809 } else { 1807 } else {
1810 FillOutputForSection(SECTION_SHIPPING); 1808 FillOutputForSection(SECTION_SHIPPING);
1811 } 1809 }
1812 callback_.Run(&form_structure_); 1810 if (wallet_items_)
1813 callback_ = base::Callback<void(const FormStructure*)>(); 1811 callback_.Run(&form_structure_, wallet_items_->google_transaction_id());
1812 else
1813 callback_.Run(&form_structure_, std::string());
1814 callback_ = base::Callback<void(const FormStructure*, const std::string&)>();
1814 1815
1815 if (dialog_type_ == DIALOG_TYPE_REQUEST_AUTOCOMPLETE) { 1816 if (dialog_type_ == DIALOG_TYPE_REQUEST_AUTOCOMPLETE) {
1816 // This may delete us. 1817 // This may delete us.
1817 Hide(); 1818 Hide();
1818 } 1819 }
1819 } 1820 }
1820 1821
1821 AutofillMetrics::DialogInitialUserStateMetric 1822 AutofillMetrics::DialogInitialUserStateMetric
1822 AutofillDialogControllerImpl::GetInitialUserState() const { 1823 AutofillDialogControllerImpl::GetInitialUserState() const {
1823 // Consider a user to be an Autofill user if the user has any credit cards 1824 // Consider a user to be an Autofill user if the user has any credit cards
(...skipping 18 matching lines...) Expand all
1842 AutofillMetrics::DIALOG_USER_SIGNED_IN_NO_WALLET_NO_AUTOFILL; 1843 AutofillMetrics::DIALOG_USER_SIGNED_IN_NO_WALLET_NO_AUTOFILL;
1843 } 1844 }
1844 1845
1845 // Has Wallet items. 1846 // Has Wallet items.
1846 return has_autofill_profiles ? 1847 return has_autofill_profiles ?
1847 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_HAS_AUTOFILL : 1848 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_HAS_AUTOFILL :
1848 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_NO_AUTOFILL; 1849 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_NO_AUTOFILL;
1849 } 1850 }
1850 1851
1851 } // namespace autofill 1852 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698