OLD | NEW |
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 <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 } | 494 } |
495 | 495 |
496 } // namespace | 496 } // namespace |
497 | 497 |
498 AutofillDialogViewDelegate::~AutofillDialogViewDelegate() {} | 498 AutofillDialogViewDelegate::~AutofillDialogViewDelegate() {} |
499 | 499 |
500 AutofillDialogControllerImpl::~AutofillDialogControllerImpl() { | 500 AutofillDialogControllerImpl::~AutofillDialogControllerImpl() { |
501 if (popup_controller_) | 501 if (popup_controller_) |
502 popup_controller_->Hide(); | 502 popup_controller_->Hide(); |
503 | 503 |
504 GetMetricLogger().LogDialogInitialUserState( | 504 GetMetricLogger().LogDialogInitialUserState(initial_user_state_); |
505 GetDialogType(), initial_user_state_); | |
506 } | 505 } |
507 | 506 |
508 // static | 507 // static |
509 base::WeakPtr<AutofillDialogControllerImpl> | 508 base::WeakPtr<AutofillDialogControllerImpl> |
510 AutofillDialogControllerImpl::Create( | 509 AutofillDialogControllerImpl::Create( |
511 content::WebContents* contents, | 510 content::WebContents* contents, |
512 const FormData& form_structure, | 511 const FormData& form_structure, |
513 const GURL& source_url, | 512 const GURL& source_url, |
514 const DialogType dialog_type, | |
515 const base::Callback<void(const FormStructure*, | 513 const base::Callback<void(const FormStructure*, |
516 const std::string&)>& callback) { | 514 const std::string&)>& callback) { |
517 // AutofillDialogControllerImpl owns itself. | 515 // AutofillDialogControllerImpl owns itself. |
518 AutofillDialogControllerImpl* autofill_dialog_controller = | 516 AutofillDialogControllerImpl* autofill_dialog_controller = |
519 new AutofillDialogControllerImpl(contents, | 517 new AutofillDialogControllerImpl(contents, |
520 form_structure, | 518 form_structure, |
521 source_url, | 519 source_url, |
522 dialog_type, | |
523 callback); | 520 callback); |
524 return autofill_dialog_controller->weak_ptr_factory_.GetWeakPtr(); | 521 return autofill_dialog_controller->weak_ptr_factory_.GetWeakPtr(); |
525 } | 522 } |
526 | 523 |
527 // static | 524 // static |
528 void AutofillDialogControllerImpl::RegisterProfilePrefs( | 525 void AutofillDialogControllerImpl::RegisterProfilePrefs( |
529 user_prefs::PrefRegistrySyncable* registry) { | 526 user_prefs::PrefRegistrySyncable* registry) { |
530 registry->RegisterIntegerPref( | 527 registry->RegisterIntegerPref( |
531 ::prefs::kAutofillDialogShowCount, | 528 ::prefs::kAutofillDialogShowCount, |
532 0, | 529 0, |
(...skipping 13 matching lines...) Expand all Loading... |
546 ::prefs::kAutofillDialogSaveData, | 543 ::prefs::kAutofillDialogSaveData, |
547 true, | 544 true, |
548 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | 545 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
549 } | 546 } |
550 | 547 |
551 // static | 548 // static |
552 base::WeakPtr<AutofillDialogController> AutofillDialogController::Create( | 549 base::WeakPtr<AutofillDialogController> AutofillDialogController::Create( |
553 content::WebContents* contents, | 550 content::WebContents* contents, |
554 const FormData& form_structure, | 551 const FormData& form_structure, |
555 const GURL& source_url, | 552 const GURL& source_url, |
556 const DialogType dialog_type, | |
557 const base::Callback<void(const FormStructure*, | 553 const base::Callback<void(const FormStructure*, |
558 const std::string&)>& callback) { | 554 const std::string&)>& callback) { |
559 return AutofillDialogControllerImpl::Create(contents, | 555 return AutofillDialogControllerImpl::Create(contents, |
560 form_structure, | 556 form_structure, |
561 source_url, | 557 source_url, |
562 dialog_type, | |
563 callback); | 558 callback); |
564 } | 559 } |
565 | 560 |
566 // static | 561 // static |
567 void AutofillDialogController::RegisterProfilePrefs( | 562 void AutofillDialogController::RegisterProfilePrefs( |
568 user_prefs::PrefRegistrySyncable* registry) { | 563 user_prefs::PrefRegistrySyncable* registry) { |
569 AutofillDialogControllerImpl::RegisterProfilePrefs(registry); | 564 AutofillDialogControllerImpl::RegisterProfilePrefs(registry); |
570 } | 565 } |
571 | 566 |
572 void AutofillDialogControllerImpl::Show() { | 567 void AutofillDialogControllerImpl::Show() { |
573 dialog_shown_timestamp_ = base::Time::Now(); | 568 dialog_shown_timestamp_ = base::Time::Now(); |
574 | 569 |
575 content::NavigationEntry* entry = | 570 content::NavigationEntry* entry = |
576 web_contents()->GetController().GetActiveEntry(); | 571 web_contents()->GetController().GetActiveEntry(); |
577 const GURL& active_url = entry ? entry->GetURL() : web_contents()->GetURL(); | 572 const GURL& active_url = entry ? entry->GetURL() : web_contents()->GetURL(); |
578 invoked_from_same_origin_ = active_url.GetOrigin() == source_url_.GetOrigin(); | 573 invoked_from_same_origin_ = active_url.GetOrigin() == source_url_.GetOrigin(); |
579 | 574 |
580 // Log any relevant UI metrics and security exceptions. | 575 // Log any relevant UI metrics and security exceptions. |
581 GetMetricLogger().LogDialogUiEvent( | 576 GetMetricLogger().LogDialogUiEvent(AutofillMetrics::DIALOG_UI_SHOWN); |
582 GetDialogType(), AutofillMetrics::DIALOG_UI_SHOWN); | |
583 | 577 |
584 GetMetricLogger().LogDialogSecurityMetric( | 578 GetMetricLogger().LogDialogSecurityMetric( |
585 GetDialogType(), AutofillMetrics::SECURITY_METRIC_DIALOG_SHOWN); | 579 AutofillMetrics::SECURITY_METRIC_DIALOG_SHOWN); |
586 | 580 |
587 if (RequestingCreditCardInfo() && !TransmissionWillBeSecure()) { | 581 if (RequestingCreditCardInfo() && !TransmissionWillBeSecure()) { |
588 GetMetricLogger().LogDialogSecurityMetric( | 582 GetMetricLogger().LogDialogSecurityMetric( |
589 GetDialogType(), | |
590 AutofillMetrics::SECURITY_METRIC_CREDIT_CARD_OVER_HTTP); | 583 AutofillMetrics::SECURITY_METRIC_CREDIT_CARD_OVER_HTTP); |
591 } | 584 } |
592 | 585 |
593 if (!invoked_from_same_origin_) { | 586 if (!invoked_from_same_origin_) { |
594 GetMetricLogger().LogDialogSecurityMetric( | 587 GetMetricLogger().LogDialogSecurityMetric( |
595 GetDialogType(), | |
596 AutofillMetrics::SECURITY_METRIC_CROSS_ORIGIN_FRAME); | 588 AutofillMetrics::SECURITY_METRIC_CROSS_ORIGIN_FRAME); |
597 } | 589 } |
598 | 590 |
599 // Determine what field types should be included in the dialog. | 591 // Determine what field types should be included in the dialog. |
600 bool has_types = false; | 592 bool has_types = false; |
601 bool has_sections = false; | 593 bool has_sections = false; |
602 form_structure_.ParseFieldTypesFromAutocompleteAttributes( | 594 form_structure_.ParseFieldTypesFromAutocompleteAttributes( |
603 &has_types, &has_sections); | 595 &has_types, &has_sections); |
604 | 596 |
605 // Fail if the author didn't specify autocomplete types. | 597 // Fail if the author didn't specify autocomplete types. |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
765 | 757 |
766 return true; | 758 return true; |
767 } | 759 } |
768 | 760 |
769 DCHECK_EQ(ui::DIALOG_BUTTON_CANCEL, button); | 761 DCHECK_EQ(ui::DIALOG_BUTTON_CANCEL, button); |
770 return !is_submitting_ || IsSubmitPausedOn(wallet::VERIFY_CVV); | 762 return !is_submitting_ || IsSubmitPausedOn(wallet::VERIFY_CVV); |
771 } | 763 } |
772 | 764 |
773 DialogOverlayState AutofillDialogControllerImpl::GetDialogOverlay() const { | 765 DialogOverlayState AutofillDialogControllerImpl::GetDialogOverlay() const { |
774 bool show_wallet_interstitial = IsPayingWithWallet() && is_submitting_ && | 766 bool show_wallet_interstitial = IsPayingWithWallet() && is_submitting_ && |
775 !IsSubmitPausedOn(wallet::VERIFY_CVV) && | 767 !IsSubmitPausedOn(wallet::VERIFY_CVV); |
776 GetDialogType() == DIALOG_TYPE_REQUEST_AUTOCOMPLETE; | |
777 if (!show_wallet_interstitial) | 768 if (!show_wallet_interstitial) |
778 return DialogOverlayState(); | 769 return DialogOverlayState(); |
779 | 770 |
780 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 771 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
781 DialogOverlayState state; | 772 DialogOverlayState state; |
782 | 773 |
783 state.strings.push_back(DialogOverlayString()); | 774 state.strings.push_back(DialogOverlayString()); |
784 DialogOverlayString& string = state.strings.back(); | 775 DialogOverlayString& string = state.strings.back(); |
785 string.font = rb.GetFont(ui::ResourceBundle::BaseFont).DeriveFont(4); | 776 string.font = rb.GetFont(ui::ResourceBundle::BaseFont).DeriveFont(4); |
786 string.alignment = gfx::ALIGN_CENTER; | 777 string.alignment = gfx::ALIGN_CENTER; |
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1437 | 1428 |
1438 DetailInputs* inputs = MutableRequestedFieldsForSection(section); | 1429 DetailInputs* inputs = MutableRequestedFieldsForSection(section); |
1439 for (DetailInputs::iterator it = inputs->begin(); it != inputs->end(); ++it) { | 1430 for (DetailInputs::iterator it = inputs->begin(); it != inputs->end(); ++it) { |
1440 it->editable = InputIsEditable(*it, section); | 1431 it->editable = InputIsEditable(*it, section); |
1441 } | 1432 } |
1442 model->FillInputs(inputs); | 1433 model->FillInputs(inputs); |
1443 | 1434 |
1444 UpdateSection(section); | 1435 UpdateSection(section); |
1445 | 1436 |
1446 GetMetricLogger().LogDialogUiEvent( | 1437 GetMetricLogger().LogDialogUiEvent( |
1447 GetDialogType(), common::DialogSectionToUiEditEvent(section)); | 1438 common::DialogSectionToUiEditEvent(section)); |
1448 } | 1439 } |
1449 | 1440 |
1450 gfx::Image AutofillDialogControllerImpl::IconForField( | 1441 gfx::Image AutofillDialogControllerImpl::IconForField( |
1451 ServerFieldType type, const string16& user_input) const { | 1442 ServerFieldType type, const string16& user_input) const { |
1452 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 1443 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
1453 if (type == CREDIT_CARD_VERIFICATION_CODE) | 1444 if (type == CREDIT_CARD_VERIFICATION_CODE) |
1454 return rb.GetImageNamed(IDR_CREDIT_CARD_CVC_HINT); | 1445 return rb.GetImageNamed(IDR_CREDIT_CARD_CVC_HINT); |
1455 | 1446 |
1456 if (type == CREDIT_CARD_NUMBER) { | 1447 if (type == CREDIT_CARD_NUMBER) { |
1457 const int input_card_idr = CreditCard::IconResourceId( | 1448 const int input_card_idr = CreditCard::IconResourceId( |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1840 if (signin_registrar_.IsEmpty()) { | 1831 if (signin_registrar_.IsEmpty()) { |
1841 // Start sign in. | 1832 // Start sign in. |
1842 DCHECK(!IsPayingWithWallet()); | 1833 DCHECK(!IsPayingWithWallet()); |
1843 | 1834 |
1844 content::Source<content::NavigationController> source(view_->ShowSignIn()); | 1835 content::Source<content::NavigationController> source(view_->ShowSignIn()); |
1845 signin_registrar_.Add( | 1836 signin_registrar_.Add( |
1846 this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, source); | 1837 this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, source); |
1847 view_->UpdateAccountChooser(); | 1838 view_->UpdateAccountChooser(); |
1848 | 1839 |
1849 GetMetricLogger().LogDialogUiEvent( | 1840 GetMetricLogger().LogDialogUiEvent( |
1850 GetDialogType(), AutofillMetrics::DIALOG_UI_SIGNIN_SHOWN); | 1841 AutofillMetrics::DIALOG_UI_SIGNIN_SHOWN); |
1851 } else { | 1842 } else { |
1852 HideSignIn(); | 1843 HideSignIn(); |
1853 } | 1844 } |
1854 } | 1845 } |
1855 | 1846 |
1856 void AutofillDialogControllerImpl::NotificationCheckboxStateChanged( | 1847 void AutofillDialogControllerImpl::NotificationCheckboxStateChanged( |
1857 DialogNotification::Type type, bool checked) { | 1848 DialogNotification::Type type, bool checked) { |
1858 if (type == DialogNotification::WALLET_USAGE_CONFIRMATION) { | 1849 if (type == DialogNotification::WALLET_USAGE_CONFIRMATION) { |
1859 if (checked) | 1850 if (checked) |
1860 account_chooser_model_.SelectActiveWalletAccount(); | 1851 account_chooser_model_.SelectActiveWalletAccount(); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1911 | 1902 |
1912 content::WebContents* AutofillDialogControllerImpl::GetWebContents() { | 1903 content::WebContents* AutofillDialogControllerImpl::GetWebContents() { |
1913 return web_contents(); | 1904 return web_contents(); |
1914 } | 1905 } |
1915 | 1906 |
1916 //////////////////////////////////////////////////////////////////////////////// | 1907 //////////////////////////////////////////////////////////////////////////////// |
1917 // AutofillPopupDelegate implementation. | 1908 // AutofillPopupDelegate implementation. |
1918 | 1909 |
1919 void AutofillDialogControllerImpl::OnPopupShown( | 1910 void AutofillDialogControllerImpl::OnPopupShown( |
1920 content::RenderWidgetHost::KeyPressEventCallback* callback) { | 1911 content::RenderWidgetHost::KeyPressEventCallback* callback) { |
1921 GetMetricLogger().LogDialogPopupEvent( | 1912 GetMetricLogger().LogDialogPopupEvent(AutofillMetrics::DIALOG_POPUP_SHOWN); |
1922 GetDialogType(), AutofillMetrics::DIALOG_POPUP_SHOWN); | |
1923 } | 1913 } |
1924 | 1914 |
1925 void AutofillDialogControllerImpl::OnPopupHidden( | 1915 void AutofillDialogControllerImpl::OnPopupHidden( |
1926 content::RenderWidgetHost::KeyPressEventCallback* callback) {} | 1916 content::RenderWidgetHost::KeyPressEventCallback* callback) {} |
1927 | 1917 |
1928 bool AutofillDialogControllerImpl::ShouldRepostEvent( | 1918 bool AutofillDialogControllerImpl::ShouldRepostEvent( |
1929 const ui::MouseEvent& event) { | 1919 const ui::MouseEvent& event) { |
1930 // If the event would be reposted inside |input_showing_popup_|, just ignore. | 1920 // If the event would be reposted inside |input_showing_popup_|, just ignore. |
1931 return !view_->HitTestInput(*input_showing_popup_, event.location()); | 1921 return !view_->HitTestInput(*input_showing_popup_, event.location()); |
1932 } | 1922 } |
(...skipping 16 matching lines...) Expand all Loading... |
1949 GetManager()->GetProfileByGUID(pair.first), pair.second)); | 1939 GetManager()->GetProfileByGUID(pair.first), pair.second)); |
1950 } | 1940 } |
1951 | 1941 |
1952 for (size_t i = SECTION_MIN; i <= SECTION_MAX; ++i) { | 1942 for (size_t i = SECTION_MIN; i <= SECTION_MAX; ++i) { |
1953 DialogSection section = static_cast<DialogSection>(i); | 1943 DialogSection section = static_cast<DialogSection>(i); |
1954 wrapper->FillInputs(MutableRequestedFieldsForSection(section)); | 1944 wrapper->FillInputs(MutableRequestedFieldsForSection(section)); |
1955 view_->FillSection(section, *input_showing_popup_); | 1945 view_->FillSection(section, *input_showing_popup_); |
1956 } | 1946 } |
1957 | 1947 |
1958 GetMetricLogger().LogDialogPopupEvent( | 1948 GetMetricLogger().LogDialogPopupEvent( |
1959 GetDialogType(), AutofillMetrics::DIALOG_POPUP_FORM_FILLED); | 1949 AutofillMetrics::DIALOG_POPUP_FORM_FILLED); |
1960 | 1950 |
1961 // TODO(estade): not sure why it's necessary to do this explicitly. | 1951 // TODO(estade): not sure why it's necessary to do this explicitly. |
1962 HidePopup(); | 1952 HidePopup(); |
1963 } | 1953 } |
1964 | 1954 |
1965 void AutofillDialogControllerImpl::RemoveSuggestion(const string16& value, | 1955 void AutofillDialogControllerImpl::RemoveSuggestion(const string16& value, |
1966 int identifier) { | 1956 int identifier) { |
1967 // TODO(estade): implement. | 1957 // TODO(estade): implement. |
1968 } | 1958 } |
1969 | 1959 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2027 LogSuggestionItemSelectedMetric(*model); | 2017 LogSuggestionItemSelectedMetric(*model); |
2028 } | 2018 } |
2029 | 2019 |
2030 //////////////////////////////////////////////////////////////////////////////// | 2020 //////////////////////////////////////////////////////////////////////////////// |
2031 // wallet::WalletClientDelegate implementation. | 2021 // wallet::WalletClientDelegate implementation. |
2032 | 2022 |
2033 const AutofillMetrics& AutofillDialogControllerImpl::GetMetricLogger() const { | 2023 const AutofillMetrics& AutofillDialogControllerImpl::GetMetricLogger() const { |
2034 return metric_logger_; | 2024 return metric_logger_; |
2035 } | 2025 } |
2036 | 2026 |
2037 DialogType AutofillDialogControllerImpl::GetDialogType() const { | |
2038 return dialog_type_; | |
2039 } | |
2040 | |
2041 std::string AutofillDialogControllerImpl::GetRiskData() const { | 2027 std::string AutofillDialogControllerImpl::GetRiskData() const { |
2042 DCHECK(!risk_data_.empty()); | 2028 DCHECK(!risk_data_.empty()); |
2043 return risk_data_; | 2029 return risk_data_; |
2044 } | 2030 } |
2045 | 2031 |
2046 std::string AutofillDialogControllerImpl::GetWalletCookieValue() const { | 2032 std::string AutofillDialogControllerImpl::GetWalletCookieValue() const { |
2047 return wallet_cookie_value_; | 2033 return wallet_cookie_value_; |
2048 } | 2034 } |
2049 | 2035 |
2050 bool AutofillDialogControllerImpl::IsShippingAddressRequired() const { | 2036 bool AutofillDialogControllerImpl::IsShippingAddressRequired() const { |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2237 NewCreditCardBubbleController::Show(profile(), | 2223 NewCreditCardBubbleController::Show(profile(), |
2238 new_card.Pass(), | 2224 new_card.Pass(), |
2239 billing_profile.Pass()); | 2225 billing_profile.Pass()); |
2240 #endif | 2226 #endif |
2241 } | 2227 } |
2242 | 2228 |
2243 AutofillDialogControllerImpl::AutofillDialogControllerImpl( | 2229 AutofillDialogControllerImpl::AutofillDialogControllerImpl( |
2244 content::WebContents* contents, | 2230 content::WebContents* contents, |
2245 const FormData& form_structure, | 2231 const FormData& form_structure, |
2246 const GURL& source_url, | 2232 const GURL& source_url, |
2247 const DialogType dialog_type, | |
2248 const base::Callback<void(const FormStructure*, | 2233 const base::Callback<void(const FormStructure*, |
2249 const std::string&)>& callback) | 2234 const std::string&)>& callback) |
2250 : WebContentsObserver(contents), | 2235 : WebContentsObserver(contents), |
2251 profile_(Profile::FromBrowserContext(contents->GetBrowserContext())), | 2236 profile_(Profile::FromBrowserContext(contents->GetBrowserContext())), |
2252 initial_user_state_(AutofillMetrics::DIALOG_USER_STATE_UNKNOWN), | 2237 initial_user_state_(AutofillMetrics::DIALOG_USER_STATE_UNKNOWN), |
2253 dialog_type_(dialog_type), | |
2254 form_structure_(form_structure), | 2238 form_structure_(form_structure), |
2255 invoked_from_same_origin_(true), | 2239 invoked_from_same_origin_(true), |
2256 source_url_(source_url), | 2240 source_url_(source_url), |
2257 callback_(callback), | 2241 callback_(callback), |
2258 account_chooser_model_(this, profile_->GetPrefs(), metric_logger_, | 2242 account_chooser_model_(this, profile_->GetPrefs(), metric_logger_), |
2259 dialog_type), | |
2260 wallet_client_(profile_->GetRequestContext(), this), | 2243 wallet_client_(profile_->GetRequestContext(), this), |
2261 suggested_email_(this), | 2244 suggested_email_(this), |
2262 suggested_cc_(this), | 2245 suggested_cc_(this), |
2263 suggested_billing_(this), | 2246 suggested_billing_(this), |
2264 suggested_cc_billing_(this), | 2247 suggested_cc_billing_(this), |
2265 suggested_shipping_(this), | 2248 suggested_shipping_(this), |
2266 cares_about_shipping_(true), | 2249 cares_about_shipping_(true), |
2267 input_showing_popup_(NULL), | 2250 input_showing_popup_(NULL), |
2268 weak_ptr_factory_(this), | 2251 weak_ptr_factory_(this), |
2269 should_show_wallet_promo_(!profile_->GetPrefs()->GetBoolean( | 2252 should_show_wallet_promo_(!profile_->GetPrefs()->GetBoolean( |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2310 PrefService* user_prefs = profile_->GetPrefs(); | 2293 PrefService* user_prefs = profile_->GetPrefs(); |
2311 std::string charset = user_prefs->GetString(::prefs::kDefaultCharset); | 2294 std::string charset = user_prefs->GetString(::prefs::kDefaultCharset); |
2312 std::string accept_languages = | 2295 std::string accept_languages = |
2313 user_prefs->GetString(::prefs::kAcceptLanguages); | 2296 user_prefs->GetString(::prefs::kAcceptLanguages); |
2314 base::Time install_time = base::Time::FromTimeT( | 2297 base::Time install_time = base::Time::FromTimeT( |
2315 g_browser_process->local_state()->GetInt64(::prefs::kInstallDate)); | 2298 g_browser_process->local_state()->GetInt64(::prefs::kInstallDate)); |
2316 | 2299 |
2317 risk::GetFingerprint( | 2300 risk::GetFingerprint( |
2318 obfuscated_gaia_id, window_bounds, *web_contents(), | 2301 obfuscated_gaia_id, window_bounds, *web_contents(), |
2319 chrome::VersionInfo().Version(), charset, accept_languages, install_time, | 2302 chrome::VersionInfo().Version(), charset, accept_languages, install_time, |
2320 dialog_type_, g_browser_process->GetApplicationLocale(), | 2303 g_browser_process->GetApplicationLocale(), |
2321 base::Bind(&AutofillDialogControllerImpl::OnDidLoadRiskFingerprintData, | 2304 base::Bind(&AutofillDialogControllerImpl::OnDidLoadRiskFingerprintData, |
2322 weak_ptr_factory_.GetWeakPtr())); | 2305 weak_ptr_factory_.GetWeakPtr())); |
2323 } | 2306 } |
2324 | 2307 |
2325 void AutofillDialogControllerImpl::OnDidLoadRiskFingerprintData( | 2308 void AutofillDialogControllerImpl::OnDidLoadRiskFingerprintData( |
2326 scoped_ptr<risk::Fingerprint> fingerprint) { | 2309 scoped_ptr<risk::Fingerprint> fingerprint) { |
2327 DCHECK(AreLegalDocumentsCurrent()); | 2310 DCHECK(AreLegalDocumentsCurrent()); |
2328 | 2311 |
2329 std::string proto_data; | 2312 std::string proto_data; |
2330 fingerprint->SerializeToString(&proto_data); | 2313 fingerprint->SerializeToString(&proto_data); |
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3133 } | 3116 } |
3134 | 3117 |
3135 LogOnFinishSubmitMetrics(); | 3118 LogOnFinishSubmitMetrics(); |
3136 | 3119 |
3137 // Callback should be called as late as possible. | 3120 // Callback should be called as late as possible. |
3138 callback_.Run(&form_structure_, !wallet_items_ ? std::string() : | 3121 callback_.Run(&form_structure_, !wallet_items_ ? std::string() : |
3139 wallet_items_->google_transaction_id()); | 3122 wallet_items_->google_transaction_id()); |
3140 data_was_passed_back_ = true; | 3123 data_was_passed_back_ = true; |
3141 | 3124 |
3142 // This might delete us. | 3125 // This might delete us. |
3143 if (GetDialogType() == DIALOG_TYPE_REQUEST_AUTOCOMPLETE) | 3126 Hide(); |
3144 Hide(); | |
3145 } | 3127 } |
3146 | 3128 |
3147 void AutofillDialogControllerImpl::PersistAutofillChoice( | 3129 void AutofillDialogControllerImpl::PersistAutofillChoice( |
3148 DialogSection section, | 3130 DialogSection section, |
3149 const std::string& guid, | 3131 const std::string& guid, |
3150 int variant) { | 3132 int variant) { |
3151 DCHECK(!IsPayingWithWallet()); | 3133 DCHECK(!IsPayingWithWallet()); |
3152 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 3134 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
3153 value->SetString(kGuidPrefKey, guid); | 3135 value->SetString(kGuidPrefKey, guid); |
3154 value->SetInteger(kVariantPrefKey, variant); | 3136 value->SetInteger(kVariantPrefKey, variant); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3204 variant++; | 3186 variant++; |
3205 else | 3187 else |
3206 break; | 3188 break; |
3207 } | 3189 } |
3208 return variant; | 3190 return variant; |
3209 } | 3191 } |
3210 | 3192 |
3211 void AutofillDialogControllerImpl::LogOnFinishSubmitMetrics() { | 3193 void AutofillDialogControllerImpl::LogOnFinishSubmitMetrics() { |
3212 GetMetricLogger().LogDialogUiDuration( | 3194 GetMetricLogger().LogDialogUiDuration( |
3213 base::Time::Now() - dialog_shown_timestamp_, | 3195 base::Time::Now() - dialog_shown_timestamp_, |
3214 GetDialogType(), | |
3215 AutofillMetrics::DIALOG_ACCEPTED); | 3196 AutofillMetrics::DIALOG_ACCEPTED); |
3216 | 3197 |
3217 GetMetricLogger().LogDialogUiEvent( | 3198 GetMetricLogger().LogDialogUiEvent(AutofillMetrics::DIALOG_UI_ACCEPTED); |
3218 GetDialogType(), AutofillMetrics::DIALOG_UI_ACCEPTED); | |
3219 | 3199 |
3220 AutofillMetrics::DialogDismissalState dismissal_state; | 3200 AutofillMetrics::DialogDismissalState dismissal_state; |
3221 if (!IsManuallyEditingAnySection()) | 3201 if (!IsManuallyEditingAnySection()) |
3222 dismissal_state = AutofillMetrics::DIALOG_ACCEPTED_EXISTING_DATA; | 3202 dismissal_state = AutofillMetrics::DIALOG_ACCEPTED_EXISTING_DATA; |
3223 else if (IsPayingWithWallet()) | 3203 else if (IsPayingWithWallet()) |
3224 dismissal_state = AutofillMetrics::DIALOG_ACCEPTED_SAVE_TO_WALLET; | 3204 dismissal_state = AutofillMetrics::DIALOG_ACCEPTED_SAVE_TO_WALLET; |
3225 else if (ShouldSaveDetailsLocally()) | 3205 else if (ShouldSaveDetailsLocally()) |
3226 dismissal_state = AutofillMetrics::DIALOG_ACCEPTED_SAVE_TO_AUTOFILL; | 3206 dismissal_state = AutofillMetrics::DIALOG_ACCEPTED_SAVE_TO_AUTOFILL; |
3227 else | 3207 else |
3228 dismissal_state = AutofillMetrics::DIALOG_ACCEPTED_NO_SAVE; | 3208 dismissal_state = AutofillMetrics::DIALOG_ACCEPTED_NO_SAVE; |
3229 | 3209 |
3230 GetMetricLogger().LogDialogDismissalState(GetDialogType(), dismissal_state); | 3210 GetMetricLogger().LogDialogDismissalState(dismissal_state); |
3231 } | 3211 } |
3232 | 3212 |
3233 void AutofillDialogControllerImpl::LogOnCancelMetrics() { | 3213 void AutofillDialogControllerImpl::LogOnCancelMetrics() { |
3234 GetMetricLogger().LogDialogUiEvent( | 3214 GetMetricLogger().LogDialogUiEvent(AutofillMetrics::DIALOG_UI_CANCELED); |
3235 GetDialogType(), AutofillMetrics::DIALOG_UI_CANCELED); | |
3236 | 3215 |
3237 AutofillMetrics::DialogDismissalState dismissal_state; | 3216 AutofillMetrics::DialogDismissalState dismissal_state; |
3238 if (!signin_registrar_.IsEmpty()) | 3217 if (!signin_registrar_.IsEmpty()) |
3239 dismissal_state = AutofillMetrics::DIALOG_CANCELED_DURING_SIGNIN; | 3218 dismissal_state = AutofillMetrics::DIALOG_CANCELED_DURING_SIGNIN; |
3240 else if (!IsManuallyEditingAnySection()) | 3219 else if (!IsManuallyEditingAnySection()) |
3241 dismissal_state = AutofillMetrics::DIALOG_CANCELED_NO_EDITS; | 3220 dismissal_state = AutofillMetrics::DIALOG_CANCELED_NO_EDITS; |
3242 else if (AllSectionsAreValid()) | 3221 else if (AllSectionsAreValid()) |
3243 dismissal_state = AutofillMetrics::DIALOG_CANCELED_NO_INVALID_FIELDS; | 3222 dismissal_state = AutofillMetrics::DIALOG_CANCELED_NO_INVALID_FIELDS; |
3244 else | 3223 else |
3245 dismissal_state = AutofillMetrics::DIALOG_CANCELED_WITH_INVALID_FIELDS; | 3224 dismissal_state = AutofillMetrics::DIALOG_CANCELED_WITH_INVALID_FIELDS; |
3246 | 3225 |
3247 GetMetricLogger().LogDialogDismissalState(GetDialogType(), dismissal_state); | 3226 GetMetricLogger().LogDialogDismissalState(dismissal_state); |
3248 | 3227 |
3249 GetMetricLogger().LogDialogUiDuration( | 3228 GetMetricLogger().LogDialogUiDuration( |
3250 base::Time::Now() - dialog_shown_timestamp_, | 3229 base::Time::Now() - dialog_shown_timestamp_, |
3251 GetDialogType(), | |
3252 AutofillMetrics::DIALOG_CANCELED); | 3230 AutofillMetrics::DIALOG_CANCELED); |
3253 } | 3231 } |
3254 | 3232 |
3255 void AutofillDialogControllerImpl::LogSuggestionItemSelectedMetric( | 3233 void AutofillDialogControllerImpl::LogSuggestionItemSelectedMetric( |
3256 const SuggestionsMenuModel& model) { | 3234 const SuggestionsMenuModel& model) { |
3257 DialogSection section = SectionForSuggestionsMenuModel(model); | 3235 DialogSection section = SectionForSuggestionsMenuModel(model); |
3258 | 3236 |
3259 AutofillMetrics::DialogUiEvent dialog_ui_event; | 3237 AutofillMetrics::DialogUiEvent dialog_ui_event; |
3260 if (model.GetItemKeyForCheckedItem() == kAddNewItemKey) { | 3238 if (model.GetItemKeyForCheckedItem() == kAddNewItemKey) { |
3261 // Selected to add a new item. | 3239 // Selected to add a new item. |
3262 dialog_ui_event = common::DialogSectionToUiItemAddedEvent(section); | 3240 dialog_ui_event = common::DialogSectionToUiItemAddedEvent(section); |
3263 } else if (IsASuggestionItemKey(model.GetItemKeyForCheckedItem())) { | 3241 } else if (IsASuggestionItemKey(model.GetItemKeyForCheckedItem())) { |
3264 // Selected an existing item. | 3242 // Selected an existing item. |
3265 dialog_ui_event = common::DialogSectionToUiSelectionChangedEvent(section); | 3243 dialog_ui_event = common::DialogSectionToUiSelectionChangedEvent(section); |
3266 } else { | 3244 } else { |
3267 // TODO(estade): add logging for "Manage items" or "Use billing for | 3245 // TODO(estade): add logging for "Manage items" or "Use billing for |
3268 // shipping"? | 3246 // shipping"? |
3269 return; | 3247 return; |
3270 } | 3248 } |
3271 | 3249 |
3272 GetMetricLogger().LogDialogUiEvent(GetDialogType(), dialog_ui_event); | 3250 GetMetricLogger().LogDialogUiEvent(dialog_ui_event); |
3273 } | 3251 } |
3274 | 3252 |
3275 void AutofillDialogControllerImpl::LogDialogLatencyToShow() { | 3253 void AutofillDialogControllerImpl::LogDialogLatencyToShow() { |
3276 if (was_ui_latency_logged_) | 3254 if (was_ui_latency_logged_) |
3277 return; | 3255 return; |
3278 | 3256 |
3279 GetMetricLogger().LogDialogLatencyToShow( | 3257 GetMetricLogger().LogDialogLatencyToShow( |
3280 GetDialogType(), | |
3281 base::Time::Now() - dialog_shown_timestamp_); | 3258 base::Time::Now() - dialog_shown_timestamp_); |
3282 was_ui_latency_logged_ = true; | 3259 was_ui_latency_logged_ = true; |
3283 } | 3260 } |
3284 | 3261 |
3285 AutofillMetrics::DialogInitialUserStateMetric | 3262 AutofillMetrics::DialogInitialUserStateMetric |
3286 AutofillDialogControllerImpl::GetInitialUserState() const { | 3263 AutofillDialogControllerImpl::GetInitialUserState() const { |
3287 // Consider a user to be an Autofill user if the user has any credit cards | 3264 // Consider a user to be an Autofill user if the user has any credit cards |
3288 // or addresses saved. Check that the item count is greater than 2 because | 3265 // or addresses saved. Check that the item count is greater than 2 because |
3289 // an "empty" menu still has the "add new" menu item and "manage" menu item. | 3266 // an "empty" menu still has the "add new" menu item and "manage" menu item. |
3290 const bool has_autofill_profiles = | 3267 const bool has_autofill_profiles = |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3357 } | 3334 } |
3358 #if !defined(OS_ANDROID) | 3335 #if !defined(OS_ANDROID) |
3359 GeneratedCreditCardBubbleController::Show( | 3336 GeneratedCreditCardBubbleController::Show( |
3360 web_contents(), | 3337 web_contents(), |
3361 full_wallet_->TypeAndLastFourDigits(), | 3338 full_wallet_->TypeAndLastFourDigits(), |
3362 backing_last_four); | 3339 backing_last_four); |
3363 #endif | 3340 #endif |
3364 } | 3341 } |
3365 | 3342 |
3366 } // namespace autofill | 3343 } // namespace autofill |
OLD | NEW |