Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | |
| 9 #include "base/logging.h" | 10 #include "base/logging.h" |
| 10 #include "base/string_split.h" | 11 #include "base/string_split.h" |
| 11 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 12 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
| 13 #include "chrome/browser/autofill/autofill_country.h" | 14 #include "chrome/browser/autofill/autofill_country.h" |
| 14 #include "chrome/browser/autofill/autofill_manager.h" | 15 #include "chrome/browser/autofill/autofill_manager.h" |
| 15 #include "chrome/browser/autofill/autofill_type.h" | 16 #include "chrome/browser/autofill/autofill_type.h" |
| 16 #include "chrome/browser/autofill/personal_data_manager.h" | 17 #include "chrome/browser/autofill/personal_data_manager.h" |
| 17 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 18 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
| 19 #include "chrome/browser/autofill/risk/fingerprint.h" | |
| 20 #include "chrome/browser/autofill/risk/proto/fingerprint.pb.h" | |
| 18 #include "chrome/browser/autofill/validation.h" | 21 #include "chrome/browser/autofill/validation.h" |
| 19 #include "chrome/browser/autofill/wallet/full_wallet.h" | 22 #include "chrome/browser/autofill/wallet/full_wallet.h" |
| 20 #include "chrome/browser/autofill/wallet/wallet_items.h" | 23 #include "chrome/browser/autofill/wallet/wallet_items.h" |
| 21 #include "chrome/browser/autofill/wallet/wallet_service_url.h" | 24 #include "chrome/browser/autofill/wallet/wallet_service_url.h" |
| 25 #include "chrome/browser/prefs/pref_service.h" | |
| 22 #include "chrome/browser/profiles/profile.h" | 26 #include "chrome/browser/profiles/profile.h" |
| 23 #include "chrome/browser/ui/autofill/autofill_dialog_view.h" | 27 #include "chrome/browser/ui/autofill/autofill_dialog_view.h" |
| 28 #include "chrome/browser/ui/browser.h" | |
| 29 #include "chrome/browser/ui/browser_finder.h" | |
| 30 #include "chrome/browser/ui/browser_window.h" | |
| 24 #include "chrome/common/form_data.h" | 31 #include "chrome/common/form_data.h" |
| 25 #include "content/public/browser/navigation_controller.h" | 32 #include "content/public/browser/navigation_controller.h" |
| 26 #include "content/public/browser/navigation_details.h" | 33 #include "content/public/browser/navigation_details.h" |
| 27 #include "content/public/browser/navigation_entry.h" | 34 #include "content/public/browser/navigation_entry.h" |
| 28 #include "content/public/browser/notification_service.h" | 35 #include "content/public/browser/notification_service.h" |
| 29 #include "content/public/browser/notification_types.h" | 36 #include "content/public/browser/notification_types.h" |
| 37 #include "content/public/browser/render_widget_host.h" | |
| 38 #include "content/public/browser/render_widget_host_view.h" | |
| 30 #include "content/public/browser/web_contents.h" | 39 #include "content/public/browser/web_contents.h" |
| 40 #include "content/public/browser/web_contents_view.h" | |
| 31 #include "content/public/common/url_constants.h" | 41 #include "content/public/common/url_constants.h" |
| 32 #include "grit/chromium_strings.h" | 42 #include "grit/chromium_strings.h" |
| 33 #include "grit/generated_resources.h" | 43 #include "grit/generated_resources.h" |
| 34 #include "net/base/cert_status_flags.h" | 44 #include "net/base/cert_status_flags.h" |
| 45 #include "third_party/WebKit/Source/Platform/chromium/public/WebScreenInfo.h" | |
| 35 #include "ui/base/l10n/l10n_util.h" | 46 #include "ui/base/l10n/l10n_util.h" |
| 36 #include "ui/base/resource/resource_bundle.h" | 47 #include "ui/base/resource/resource_bundle.h" |
| 37 | 48 |
| 38 namespace autofill { | 49 namespace autofill { |
| 39 | 50 |
| 40 namespace { | 51 namespace { |
| 41 | 52 |
| 42 // Returns true if |input| should be shown when |field| has been requested. | 53 // Returns true if |input| should be shown when |field| has been requested. |
| 43 bool InputTypeMatchesFieldType(const DetailInput& input, | 54 bool InputTypeMatchesFieldType(const DetailInput& input, |
| 44 const AutofillField& field) { | 55 const AutofillField& field) { |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 form_structure_(form), | 143 form_structure_(form), |
| 133 source_url_(source_url), | 144 source_url_(source_url), |
| 134 ssl_status_(ssl_status), | 145 ssl_status_(ssl_status), |
| 135 callback_(callback), | 146 callback_(callback), |
| 136 wallet_client_(profile_->GetRequestContext()), | 147 wallet_client_(profile_->GetRequestContext()), |
| 137 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_email_(this)), | 148 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_email_(this)), |
| 138 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_cc_(this)), | 149 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_cc_(this)), |
| 139 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_billing_(this)), | 150 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_billing_(this)), |
| 140 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_shipping_(this)), | 151 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_shipping_(this)), |
| 141 popup_controller_(NULL), | 152 popup_controller_(NULL), |
| 142 section_showing_popup_(SECTION_BILLING) { | 153 section_showing_popup_(SECTION_BILLING), |
| 154 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { | |
| 143 // TODO(estade): |this| should observe PersonalDataManager. | 155 // TODO(estade): |this| should observe PersonalDataManager. |
| 144 // TODO(estade): remove duplicates from |form|? | 156 // TODO(estade): remove duplicates from |form|? |
| 145 | 157 |
| 146 content::NavigationEntry* entry = contents->GetController().GetActiveEntry(); | 158 content::NavigationEntry* entry = contents->GetController().GetActiveEntry(); |
| 147 const GURL& active_url = entry ? entry->GetURL() : web_contents()->GetURL(); | 159 const GURL& active_url = entry ? entry->GetURL() : web_contents()->GetURL(); |
| 148 invoked_from_same_origin_ = active_url.GetOrigin() == source_url_.GetOrigin(); | 160 invoked_from_same_origin_ = active_url.GetOrigin() == source_url_.GetOrigin(); |
| 149 } | 161 } |
| 150 | 162 |
| 151 AutofillDialogControllerImpl::~AutofillDialogControllerImpl() { | 163 AutofillDialogControllerImpl::~AutofillDialogControllerImpl() { |
| 152 if (popup_controller_) | 164 if (popup_controller_) |
| (...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 940 return const_cast<DetailInputs*>(&RequestedFieldsForSection(section)); | 952 return const_cast<DetailInputs*>(&RequestedFieldsForSection(section)); |
| 941 } | 953 } |
| 942 | 954 |
| 943 void AutofillDialogControllerImpl::HidePopup() { | 955 void AutofillDialogControllerImpl::HidePopup() { |
| 944 if (popup_controller_) { | 956 if (popup_controller_) { |
| 945 popup_controller_->Hide(); | 957 popup_controller_->Hide(); |
| 946 ControllerDestroyed(); | 958 ControllerDestroyed(); |
| 947 } | 959 } |
| 948 } | 960 } |
| 949 | 961 |
| 962 void AutofillDialogControllerImpl::LoadRiskFingerprintData() { | |
| 963 // TODO(dbeam): Add a DCHECK that the ToS have been accepted prior to | |
| 964 // calling into this method. Also, ensure that the UI contains a clear | |
| 965 // indication to the user as to what data will be collected. Until then, this | |
| 966 // code should not be called. | |
| 967 | |
| 968 // TODO(dbeam): Set the right GAIA id. | |
|
Dan Beam
2013/02/07 01:36:46
this can be obtained via |base::StringToInt64(wall
Dan Beam
2013/02/07 01:37:33
er, I mean... wallet_items_->obfuscated_gaia_id()
Ilya Sherman
2013/02/07 01:58:29
Done.
Ilya Sherman
2013/02/07 01:58:29
Done.
| |
| 969 int64 gaia_id = 0; | |
| 970 | |
| 971 gfx::Rect window_bounds = | |
| 972 chrome::FindBrowserWithWebContents(web_contents())->window()->GetBounds(); | |
|
Evan Stade
2013/02/07 01:34:53
it seems like all this bounds calculation stuff co
Ilya Sherman
2013/02/07 01:58:29
That would require the risk code to have dependenc
Evan Stade
2013/02/07 02:09:16
probably worth noting that FindBrowserWithWebConte
Evan Stade
2013/02/07 02:09:16
you could solve that by adding a function to WebCo
Ilya Sherman
2013/02/14 09:00:40
Aren't we guaranteed to be inside a browser window
Ilya Sherman
2013/02/14 09:00:40
Per John's comment, I did not do this. However, I
Evan Stade
2013/02/19 21:18:18
I can't remember if platform apps have a Browser o
Ilya Sherman
2013/02/20 00:05:19
You're right, they don't. Added code to handle pl
| |
| 973 | |
| 974 gfx::Rect content_bounds; | |
| 975 web_contents()->GetView()->GetContainerBounds(&content_bounds); | |
| 976 | |
| 977 WebKit::WebScreenInfo screen_info; | |
| 978 content::RenderWidgetHostView* host_view = | |
| 979 web_contents()->GetRenderWidgetHostView(); | |
| 980 if (host_view) | |
| 981 host_view->GetRenderWidgetHost()->GetWebScreenInfo(&screen_info); | |
| 982 | |
| 983 risk::GetFingerprint( | |
| 984 gaia_id, window_bounds, content_bounds, screen_info, | |
| 985 *profile_->GetPrefs(), | |
| 986 base::Bind(&AutofillDialogControllerImpl::OnDidLoadRiskFingerprintData, | |
| 987 weak_ptr_factory_.GetWeakPtr())); | |
| 988 } | |
| 989 | |
| 990 void AutofillDialogControllerImpl::OnDidLoadRiskFingerprintData( | |
| 991 scoped_ptr<risk::Fingerprint> fingerprint) { | |
| 992 NOTIMPLEMENTED(); | |
| 993 } | |
| 994 | |
| 995 | |
|
Evan Stade
2013/02/07 01:34:53
^H
Ilya Sherman
2013/02/07 01:58:29
Done.
| |
| 950 } // namespace autofill | 996 } // namespace autofill |
| OLD | NEW |