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: components/autofill/content/renderer/password_autofill_agent.h

Issue 83023017: Basic autofill into password value on user gesture only. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nits from gcasto Created 7 years 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 | Annotate | Revision Log
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 #ifndef COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_AUTOFILL_AGENT_H_ 5 #ifndef COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_AUTOFILL_AGENT_H_
6 #define COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_AUTOFILL_AGENT_H_ 6 #define COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_AUTOFILL_AGENT_H_
7 7
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/memory/linked_ptr.h" 11 #include "base/memory/linked_ptr.h"
12 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
13 #include "components/autofill/core/common/password_form_fill_data.h" 14 #include "components/autofill/core/common/password_form_fill_data.h"
14 #include "content/public/renderer/render_view_observer.h" 15 #include "content/public/renderer/render_view_observer.h"
15 #include "third_party/WebKit/public/web/WebInputElement.h" 16 #include "third_party/WebKit/public/web/WebInputElement.h"
17 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h"
16 18
17 namespace blink { 19 namespace blink {
18 class WebInputElement; 20 class WebInputElement;
19 class WebKeyboardEvent; 21 class WebKeyboardEvent;
20 class WebSecurityOrigin; 22 class WebSecurityOrigin;
21 class WebView; 23 class WebView;
22 } 24 }
23 25
24 namespace autofill { 26 namespace autofill {
25 27
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 struct PasswordInfo { 74 struct PasswordInfo {
73 blink::WebInputElement password_field; 75 blink::WebInputElement password_field;
74 PasswordFormFillData fill_data; 76 PasswordFormFillData fill_data;
75 bool backspace_pressed_last; 77 bool backspace_pressed_last;
76 PasswordInfo() : backspace_pressed_last(false) {} 78 PasswordInfo() : backspace_pressed_last(false) {}
77 }; 79 };
78 typedef std::map<blink::WebElement, PasswordInfo> LoginToPasswordInfoMap; 80 typedef std::map<blink::WebElement, PasswordInfo> LoginToPasswordInfoMap;
79 typedef std::map<blink::WebFrame*, 81 typedef std::map<blink::WebFrame*,
80 linked_ptr<PasswordForm> > FrameToPasswordFormMap; 82 linked_ptr<PasswordForm> > FrameToPasswordFormMap;
81 83
84 class AutofillWebUserGestureHandler : public blink::WebUserGestureHandler {
85 public:
86 AutofillWebUserGestureHandler(PasswordAutofillAgent* agent);
87 virtual ~AutofillWebUserGestureHandler();
88
89 void addElement(const blink::WebInputElement& element) {
90 elements_.push_back(element);
91 }
92
93 void clearElements() {
94 elements_.clear();
95 }
96
97 virtual void onGesture();
98
99 private:
100 PasswordAutofillAgent* agent_;
101 std::vector<blink::WebInputElement> elements_;
102 };
103
82 // RenderViewObserver: 104 // RenderViewObserver:
83 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 105 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
84 virtual void DidStartProvisionalLoad(blink::WebFrame* frame) OVERRIDE; 106 virtual void DidStartProvisionalLoad(blink::WebFrame* frame) OVERRIDE;
85 virtual void DidStartLoading() OVERRIDE; 107 virtual void DidStartLoading() OVERRIDE;
86 virtual void DidFinishDocumentLoad(blink::WebFrame* frame) OVERRIDE; 108 virtual void DidFinishDocumentLoad(blink::WebFrame* frame) OVERRIDE;
87 virtual void DidFinishLoad(blink::WebFrame* frame) OVERRIDE; 109 virtual void DidFinishLoad(blink::WebFrame* frame) OVERRIDE;
88 virtual void FrameDetached(blink::WebFrame* frame) OVERRIDE; 110 virtual void FrameDetached(blink::WebFrame* frame) OVERRIDE;
89 virtual void FrameWillClose(blink::WebFrame* frame) OVERRIDE; 111 virtual void FrameWillClose(blink::WebFrame* frame) OVERRIDE;
90 virtual void WillSendSubmitEvent(blink::WebFrame* frame, 112 virtual void WillSendSubmitEvent(blink::WebFrame* frame,
91 const blink::WebFormElement& form) OVERRIDE; 113 const blink::WebFormElement& form) OVERRIDE;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 // Finds login information for a |node| that was previously filled. 159 // Finds login information for a |node| that was previously filled.
138 bool FindLoginInfo(const blink::WebNode& node, 160 bool FindLoginInfo(const blink::WebNode& node,
139 blink::WebInputElement* found_input, 161 blink::WebInputElement* found_input,
140 PasswordInfo* found_password); 162 PasswordInfo* found_password);
141 163
142 // If |provisionally_saved_forms_| contains a form for |current_frame| or its 164 // If |provisionally_saved_forms_| contains a form for |current_frame| or its
143 // children, return such frame. 165 // children, return such frame.
144 blink::WebFrame* CurrentOrChildFrameWithSavedForms( 166 blink::WebFrame* CurrentOrChildFrameWithSavedForms(
145 const blink::WebFrame* current_frame); 167 const blink::WebFrame* current_frame);
146 168
169 void set_user_gesture_occurred(bool occurred) {
170 user_gesture_occurred_ = occurred;
171 }
172
147 // The logins we have filled so far with their associated info. 173 // The logins we have filled so far with their associated info.
148 LoginToPasswordInfoMap login_to_password_info_; 174 LoginToPasswordInfoMap login_to_password_info_;
149 175
150 // Used for UMA stats. 176 // Used for UMA stats.
151 OtherPossibleUsernamesUsage usernames_usage_; 177 OtherPossibleUsernamesUsage usernames_usage_;
152 178
153 // Pointer to the WebView. Used to access page scale factor. 179 // Pointer to the WebView. Used to access page scale factor.
154 blink::WebView* web_view_; 180 blink::WebView* web_view_;
155 181
156 // Set if the user might be submitting a password form on the current page, 182 // Set if the user might be submitting a password form on the current page,
157 // but the submit may still fail (i.e. doesn't pass JavaScript validation). 183 // but the submit may still fail (i.e. doesn't pass JavaScript validation).
158 FrameToPasswordFormMap provisionally_saved_forms_; 184 FrameToPasswordFormMap provisionally_saved_forms_;
159 185
186 scoped_ptr<AutofillWebUserGestureHandler> gesture_handler_;
187
188 bool user_gesture_occurred_;
189
160 base::WeakPtrFactory<PasswordAutofillAgent> weak_ptr_factory_; 190 base::WeakPtrFactory<PasswordAutofillAgent> weak_ptr_factory_;
161 191
162 DISALLOW_COPY_AND_ASSIGN(PasswordAutofillAgent); 192 DISALLOW_COPY_AND_ASSIGN(PasswordAutofillAgent);
163 }; 193 };
164 194
165 } // namespace autofill 195 } // namespace autofill
166 196
167 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_AUTOFILL_AGENT_H_ 197 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_AUTOFILL_AGENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698