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

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: DCHECK Created 7 years, 9 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 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 } // namespace 218 } // namespace
219 219
220 AutofillDialogController::~AutofillDialogController() {} 220 AutofillDialogController::~AutofillDialogController() {}
221 221
222 AutofillDialogControllerImpl::AutofillDialogControllerImpl( 222 AutofillDialogControllerImpl::AutofillDialogControllerImpl(
223 content::WebContents* contents, 223 content::WebContents* contents,
224 const FormData& form, 224 const FormData& form,
225 const GURL& source_url, 225 const GURL& source_url,
226 const AutofillMetrics& metric_logger, 226 const AutofillMetrics& metric_logger,
227 DialogType dialog_type, 227 DialogType dialog_type,
228 const base::Callback<void(const FormStructure*)>& callback) 228 const base::Callback<void(const FormStructure*,
229 const std::string&)>& callback)
229 : profile_(Profile::FromBrowserContext(contents->GetBrowserContext())), 230 : profile_(Profile::FromBrowserContext(contents->GetBrowserContext())),
230 contents_(contents), 231 contents_(contents),
231 form_structure_(form, std::string()), 232 form_structure_(form, std::string()),
232 invoked_from_same_origin_(true), 233 invoked_from_same_origin_(true),
233 source_url_(source_url), 234 source_url_(source_url),
234 ssl_status_(form.ssl_status), 235 ssl_status_(form.ssl_status),
235 callback_(callback), 236 callback_(callback),
236 ALLOW_THIS_IN_INITIALIZER_LIST( 237 ALLOW_THIS_IN_INITIALIZER_LIST(
237 account_chooser_model_(this, profile_->GetPrefs())), 238 account_chooser_model_(this, profile_->GetPrefs())),
238 ALLOW_THIS_IN_INITIALIZER_LIST( 239 ALLOW_THIS_IN_INITIALIZER_LIST(
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 AutofillMetrics::SECURITY_METRIC_CROSS_ORIGIN_FRAME); 293 AutofillMetrics::SECURITY_METRIC_CROSS_ORIGIN_FRAME);
293 } 294 }
294 295
295 // Determine what field types should be included in the dialog. 296 // Determine what field types should be included in the dialog.
296 bool has_types = false; 297 bool has_types = false;
297 bool has_sections = false; 298 bool has_sections = false;
298 form_structure_.ParseFieldTypesFromAutocompleteAttributes(&has_types, 299 form_structure_.ParseFieldTypesFromAutocompleteAttributes(&has_types,
299 &has_sections); 300 &has_sections);
300 // Fail if the author didn't specify autocomplete types. 301 // Fail if the author didn't specify autocomplete types.
301 if (!has_types) { 302 if (!has_types) {
302 callback_.Run(NULL); 303 callback_.Run(NULL, std::string());
303 delete this; 304 delete this;
304 return; 305 return;
305 } 306 }
306 307
307 const DetailInput kEmailInputs[] = { 308 const DetailInput kEmailInputs[] = {
308 { 1, EMAIL_ADDRESS, IDS_AUTOFILL_DIALOG_PLACEHOLDER_EMAIL }, 309 { 1, EMAIL_ADDRESS, IDS_AUTOFILL_DIALOG_PLACEHOLDER_EMAIL },
309 }; 310 };
310 311
311 const DetailInput kCCInputs[] = { 312 const DetailInput kCCInputs[] = {
312 { 2, CREDIT_CARD_NUMBER, IDS_AUTOFILL_DIALOG_PLACEHOLDER_CARD_NUMBER }, 313 { 2, CREDIT_CARD_NUMBER, IDS_AUTOFILL_DIALOG_PLACEHOLDER_CARD_NUMBER },
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after
996 metric_logger_.LogDialogUiDuration( 997 metric_logger_.LogDialogUiDuration(
997 base::Time::Now() - dialog_shown_timestamp_, 998 base::Time::Now() - dialog_shown_timestamp_,
998 dialog_type_, 999 dialog_type_,
999 AutofillMetrics::DIALOG_CANCELED); 1000 AutofillMetrics::DIALOG_CANCELED);
1000 } 1001 }
1001 1002
1002 // If Autocheckout has an error, it's possible that the dialog will be 1003 // If Autocheckout has an error, it's possible that the dialog will be
1003 // submitted to start the flow and then cancelled to close the dialog after 1004 // submitted to start the flow and then cancelled to close the dialog after
1004 // the error. 1005 // the error.
1005 if (!callback_.is_null()) { 1006 if (!callback_.is_null()) {
1006 callback_.Run(NULL); 1007 callback_.Run(NULL, std::string());
1007 callback_ = base::Callback<void(const FormStructure*)>(); 1008 callback_ = base::Callback<void(const FormStructure*,
1009 const std::string&)>();
1008 } 1010 }
1009 } 1011 }
1010 1012
1011 void AutofillDialogControllerImpl::OnSubmit() { 1013 void AutofillDialogControllerImpl::OnSubmit() {
1012 did_submit_ = true; 1014 did_submit_ = true;
1013 metric_logger_.LogDialogUiDuration( 1015 metric_logger_.LogDialogUiDuration(
1014 base::Time::Now() - dialog_shown_timestamp_, 1016 base::Time::Now() - dialog_shown_timestamp_,
1015 dialog_type_, 1017 dialog_type_,
1016 AutofillMetrics::DIALOG_ACCEPTED); 1018 AutofillMetrics::DIALOG_ACCEPTED);
1017 1019
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
1187 void AutofillDialogControllerImpl::OnDidSaveInstrumentAndAddress( 1189 void AutofillDialogControllerImpl::OnDidSaveInstrumentAndAddress(
1188 const std::string& instrument_id, 1190 const std::string& instrument_id,
1189 const std::string& address_id, 1191 const std::string& address_id,
1190 const std::vector<wallet::RequiredAction>& required_actions) { 1192 const std::vector<wallet::RequiredAction>& required_actions) {
1191 // TODO(dbeam): handle required actions. 1193 // TODO(dbeam): handle required actions.
1192 active_instrument_id_ = instrument_id; 1194 active_instrument_id_ = instrument_id;
1193 active_address_id_ = address_id; 1195 active_address_id_ = address_id;
1194 GetFullWallet(); 1196 GetFullWallet();
1195 } 1197 }
1196 1198
1197 void AutofillDialogControllerImpl::OnDidSendAutocheckoutStatus() {
1198 NOTIMPLEMENTED();
1199 }
1200
1201 void AutofillDialogControllerImpl::OnDidUpdateAddress( 1199 void AutofillDialogControllerImpl::OnDidUpdateAddress(
1202 const std::string& address_id, 1200 const std::string& address_id,
1203 const std::vector<wallet::RequiredAction>& required_actions) { 1201 const std::vector<wallet::RequiredAction>& required_actions) {
1204 // TODO(dbeam): Handle this callback. 1202 // TODO(dbeam): Handle this callback.
1205 NOTIMPLEMENTED() << " address_id=" << address_id; 1203 NOTIMPLEMENTED() << " address_id=" << address_id;
1206 } 1204 }
1207 1205
1208 void AutofillDialogControllerImpl::OnDidUpdateInstrument( 1206 void AutofillDialogControllerImpl::OnDidUpdateInstrument(
1209 const std::string& instrument_id, 1207 const std::string& instrument_id,
1210 const std::vector<wallet::RequiredAction>& required_actions) { 1208 const std::vector<wallet::RequiredAction>& required_actions) {
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
1707 if (ShouldUseBillingForShipping()) { 1705 if (ShouldUseBillingForShipping()) {
1708 FillOutputForSectionWithComparator( 1706 FillOutputForSectionWithComparator(
1709 SECTION_BILLING, 1707 SECTION_BILLING,
1710 base::Bind(DetailInputMatchesShippingField)); 1708 base::Bind(DetailInputMatchesShippingField));
1711 FillOutputForSectionWithComparator( 1709 FillOutputForSectionWithComparator(
1712 SECTION_CC, 1710 SECTION_CC,
1713 base::Bind(DetailInputMatchesShippingField)); 1711 base::Bind(DetailInputMatchesShippingField));
1714 } else { 1712 } else {
1715 FillOutputForSection(SECTION_SHIPPING); 1713 FillOutputForSection(SECTION_SHIPPING);
1716 } 1714 }
1717 callback_.Run(&form_structure_); 1715 if (wallet_items_)
1718 callback_ = base::Callback<void(const FormStructure*)>(); 1716 callback_.Run(&form_structure_, wallet_items_->google_transaction_id());
1717 else
1718 callback_.Run(&form_structure_, std::string());
1719 callback_ = base::Callback<void(const FormStructure*, const std::string&)>();
1719 1720
1720 if (dialog_type_ == DIALOG_TYPE_REQUEST_AUTOCOMPLETE) { 1721 if (dialog_type_ == DIALOG_TYPE_REQUEST_AUTOCOMPLETE) {
1721 // This may delete us. 1722 // This may delete us.
1722 Hide(); 1723 Hide();
1723 } 1724 }
1724 } 1725 }
1725 1726
1726 AutofillMetrics::DialogInitialUserStateMetric 1727 AutofillMetrics::DialogInitialUserStateMetric
1727 AutofillDialogControllerImpl::GetInitialUserState() const { 1728 AutofillDialogControllerImpl::GetInitialUserState() const {
1728 // Consider a user to be an Autofill user if the user has any credit cards 1729 // Consider a user to be an Autofill user if the user has any credit cards
(...skipping 18 matching lines...) Expand all
1747 AutofillMetrics::DIALOG_USER_SIGNED_IN_NO_WALLET_NO_AUTOFILL; 1748 AutofillMetrics::DIALOG_USER_SIGNED_IN_NO_WALLET_NO_AUTOFILL;
1748 } 1749 }
1749 1750
1750 // Has Wallet items. 1751 // Has Wallet items.
1751 return has_autofill_profiles ? 1752 return has_autofill_profiles ?
1752 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_HAS_AUTOFILL : 1753 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_HAS_AUTOFILL :
1753 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_NO_AUTOFILL; 1754 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_NO_AUTOFILL;
1754 } 1755 }
1755 1756
1756 } // namespace autofill 1757 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698