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

Side by Side Diff: components/autofill/content/renderer/password_autofill_agent.cc

Issue 2640903006: Show FormNotSecure warnings on sensitive inputs in non-secure contexts (Closed)
Patch Set: Convert ui_interactive_test to use HTTPS to avoid breakage Created 3 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 "components/autofill/content/renderer/password_autofill_agent.h" 5 #include "components/autofill/content/renderer/password_autofill_agent.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 10 matching lines...) Expand all
21 #include "base/strings/utf_string_conversions.h" 21 #include "base/strings/utf_string_conversions.h"
22 #include "base/threading/thread_task_runner_handle.h" 22 #include "base/threading/thread_task_runner_handle.h"
23 #include "build/build_config.h" 23 #include "build/build_config.h"
24 #include "components/autofill/content/renderer/form_autofill_util.h" 24 #include "components/autofill/content/renderer/form_autofill_util.h"
25 #include "components/autofill/content/renderer/password_form_conversion_utils.h" 25 #include "components/autofill/content/renderer/password_form_conversion_utils.h"
26 #include "components/autofill/content/renderer/renderer_save_password_progress_l ogger.h" 26 #include "components/autofill/content/renderer/renderer_save_password_progress_l ogger.h"
27 #include "components/autofill/core/common/autofill_constants.h" 27 #include "components/autofill/core/common/autofill_constants.h"
28 #include "components/autofill/core/common/autofill_util.h" 28 #include "components/autofill/core/common/autofill_util.h"
29 #include "components/autofill/core/common/form_field_data.h" 29 #include "components/autofill/core/common/form_field_data.h"
30 #include "components/autofill/core/common/password_form_fill_data.h" 30 #include "components/autofill/core/common/password_form_fill_data.h"
31 #include "components/security_state/core/security_state.h"
32 #include "content/public/common/origin_util.h"
31 #include "content/public/renderer/document_state.h" 33 #include "content/public/renderer/document_state.h"
32 #include "content/public/renderer/navigation_state.h" 34 #include "content/public/renderer/navigation_state.h"
33 #include "content/public/renderer/render_frame.h" 35 #include "content/public/renderer/render_frame.h"
34 #include "content/public/renderer/render_view.h" 36 #include "content/public/renderer/render_view.h"
35 #include "services/service_manager/public/cpp/interface_provider.h" 37 #include "services/service_manager/public/cpp/interface_provider.h"
36 #include "services/service_manager/public/cpp/interface_registry.h" 38 #include "services/service_manager/public/cpp/interface_registry.h"
37 #include "third_party/WebKit/public/platform/WebInputEvent.h" 39 #include "third_party/WebKit/public/platform/WebInputEvent.h"
38 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" 40 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h"
39 #include "third_party/WebKit/public/platform/WebVector.h" 41 #include "third_party/WebKit/public/platform/WebVector.h"
40 #include "third_party/WebKit/public/web/WebAutofillClient.h" 42 #include "third_party/WebKit/public/web/WebAutofillClient.h"
(...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 return true; 837 return true;
836 } 838 }
837 839
838 bool PasswordAutofillAgent::ShowSuggestions( 840 bool PasswordAutofillAgent::ShowSuggestions(
839 const blink::WebInputElement& element, 841 const blink::WebInputElement& element,
840 bool show_all, 842 bool show_all,
841 bool generation_popup_showing) { 843 bool generation_popup_showing) {
842 blink::WebInputElement username_element; 844 blink::WebInputElement username_element;
843 blink::WebInputElement password_element; 845 blink::WebInputElement password_element;
844 PasswordInfo* password_info; 846 PasswordInfo* password_info;
847
845 if (!FindPasswordInfoForElement(element, &username_element, &password_element, 848 if (!FindPasswordInfoForElement(element, &username_element, &password_element,
846 &password_info)) 849 &password_info)) {
850 // If we don't have a password stored, but the form is non-secure, warn
851 // the user about the non-secure form.
852 if ((element.isPasswordField() ||
853 HasAutocompleteAttributeValue(element, "username")) &&
854 security_state::IsHttpWarningInFormEnabled() &&
855 !content::IsOriginSecure(url::Origin(render_frame()
856 ->GetRenderView()
857 ->GetMainRenderFrame()
858 ->GetWebFrame()
859 ->getSecurityOrigin())
860 .GetURL())) {
861 autofill_agent_->ShowNotSecureWarning(element);
862 return true;
863 }
847 return false; 864 return false;
865 }
848 866
849 // If autocomplete='off' is set on the form elements, no suggestion dialog 867 // If autocomplete='off' is set on the form elements, no suggestion dialog
850 // should be shown. However, return |true| to indicate that this is a known 868 // should be shown. However, return |true| to indicate that this is a known
851 // password form and that the request to show suggestions has been handled (as 869 // password form and that the request to show suggestions has been handled (as
852 // a no-op). 870 // a no-op).
853 if (!element.isTextField() || !IsElementAutocompletable(element) || 871 if (!element.isTextField() || !IsElementAutocompletable(element) ||
854 !IsElementAutocompletable(password_element)) 872 !IsElementAutocompletable(password_element))
855 return true; 873 return true;
856 874
857 if (element.nameForAutofill().isEmpty() && 875 if (element.nameForAutofill().isEmpty() &&
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
1502 PasswordAutofillAgent::GetPasswordManagerDriver() { 1520 PasswordAutofillAgent::GetPasswordManagerDriver() {
1503 if (!password_manager_driver_) { 1521 if (!password_manager_driver_) {
1504 render_frame()->GetRemoteInterfaces()->GetInterface( 1522 render_frame()->GetRemoteInterfaces()->GetInterface(
1505 mojo::MakeRequest(&password_manager_driver_)); 1523 mojo::MakeRequest(&password_manager_driver_));
1506 } 1524 }
1507 1525
1508 return password_manager_driver_; 1526 return password_manager_driver_;
1509 } 1527 }
1510 1528
1511 } // namespace autofill 1529 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698