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

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

Issue 896583003: Add risk data to getrealpan request. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixes for android Created 5 years, 10 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
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 <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
11 #include "base/base64.h"
12 #include "base/bind.h" 11 #include "base/bind.h"
13 #include "base/bind_helpers.h" 12 #include "base/bind_helpers.h"
14 #include "base/i18n/case_conversion.h" 13 #include "base/i18n/case_conversion.h"
15 #include "base/i18n/rtl.h" 14 #include "base/i18n/rtl.h"
16 #include "base/logging.h" 15 #include "base/logging.h"
17 #include "base/prefs/pref_registry_simple.h" 16 #include "base/prefs/pref_registry_simple.h"
18 #include "base/prefs/pref_service.h" 17 #include "base/prefs/pref_service.h"
19 #include "base/prefs/scoped_user_pref_update.h" 18 #include "base/prefs/scoped_user_pref_update.h"
20 #include "base/rand_util.h" 19 #include "base/rand_util.h"
21 #include "base/strings/string_number_conversions.h" 20 #include "base/strings/string_number_conversions.h"
22 #include "base/strings/string_split.h" 21 #include "base/strings/string_split.h"
23 #include "base/strings/utf_string_conversions.h" 22 #include "base/strings/utf_string_conversions.h"
24 #include "base/time/time.h" 23 #include "base/time/time.h"
25 #include "chrome/browser/apps/app_window_registry_util.h"
26 #include "chrome/browser/autofill/personal_data_manager_factory.h" 24 #include "chrome/browser/autofill/personal_data_manager_factory.h"
25 #include "chrome/browser/autofill/risk_util.h"
27 #include "chrome/browser/autofill/validation_rules_storage_factory.h" 26 #include "chrome/browser/autofill/validation_rules_storage_factory.h"
28 #include "chrome/browser/browser_process.h" 27 #include "chrome/browser/browser_process.h"
29 #include "chrome/browser/profiles/profile.h" 28 #include "chrome/browser/profiles/profile.h"
30 #include "chrome/browser/ui/autofill/autofill_dialog_common.h" 29 #include "chrome/browser/ui/autofill/autofill_dialog_common.h"
31 #include "chrome/browser/ui/autofill/autofill_dialog_i18n_input.h" 30 #include "chrome/browser/ui/autofill/autofill_dialog_i18n_input.h"
32 #include "chrome/browser/ui/autofill/autofill_dialog_view.h" 31 #include "chrome/browser/ui/autofill/autofill_dialog_view.h"
33 #include "chrome/browser/ui/autofill/data_model_wrapper.h" 32 #include "chrome/browser/ui/autofill/data_model_wrapper.h"
34 #include "chrome/browser/ui/autofill/generated_credit_card_bubble_controller.h" 33 #include "chrome/browser/ui/autofill/generated_credit_card_bubble_controller.h"
35 #include "chrome/browser/ui/autofill/new_credit_card_bubble_controller.h" 34 #include "chrome/browser/ui/autofill/new_credit_card_bubble_controller.h"
36 #include "chrome/browser/ui/browser.h" 35 #include "chrome/browser/ui/browser.h"
37 #include "chrome/browser/ui/browser_finder.h" 36 #include "chrome/browser/ui/browser_finder.h"
38 #include "chrome/browser/ui/browser_navigator.h" 37 #include "chrome/browser/ui/browser_navigator.h"
39 #include "chrome/browser/ui/browser_window.h" 38 #include "chrome/browser/ui/browser_window.h"
40 #include "chrome/common/chrome_content_client.h"
41 #include "chrome/common/chrome_version_info.h"
42 #include "chrome/common/pref_names.h" 39 #include "chrome/common/pref_names.h"
43 #include "chrome/common/render_messages.h" 40 #include "chrome/common/render_messages.h"
44 #include "chrome/common/url_constants.h" 41 #include "chrome/common/url_constants.h"
45 #include "chrome/grit/chromium_strings.h" 42 #include "chrome/grit/chromium_strings.h"
46 #include "chrome/grit/generated_resources.h" 43 #include "chrome/grit/generated_resources.h"
47 #include "components/autofill/content/browser/risk/fingerprint.h"
48 #include "components/autofill/content/browser/risk/proto/fingerprint.pb.h"
49 #include "components/autofill/content/browser/wallet/form_field_error.h" 44 #include "components/autofill/content/browser/wallet/form_field_error.h"
50 #include "components/autofill/content/browser/wallet/full_wallet.h" 45 #include "components/autofill/content/browser/wallet/full_wallet.h"
51 #include "components/autofill/content/browser/wallet/gaia_account.h" 46 #include "components/autofill/content/browser/wallet/gaia_account.h"
52 #include "components/autofill/content/browser/wallet/instrument.h" 47 #include "components/autofill/content/browser/wallet/instrument.h"
53 #include "components/autofill/content/browser/wallet/wallet_address.h" 48 #include "components/autofill/content/browser/wallet/wallet_address.h"
54 #include "components/autofill/content/browser/wallet/wallet_items.h" 49 #include "components/autofill/content/browser/wallet/wallet_items.h"
55 #include "components/autofill/content/browser/wallet/wallet_service_url.h" 50 #include "components/autofill/content/browser/wallet/wallet_service_url.h"
56 #include "components/autofill/content/browser/wallet/wallet_signin_helper.h" 51 #include "components/autofill/content/browser/wallet/wallet_signin_helper.h"
57 #include "components/autofill/core/browser/address_i18n.h" 52 #include "components/autofill/core/browser/address_i18n.h"
58 #include "components/autofill/core/browser/autofill_country.h" 53 #include "components/autofill/core/browser/autofill_country.h"
59 #include "components/autofill/core/browser/autofill_data_model.h" 54 #include "components/autofill/core/browser/autofill_data_model.h"
60 #include "components/autofill/core/browser/autofill_manager.h" 55 #include "components/autofill/core/browser/autofill_manager.h"
61 #include "components/autofill/core/browser/autofill_type.h" 56 #include "components/autofill/core/browser/autofill_type.h"
62 #include "components/autofill/core/browser/personal_data_manager.h" 57 #include "components/autofill/core/browser/personal_data_manager.h"
63 #include "components/autofill/core/browser/phone_number_i18n.h" 58 #include "components/autofill/core/browser/phone_number_i18n.h"
64 #include "components/autofill/core/browser/validation.h" 59 #include "components/autofill/core/browser/validation.h"
65 #include "components/autofill/core/common/autofill_pref_names.h" 60 #include "components/autofill/core/common/autofill_pref_names.h"
66 #include "components/autofill/core/common/form_data.h" 61 #include "components/autofill/core/common/form_data.h"
67 #include "components/metrics/metrics_service.h"
68 #include "components/pref_registry/pref_registry_syncable.h" 62 #include "components/pref_registry/pref_registry_syncable.h"
69 #include "content/public/browser/browser_thread.h" 63 #include "content/public/browser/browser_thread.h"
70 #include "content/public/browser/geolocation_provider.h" 64 #include "content/public/browser/geolocation_provider.h"
71 #include "content/public/browser/navigation_controller.h" 65 #include "content/public/browser/navigation_controller.h"
72 #include "content/public/browser/navigation_details.h" 66 #include "content/public/browser/navigation_details.h"
73 #include "content/public/browser/navigation_entry.h" 67 #include "content/public/browser/navigation_entry.h"
74 #include "content/public/browser/notification_service.h" 68 #include "content/public/browser/notification_service.h"
75 #include "content/public/browser/notification_types.h" 69 #include "content/public/browser/notification_types.h"
76 #include "content/public/browser/render_view_host.h" 70 #include "content/public/browser/render_view_host.h"
77 #include "content/public/browser/web_contents.h" 71 #include "content/public/browser/web_contents.h"
78 #include "content/public/common/url_constants.h" 72 #include "content/public/common/url_constants.h"
79 #include "extensions/browser/app_window/app_window.h"
80 #include "extensions/browser/app_window/native_app_window.h"
81 #include "grit/components_scaled_resources.h" 73 #include "grit/components_scaled_resources.h"
82 #include "grit/components_strings.h" 74 #include "grit/components_strings.h"
83 #include "grit/platform_locale_settings.h" 75 #include "grit/platform_locale_settings.h"
84 #include "grit/theme_resources.h" 76 #include "grit/theme_resources.h"
85 #include "net/cert/cert_status_flags.h" 77 #include "net/cert/cert_status_flags.h"
86 #include "third_party/libaddressinput/chromium/chrome_metadata_source.h" 78 #include "third_party/libaddressinput/chromium/chrome_metadata_source.h"
87 #include "third_party/libaddressinput/chromium/chrome_storage_impl.h" 79 #include "third_party/libaddressinput/chromium/chrome_storage_impl.h"
88 #include "third_party/libaddressinput/messages.h" 80 #include "third_party/libaddressinput/messages.h"
89 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_da ta.h" 81 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_da ta.h"
90 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_fi eld.h" 82 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_fi eld.h"
91 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_pr oblem.h" 83 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_pr oblem.h"
92 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/localizati on.h" 84 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/localizati on.h"
93 #include "ui/base/base_window.h"
94 #include "ui/base/l10n/l10n_util.h" 85 #include "ui/base/l10n/l10n_util.h"
95 #include "ui/base/models/combobox_model.h" 86 #include "ui/base/models/combobox_model.h"
96 #include "ui/base/resource/resource_bundle.h" 87 #include "ui/base/resource/resource_bundle.h"
97 #include "ui/gfx/canvas.h" 88 #include "ui/gfx/canvas.h"
98 #include "ui/gfx/image/image_skia_operations.h" 89 #include "ui/gfx/image/image_skia_operations.h"
99 #include "ui/gfx/skia_util.h" 90 #include "ui/gfx/skia_util.h"
100 91
101 using ::i18n::addressinput::AddressData; 92 using ::i18n::addressinput::AddressData;
102 using ::i18n::addressinput::AddressField; 93 using ::i18n::addressinput::AddressField;
103 using ::i18n::addressinput::AddressProblem; 94 using ::i18n::addressinput::AddressProblem;
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 231
241 if (profile) { 232 if (profile) {
242 profile->SetInfo(AutofillType(AutofillType(type).GetStorableType()), 233 profile->SetInfo(AutofillType(AutofillType(type).GetStorableType()),
243 trimmed, 234 trimmed,
244 g_browser_process->GetApplicationLocale()); 235 g_browser_process->GetApplicationLocale());
245 } 236 }
246 } 237 }
247 } 238 }
248 } 239 }
249 240
250 // Returns the containing window for the given |web_contents|. The containing
251 // window might be a browser window for a Chrome tab, or it might be an app
252 // window for a platform app.
253 ui::BaseWindow* GetBaseWindowForWebContents(
254 content::WebContents* web_contents) {
255 Browser* browser = chrome::FindBrowserWithWebContents(web_contents);
256 if (browser)
257 return browser->window();
258
259 gfx::NativeWindow native_window = web_contents->GetTopLevelNativeWindow();
260 extensions::AppWindow* app_window =
261 AppWindowRegistryUtil::GetAppWindowForNativeWindowAnyProfile(
262 native_window);
263 return app_window->GetBaseWindow();
264 }
265 241
266 // Returns a string descriptor for a DialogSection, for use with prefs (do not 242 // Returns a string descriptor for a DialogSection, for use with prefs (do not
267 // change these values). 243 // change these values).
268 std::string SectionToPrefString(DialogSection section) { 244 std::string SectionToPrefString(DialogSection section) {
269 switch (section) { 245 switch (section) {
270 case SECTION_CC: 246 case SECTION_CC:
271 return "cc"; 247 return "cc";
272 248
273 case SECTION_BILLING: 249 case SECTION_BILLING:
274 return "billing"; 250 return "billing";
(...skipping 2592 matching lines...) Expand 10 before | Expand all | Expand 10 after
2867 } 2843 }
2868 2844
2869 void AutofillDialogControllerImpl::LoadRiskFingerprintData() { 2845 void AutofillDialogControllerImpl::LoadRiskFingerprintData() {
2870 risk_data_.clear(); 2846 risk_data_.clear();
2871 2847
2872 uint64 obfuscated_gaia_id = 0; 2848 uint64 obfuscated_gaia_id = 0;
2873 bool success = base::StringToUint64(wallet_items_->ObfuscatedGaiaId(), 2849 bool success = base::StringToUint64(wallet_items_->ObfuscatedGaiaId(),
2874 &obfuscated_gaia_id); 2850 &obfuscated_gaia_id);
2875 DCHECK(success); 2851 DCHECK(success);
2876 2852
2877 gfx::Rect window_bounds; 2853 LoadRiskData(
2878 window_bounds = GetBaseWindowForWebContents(web_contents())->GetBounds(); 2854 obfuscated_gaia_id, web_contents(),
2879
2880 PrefService* user_prefs = profile_->GetPrefs();
2881 std::string charset = user_prefs->GetString(::prefs::kDefaultCharset);
2882 std::string accept_languages =
2883 user_prefs->GetString(::prefs::kAcceptLanguages);
2884 base::Time install_time = base::Time::FromTimeT(
2885 g_browser_process->metrics_service()->GetInstallDate());
2886
2887 risk::GetFingerprint(
2888 obfuscated_gaia_id, window_bounds, web_contents(),
2889 chrome::VersionInfo().Version(), charset, accept_languages, install_time,
2890 g_browser_process->GetApplicationLocale(), GetUserAgent(),
2891 base::Bind(&AutofillDialogControllerImpl::OnDidLoadRiskFingerprintData, 2855 base::Bind(&AutofillDialogControllerImpl::OnDidLoadRiskFingerprintData,
2892 weak_ptr_factory_.GetWeakPtr())); 2856 weak_ptr_factory_.GetWeakPtr()));
2893 } 2857 }
2894 2858
2895 void AutofillDialogControllerImpl::OnDidLoadRiskFingerprintData( 2859 void AutofillDialogControllerImpl::OnDidLoadRiskFingerprintData(
2896 scoped_ptr<risk::Fingerprint> fingerprint) { 2860 const std::string& risk_data) {
2897 DCHECK(AreLegalDocumentsCurrent()); 2861 DCHECK(AreLegalDocumentsCurrent());
2898 2862 risk_data_ = risk_data;
2899 std::string proto_data;
2900 fingerprint->SerializeToString(&proto_data);
2901 base::Base64Encode(proto_data, &risk_data_);
2902
2903 SubmitWithWallet(); 2863 SubmitWithWallet();
2904 } 2864 }
2905 2865
2906 void AutofillDialogControllerImpl::OpenTabWithUrl(const GURL& url) { 2866 void AutofillDialogControllerImpl::OpenTabWithUrl(const GURL& url) {
2907 chrome::NavigateParams params( 2867 chrome::NavigateParams params(
2908 chrome::FindBrowserWithWebContents(web_contents()), 2868 chrome::FindBrowserWithWebContents(web_contents()),
2909 url, 2869 url,
2910 ui::PAGE_TRANSITION_LINK); 2870 ui::PAGE_TRANSITION_LINK);
2911 params.disposition = NEW_FOREGROUND_TAB; 2871 params.disposition = NEW_FOREGROUND_TAB;
2912 chrome::Navigate(&params); 2872 chrome::Navigate(&params);
(...skipping 1235 matching lines...) Expand 10 before | Expand all | Expand 10 after
4148 view_->UpdateButtonStrip(); 4108 view_->UpdateButtonStrip();
4149 } 4109 }
4150 4110
4151 void AutofillDialogControllerImpl::FetchWalletCookie() { 4111 void AutofillDialogControllerImpl::FetchWalletCookie() {
4152 net::URLRequestContextGetter* request_context = profile_->GetRequestContext(); 4112 net::URLRequestContextGetter* request_context = profile_->GetRequestContext();
4153 signin_helper_.reset(new wallet::WalletSigninHelper(this, request_context)); 4113 signin_helper_.reset(new wallet::WalletSigninHelper(this, request_context));
4154 signin_helper_->StartWalletCookieValueFetch(); 4114 signin_helper_->StartWalletCookieValueFetch();
4155 } 4115 }
4156 4116
4157 } // namespace autofill 4117 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698