Index: chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc |
diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc |
index c3f3d7682eb072d861b1e10c5efe6e5518db382a..71ae97616ea2de05b359af825f31621a033a1448 100644 |
--- a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc |
+++ b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc |
@@ -7,6 +7,7 @@ |
#include <algorithm> |
#include <string> |
+#include "base/base64.h" |
#include "base/bind.h" |
#include "base/logging.h" |
#include "base/prefs/pref_service.h" |
@@ -1418,13 +1419,13 @@ DialogType AutofillDialogControllerImpl::GetDialogType() const { |
} |
std::string AutofillDialogControllerImpl::GetRiskData() const { |
- // TODO(dbeam): Implement this. |
- return "risky business"; |
+ // TODO(dbeam): remove the server restriction that this must not be empty. |
+ return risk_data_; |
} |
void AutofillDialogControllerImpl::OnDidAcceptLegalDocuments() { |
- // TODO(dbeam): Don't send risk params until legal documents are accepted: |
- // http://crbug.com/173505 |
+ legal_documents_are_current_ = true; |
+ LoadRiskFingerprintData(); |
} |
void AutofillDialogControllerImpl::OnDidAuthenticateInstrument(bool success) { |
@@ -1503,6 +1504,11 @@ void AutofillDialogControllerImpl::OnDidGetWalletItems( |
// TODO(dbeam): verify items support kCartCurrency? http://crbug.com/232952 |
wallet_items_ = wallet_items.Pass(); |
+ |
+ legal_documents_are_current_ = wallet_items_->legal_documents().empty(); |
+ if (legal_documents_are_current_) |
+ LoadRiskFingerprintData(); |
+ |
OnWalletOrSigninUpdate(); |
} |
@@ -1673,6 +1679,7 @@ AutofillDialogControllerImpl::AutofillDialogControllerImpl( |
weak_ptr_factory_(this), |
is_first_run_(!profile_->GetPrefs()->HasPrefPath( |
::prefs::kAutofillDialogPayWithoutWallet)), |
+ legal_documents_are_current_(false), |
is_submitting_(false), |
autocheckout_is_running_(false), |
had_autocheckout_error_(false), |
@@ -1702,6 +1709,43 @@ bool AutofillDialogControllerImpl::IsFirstRun() const { |
return is_first_run_; |
} |
+void AutofillDialogControllerImpl::LoadRiskFingerprintData() { |
+ if (!legal_documents_are_current_) |
+ return; |
+ |
+ uint64 obfuscated_gaia_id = 0; |
+ bool success = base::StringToUint64(wallet_items_->obfuscated_gaia_id(), |
+ &obfuscated_gaia_id); |
+ DCHECK(success); |
+ |
+ gfx::Rect window_bounds; |
+#if !defined(OS_ANDROID) |
+ window_bounds = GetBaseWindowForWebContents(web_contents())->GetBounds(); |
+#else |
+ // TODO(dbeam): figure out the correct browser window size to pass along for |
+ // android. |
+#endif |
+ |
+ PrefService* user_prefs = profile_->GetPrefs(); |
+ std::string charset = user_prefs->GetString(::prefs::kDefaultCharset); |
+ std::string accept_languages = |
+ user_prefs->GetString(::prefs::kAcceptLanguages); |
+ base::Time install_time = base::Time::FromTimeT( |
+ g_browser_process->local_state()->GetInt64(::prefs::kInstallDate)); |
+ |
+ risk::GetFingerprint( |
+ obfuscated_gaia_id, window_bounds, *web_contents(), |
+ chrome::VersionInfo().Version(), charset, accept_languages, install_time, |
+ dialog_type_, g_browser_process->GetApplicationLocale(), |
+ base::Bind(&AutofillDialogControllerImpl::OnDidLoadRiskFingerprintData, |
+ weak_ptr_factory_.GetWeakPtr())); |
+} |
+ |
+void AutofillDialogControllerImpl::SerializeFingerprint( |
+ risk::Fingerprint* fingerprint, std::string* data) { |
+ fingerprint->SerializeToString(data); |
+} |
+ |
void AutofillDialogControllerImpl::DisableWallet() { |
signin_helper_.reset(); |
account_chooser_model_.SetHadWalletError(); |
@@ -2023,38 +2067,15 @@ void AutofillDialogControllerImpl::HidePopup() { |
input_showing_popup_ = NULL; |
} |
-void AutofillDialogControllerImpl::LoadRiskFingerprintData() { |
- // TODO(dbeam): Add a CHECK or otherwise strong guarantee that the ToS have |
- // been accepted prior to calling into this method. Also, ensure that the UI |
Dan Beam
2013/05/07 04:02:50
why do we care if risk data is *loaded*? we care
Ilya Sherman
2013/05/07 09:11:41
Yes, what we really care about is whether it's sen
Ilya Sherman
2013/05/07 09:25:03
Actually, belay that. It looks like determining t
|
- // contains a clear indication to the user as to what data will be collected. |
- // Until then, this code should not be called. http://crbug.com/173505 |
- |
- int64 gaia_id = 0; |
- bool success = |
- base::StringToInt64(wallet_items_->obfuscated_gaia_id(), &gaia_id); |
- DCHECK(success); |
- |
- gfx::Rect window_bounds = |
- GetBaseWindowForWebContents(web_contents())->GetBounds(); |
- |
- PrefService* user_prefs = profile_->GetPrefs(); |
- std::string charset = user_prefs->GetString(::prefs::kDefaultCharset); |
- std::string accept_languages = |
- user_prefs->GetString(::prefs::kAcceptLanguages); |
- base::Time install_time = base::Time::FromTimeT( |
- g_browser_process->local_state()->GetInt64(::prefs::kInstallDate)); |
- |
- risk::GetFingerprint( |
- gaia_id, window_bounds, *web_contents(), chrome::VersionInfo().Version(), |
- charset, accept_languages, install_time, dialog_type_, |
- g_browser_process->GetApplicationLocale(), |
- base::Bind(&AutofillDialogControllerImpl::OnDidLoadRiskFingerprintData, |
- weak_ptr_factory_.GetWeakPtr())); |
-} |
- |
void AutofillDialogControllerImpl::OnDidLoadRiskFingerprintData( |
scoped_ptr<risk::Fingerprint> fingerprint) { |
- NOTIMPLEMENTED(); |
+ if (!legal_documents_are_current_) |
+ return; |
+ |
+ std::string proto_data; |
+ SerializeFingerprint(fingerprint.get(), &proto_data); |
+ bool success = base::Base64Encode(proto_data, &risk_data_); |
+ DCHECK(success); |
} |
bool AutofillDialogControllerImpl::IsManuallyEditingSection( |