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

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

Issue 63273002: Rename WebKit namespace to blink (part 4) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 16
17 namespace WebKit { 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 explicit PasswordAutofillAgent(content::RenderView* render_view); 30 explicit PasswordAutofillAgent(content::RenderView* render_view);
31 virtual ~PasswordAutofillAgent(); 31 virtual ~PasswordAutofillAgent();
32 32
33 // WebViewClient editor related calls forwarded by the RenderView. 33 // WebViewClient editor related calls forwarded by the RenderView.
34 // If they return true, it indicates the event was consumed and should not 34 // If they return true, it indicates the event was consumed and should not
35 // be used for any other autofill activity. 35 // be used for any other autofill activity.
36 bool TextFieldDidEndEditing(const WebKit::WebInputElement& element); 36 bool TextFieldDidEndEditing(const blink::WebInputElement& element);
37 bool TextDidChangeInTextField(const WebKit::WebInputElement& element); 37 bool TextDidChangeInTextField(const blink::WebInputElement& element);
38 bool TextFieldHandlingKeyDown(const WebKit::WebInputElement& element, 38 bool TextFieldHandlingKeyDown(const blink::WebInputElement& element,
39 const WebKit::WebKeyboardEvent& event); 39 const blink::WebKeyboardEvent& event);
40 40
41 // Fills the password associated with user name |value|. Returns true if the 41 // Fills the password associated with user name |value|. Returns true if the
42 // username and password fields were filled, false otherwise. 42 // username and password fields were filled, false otherwise.
43 bool DidAcceptAutofillSuggestion(const WebKit::WebNode& node, 43 bool DidAcceptAutofillSuggestion(const blink::WebNode& node,
44 const WebKit::WebString& value); 44 const blink::WebString& value);
45 // A no-op. Password forms are not previewed, so they do not need to be 45 // A no-op. Password forms are not previewed, so they do not need to be
46 // cleared when the selection changes. However, this method returns 46 // cleared when the selection changes. However, this method returns
47 // true when |node| is fillable by password Autofill. 47 // true when |node| is fillable by password Autofill.
48 bool DidClearAutofillSelection(const WebKit::WebNode& node); 48 bool DidClearAutofillSelection(const blink::WebNode& node);
49 // Shows an Autofill popup with username suggestions for |element|. 49 // Shows an Autofill popup with username suggestions for |element|.
50 // Returns true if any suggestions were shown, false otherwise. 50 // Returns true if any suggestions were shown, false otherwise.
51 bool ShowSuggestions(const WebKit::WebInputElement& element); 51 bool ShowSuggestions(const blink::WebInputElement& element);
52 52
53 // Called when new form controls are inserted. 53 // Called when new form controls are inserted.
54 void OnDynamicFormsSeen(WebKit::WebFrame* frame); 54 void OnDynamicFormsSeen(blink::WebFrame* frame);
55 55
56 protected: 56 protected:
57 virtual bool OriginCanAccessPasswordManager( 57 virtual bool OriginCanAccessPasswordManager(
58 const WebKit::WebSecurityOrigin& origin); 58 const blink::WebSecurityOrigin& origin);
59 59
60 private: 60 private:
61 friend class PasswordAutofillAgentTest; 61 friend class PasswordAutofillAgentTest;
62 62
63 enum OtherPossibleUsernamesUsage { 63 enum OtherPossibleUsernamesUsage {
64 NOTHING_TO_AUTOFILL, 64 NOTHING_TO_AUTOFILL,
65 OTHER_POSSIBLE_USERNAMES_ABSENT, 65 OTHER_POSSIBLE_USERNAMES_ABSENT,
66 OTHER_POSSIBLE_USERNAMES_PRESENT, 66 OTHER_POSSIBLE_USERNAMES_PRESENT,
67 OTHER_POSSIBLE_USERNAME_SHOWN, 67 OTHER_POSSIBLE_USERNAME_SHOWN,
68 OTHER_POSSIBLE_USERNAME_SELECTED, 68 OTHER_POSSIBLE_USERNAME_SELECTED,
69 OTHER_POSSIBLE_USERNAMES_MAX 69 OTHER_POSSIBLE_USERNAMES_MAX
70 }; 70 };
71 71
72 struct PasswordInfo { 72 struct PasswordInfo {
73 WebKit::WebInputElement password_field; 73 blink::WebInputElement password_field;
74 PasswordFormFillData fill_data; 74 PasswordFormFillData fill_data;
75 bool backspace_pressed_last; 75 bool backspace_pressed_last;
76 PasswordInfo() : backspace_pressed_last(false) {} 76 PasswordInfo() : backspace_pressed_last(false) {}
77 }; 77 };
78 typedef std::map<WebKit::WebElement, PasswordInfo> LoginToPasswordInfoMap; 78 typedef std::map<blink::WebElement, PasswordInfo> LoginToPasswordInfoMap;
79 typedef std::map<WebKit::WebFrame*, 79 typedef std::map<blink::WebFrame*,
80 linked_ptr<PasswordForm> > FrameToPasswordFormMap; 80 linked_ptr<PasswordForm> > FrameToPasswordFormMap;
81 81
82 // RenderViewObserver: 82 // RenderViewObserver:
83 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 83 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
84 virtual void DidStartProvisionalLoad(WebKit::WebFrame* frame) OVERRIDE; 84 virtual void DidStartProvisionalLoad(blink::WebFrame* frame) OVERRIDE;
85 virtual void DidStartLoading() OVERRIDE; 85 virtual void DidStartLoading() OVERRIDE;
86 virtual void DidFinishDocumentLoad(WebKit::WebFrame* frame) OVERRIDE; 86 virtual void DidFinishDocumentLoad(blink::WebFrame* frame) OVERRIDE;
87 virtual void DidFinishLoad(WebKit::WebFrame* frame) OVERRIDE; 87 virtual void DidFinishLoad(blink::WebFrame* frame) OVERRIDE;
88 virtual void FrameDetached(WebKit::WebFrame* frame) OVERRIDE; 88 virtual void FrameDetached(blink::WebFrame* frame) OVERRIDE;
89 virtual void FrameWillClose(WebKit::WebFrame* frame) OVERRIDE; 89 virtual void FrameWillClose(blink::WebFrame* frame) OVERRIDE;
90 virtual void WillSendSubmitEvent(WebKit::WebFrame* frame, 90 virtual void WillSendSubmitEvent(blink::WebFrame* frame,
91 const WebKit::WebFormElement& form) OVERRIDE; 91 const blink::WebFormElement& form) OVERRIDE;
92 virtual void WillSubmitForm(WebKit::WebFrame* frame, 92 virtual void WillSubmitForm(blink::WebFrame* frame,
93 const WebKit::WebFormElement& form) OVERRIDE; 93 const blink::WebFormElement& form) OVERRIDE;
94 94
95 // RenderView IPC handlers: 95 // RenderView IPC handlers:
96 void OnFillPasswordForm(const PasswordFormFillData& form_data); 96 void OnFillPasswordForm(const PasswordFormFillData& form_data);
97 97
98 // Scans the given frame for password forms and sends them up to the browser. 98 // Scans the given frame for password forms and sends them up to the browser.
99 // If |only_visible| is true, only forms visible in the layout are sent. 99 // If |only_visible| is true, only forms visible in the layout are sent.
100 void SendPasswordForms(WebKit::WebFrame* frame, bool only_visible); 100 void SendPasswordForms(blink::WebFrame* frame, bool only_visible);
101 101
102 void GetSuggestions(const PasswordFormFillData& fill_data, 102 void GetSuggestions(const PasswordFormFillData& fill_data,
103 const base::string16& input, 103 const base::string16& input,
104 std::vector<base::string16>* suggestions, 104 std::vector<base::string16>* suggestions,
105 std::vector<base::string16>* realms); 105 std::vector<base::string16>* realms);
106 106
107 bool ShowSuggestionPopup(const PasswordFormFillData& fill_data, 107 bool ShowSuggestionPopup(const PasswordFormFillData& fill_data,
108 const WebKit::WebInputElement& user_input); 108 const blink::WebInputElement& user_input);
109 109
110 // Attempts to fill |username_element| and |password_element| with the 110 // Attempts to fill |username_element| and |password_element| with the
111 // |fill_data|. Will use the data corresponding to the preferred username, 111 // |fill_data|. Will use the data corresponding to the preferred username,
112 // unless the |username_element| already has a value set. In that case, 112 // unless the |username_element| already has a value set. In that case,
113 // attempts to fill the password matching the already filled username, if 113 // attempts to fill the password matching the already filled username, if
114 // such a password exists. 114 // such a password exists.
115 void FillFormOnPasswordRecieved(const PasswordFormFillData& fill_data, 115 void FillFormOnPasswordRecieved(const PasswordFormFillData& fill_data,
116 WebKit::WebInputElement username_element, 116 blink::WebInputElement username_element,
117 WebKit::WebInputElement password_element); 117 blink::WebInputElement password_element);
118 118
119 bool FillUserNameAndPassword( 119 bool FillUserNameAndPassword(
120 WebKit::WebInputElement* username_element, 120 blink::WebInputElement* username_element,
121 WebKit::WebInputElement* password_element, 121 blink::WebInputElement* password_element,
122 const PasswordFormFillData& fill_data, 122 const PasswordFormFillData& fill_data,
123 bool exact_username_match, 123 bool exact_username_match,
124 bool set_selection); 124 bool set_selection);
125 125
126 // Fills |login_input| and |password| with the most relevant suggestion from 126 // Fills |login_input| and |password| with the most relevant suggestion from
127 // |fill_data| and shows a popup with other suggestions. 127 // |fill_data| and shows a popup with other suggestions.
128 void PerformInlineAutocomplete( 128 void PerformInlineAutocomplete(
129 const WebKit::WebInputElement& username, 129 const blink::WebInputElement& username,
130 const WebKit::WebInputElement& password, 130 const blink::WebInputElement& password,
131 const PasswordFormFillData& fill_data); 131 const PasswordFormFillData& fill_data);
132 132
133 // Invoked when the passed frame is closing. Gives us a chance to clear any 133 // Invoked when the passed frame is closing. Gives us a chance to clear any
134 // reference we may have to elements in that frame. 134 // reference we may have to elements in that frame.
135 void FrameClosing(const WebKit::WebFrame* frame); 135 void FrameClosing(const blink::WebFrame* frame);
136 136
137 // Finds login information for a |node| that was previously filled. 137 // Finds login information for a |node| that was previously filled.
138 bool FindLoginInfo(const WebKit::WebNode& node, 138 bool FindLoginInfo(const blink::WebNode& node,
139 WebKit::WebInputElement* found_input, 139 blink::WebInputElement* found_input,
140 PasswordInfo* found_password); 140 PasswordInfo* found_password);
141 141
142 // The logins we have filled so far with their associated info. 142 // The logins we have filled so far with their associated info.
143 LoginToPasswordInfoMap login_to_password_info_; 143 LoginToPasswordInfoMap login_to_password_info_;
144 144
145 // Used for UMA stats. 145 // Used for UMA stats.
146 OtherPossibleUsernamesUsage usernames_usage_; 146 OtherPossibleUsernamesUsage usernames_usage_;
147 147
148 // Pointer to the WebView. Used to access page scale factor. 148 // Pointer to the WebView. Used to access page scale factor.
149 WebKit::WebView* web_view_; 149 blink::WebView* web_view_;
150 150
151 // Set if the user might be submitting a password form on the current page, 151 // Set if the user might be submitting a password form on the current page,
152 // but the submit may still fail (i.e. doesn't pass JavaScript validation). 152 // but the submit may still fail (i.e. doesn't pass JavaScript validation).
153 FrameToPasswordFormMap provisionally_saved_forms_; 153 FrameToPasswordFormMap provisionally_saved_forms_;
154 154
155 base::WeakPtrFactory<PasswordAutofillAgent> weak_ptr_factory_; 155 base::WeakPtrFactory<PasswordAutofillAgent> weak_ptr_factory_;
156 156
157 DISALLOW_COPY_AND_ASSIGN(PasswordAutofillAgent); 157 DISALLOW_COPY_AND_ASSIGN(PasswordAutofillAgent);
158 }; 158 };
159 159
160 } // namespace autofill 160 } // namespace autofill
161 161
162 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_AUTOFILL_AGENT_H_ 162 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_AUTOFILL_AGENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698