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

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

Issue 597983003: Refactor PasswordAutofillAgent: methods to functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: changes as per review comments. Created 6 years, 2 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 #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 16
17 namespace blink { 17 namespace blink {
18 class WebInputElement; 18 class WebInputElement;
19 class WebKeyboardEvent; 19 class WebKeyboardEvent;
20 class WebSecurityOrigin; 20 class WebSecurityOrigin;
21 class WebView; 21 class WebView;
22 } 22 }
23 23
24 namespace autofill { 24 namespace autofill {
25 25
26 // This class is responsible for filling password forms. 26 // This class is responsible for filling password forms.
27 // There is one PasswordAutofillAgent per RenderView. 27 // There is one PasswordAutofillAgent per RenderView.
28 class PasswordAutofillAgent : public content::RenderViewObserver { 28 class PasswordAutofillAgent : public content::RenderViewObserver {
29 public: 29 public:
30 enum OtherPossibleUsernamesUsage {
vabr (Chromium) 2014/09/26 10:06:48 Please keep this private, not public. Instead, us
31 NOTHING_TO_AUTOFILL,
32 OTHER_POSSIBLE_USERNAMES_ABSENT,
33 OTHER_POSSIBLE_USERNAMES_PRESENT,
34 OTHER_POSSIBLE_USERNAME_SHOWN,
35 OTHER_POSSIBLE_USERNAME_SELECTED,
36 OTHER_POSSIBLE_USERNAMES_MAX
37 };
30 explicit PasswordAutofillAgent(content::RenderView* render_view); 38 explicit PasswordAutofillAgent(content::RenderView* render_view);
31 virtual ~PasswordAutofillAgent(); 39 virtual ~PasswordAutofillAgent();
32 40
33 // WebViewClient editor related calls forwarded by the RenderView. 41 // WebViewClient editor related calls forwarded by the RenderView.
34 // If they return true, it indicates the event was consumed and should not 42 // If they return true, it indicates the event was consumed and should not
35 // be used for any other autofill activity. 43 // be used for any other autofill activity.
36 bool TextFieldDidEndEditing(const blink::WebInputElement& element); 44 bool TextFieldDidEndEditing(const blink::WebInputElement& element);
37 bool TextDidChangeInTextField(const blink::WebInputElement& element); 45 bool TextDidChangeInTextField(const blink::WebInputElement& element);
38 bool TextFieldHandlingKeyDown(const blink::WebInputElement& element, 46 bool TextFieldHandlingKeyDown(const blink::WebInputElement& element,
39 const blink::WebKeyboardEvent& event); 47 const blink::WebKeyboardEvent& event);
(...skipping 26 matching lines...) Expand all
66 // Called when the user first interacts with the page after a load. This is a 74 // Called when the user first interacts with the page after a load. This is a
67 // signal to make autofilled values of password input elements accessible to 75 // signal to make autofilled values of password input elements accessible to
68 // JavaScript. 76 // JavaScript.
69 void FirstUserGestureObserved(); 77 void FirstUserGestureObserved();
70 78
71 protected: 79 protected:
72 virtual bool OriginCanAccessPasswordManager( 80 virtual bool OriginCanAccessPasswordManager(
73 const blink::WebSecurityOrigin& origin); 81 const blink::WebSecurityOrigin& origin);
74 82
75 private: 83 private:
76 enum OtherPossibleUsernamesUsage {
77 NOTHING_TO_AUTOFILL,
78 OTHER_POSSIBLE_USERNAMES_ABSENT,
79 OTHER_POSSIBLE_USERNAMES_PRESENT,
80 OTHER_POSSIBLE_USERNAME_SHOWN,
81 OTHER_POSSIBLE_USERNAME_SELECTED,
82 OTHER_POSSIBLE_USERNAMES_MAX
83 };
84
85 // Ways to restrict which passwords are saved in ProvisionallySavePassword. 84 // Ways to restrict which passwords are saved in ProvisionallySavePassword.
86 enum ProvisionallySaveRestriction { 85 enum ProvisionallySaveRestriction {
87 RESTRICTION_NONE, 86 RESTRICTION_NONE,
88 RESTRICTION_NON_EMPTY_PASSWORD 87 RESTRICTION_NON_EMPTY_PASSWORD
89 }; 88 };
90 89
91 struct PasswordInfo { 90 struct PasswordInfo {
92 blink::WebInputElement password_field; 91 blink::WebInputElement password_field;
93 PasswordFormFillData fill_data; 92 PasswordFormFillData fill_data;
94 bool backspace_pressed_last; 93 bool backspace_pressed_last;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 const blink::WebFormElement& form) OVERRIDE; 145 const blink::WebFormElement& form) OVERRIDE;
147 146
148 // RenderView IPC handlers: 147 // RenderView IPC handlers:
149 void OnFillPasswordForm(const PasswordFormFillData& form_data); 148 void OnFillPasswordForm(const PasswordFormFillData& form_data);
150 void OnSetLoggingState(bool active); 149 void OnSetLoggingState(bool active);
151 150
152 // Scans the given frame for password forms and sends them up to the browser. 151 // Scans the given frame for password forms and sends them up to the browser.
153 // If |only_visible| is true, only forms visible in the layout are sent. 152 // If |only_visible| is true, only forms visible in the layout are sent.
154 void SendPasswordForms(blink::WebFrame* frame, bool only_visible); 153 void SendPasswordForms(blink::WebFrame* frame, bool only_visible);
155 154
156 void GetSuggestions(const PasswordFormFillData& fill_data,
157 const base::string16& input,
158 std::vector<base::string16>* suggestions,
159 std::vector<base::string16>* realms,
160 bool show_all);
161
162 bool ShowSuggestionPopup(const PasswordFormFillData& fill_data, 155 bool ShowSuggestionPopup(const PasswordFormFillData& fill_data,
163 const blink::WebInputElement& user_input, 156 const blink::WebInputElement& user_input,
164 bool show_all); 157 bool show_all);
165 158
166 // Attempts to fill |username_element| and |password_element| with the
167 // |fill_data|. Will use the data corresponding to the preferred username,
168 // unless the |username_element| already has a value set. In that case,
169 // attempts to fill the password matching the already filled username, if
170 // such a password exists.
171 void FillFormOnPasswordRecieved(const PasswordFormFillData& fill_data,
172 blink::WebInputElement username_element,
173 blink::WebInputElement password_element);
174
175 bool FillUserNameAndPassword(blink::WebInputElement* username_element,
176 blink::WebInputElement* password_element,
177 const PasswordFormFillData& fill_data,
178 bool exact_username_match,
179 bool set_selection);
180 159
181 // Fills |login_input| and |password| with the most relevant suggestion from 160 // Fills |login_input| and |password| with the most relevant suggestion from
182 // |fill_data| and shows a popup with other suggestions. 161 // |fill_data| and shows a popup with other suggestions.
183 void PerformInlineAutocomplete( 162 void PerformInlineAutocomplete(
184 const blink::WebInputElement& username, 163 const blink::WebInputElement& username,
185 const blink::WebInputElement& password, 164 const blink::WebInputElement& password,
186 const PasswordFormFillData& fill_data); 165 const PasswordFormFillData& fill_data);
187 166
188 // Invoked when the passed frame is closing. Gives us a chance to clear any 167 // Invoked when the passed frame is closing. Gives us a chance to clear any
189 // reference we may have to elements in that frame. 168 // reference we may have to elements in that frame.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 bool did_stop_loading_; 222 bool did_stop_loading_;
244 223
245 base::WeakPtrFactory<PasswordAutofillAgent> weak_ptr_factory_; 224 base::WeakPtrFactory<PasswordAutofillAgent> weak_ptr_factory_;
246 225
247 DISALLOW_COPY_AND_ASSIGN(PasswordAutofillAgent); 226 DISALLOW_COPY_AND_ASSIGN(PasswordAutofillAgent);
248 }; 227 };
249 228
250 } // namespace autofill 229 } // namespace autofill
251 230
252 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_AUTOFILL_AGENT_H_ 231 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_AUTOFILL_AGENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698