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

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

Powered by Google App Engine
This is Rietveld 408576698