OLD | NEW |
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 // In unit tests, |render_view| can be NULL. |
30 explicit PasswordAutofillAgent(content::RenderView* render_view); | 31 explicit PasswordAutofillAgent(content::RenderView* render_view); |
31 virtual ~PasswordAutofillAgent(); | 32 virtual ~PasswordAutofillAgent(); |
32 | 33 |
33 // WebViewClient editor related calls forwarded by the RenderView. | 34 // WebViewClient editor related calls forwarded by the RenderView. |
34 // If they return true, it indicates the event was consumed and should not | 35 // If they return true, it indicates the event was consumed and should not |
35 // be used for any other autofill activity. | 36 // be used for any other autofill activity. |
36 bool TextFieldDidEndEditing(const blink::WebInputElement& element); | 37 bool TextFieldDidEndEditing(const blink::WebInputElement& element); |
37 bool TextDidChangeInTextField(const blink::WebInputElement& element); | 38 bool TextDidChangeInTextField(const blink::WebInputElement& element); |
38 bool TextFieldHandlingKeyDown(const blink::WebInputElement& element, | 39 bool TextFieldHandlingKeyDown(const blink::WebInputElement& element, |
39 const blink::WebKeyboardEvent& event); | 40 const blink::WebKeyboardEvent& event); |
(...skipping 17 matching lines...) Expand all Loading... |
57 | 58 |
58 // Called when the user first interacts with the page after a load. This is a | 59 // Called when the user first interacts with the page after a load. This is a |
59 // signal to make autofilled values of password input elements accessible to | 60 // signal to make autofilled values of password input elements accessible to |
60 // JavaScript. | 61 // JavaScript. |
61 void FirstUserGestureObserved(); | 62 void FirstUserGestureObserved(); |
62 | 63 |
63 protected: | 64 protected: |
64 virtual bool OriginCanAccessPasswordManager( | 65 virtual bool OriginCanAccessPasswordManager( |
65 const blink::WebSecurityOrigin& origin); | 66 const blink::WebSecurityOrigin& origin); |
66 | 67 |
| 68 // Only for tests. |
| 69 bool logging_state_active() { return logging_state_active_; } |
| 70 |
67 private: | 71 private: |
68 friend class PasswordAutofillAgentTest; | 72 friend class PasswordAutofillAgentTest; |
69 | 73 |
70 enum OtherPossibleUsernamesUsage { | 74 enum OtherPossibleUsernamesUsage { |
71 NOTHING_TO_AUTOFILL, | 75 NOTHING_TO_AUTOFILL, |
72 OTHER_POSSIBLE_USERNAMES_ABSENT, | 76 OTHER_POSSIBLE_USERNAMES_ABSENT, |
73 OTHER_POSSIBLE_USERNAMES_PRESENT, | 77 OTHER_POSSIBLE_USERNAMES_PRESENT, |
74 OTHER_POSSIBLE_USERNAME_SHOWN, | 78 OTHER_POSSIBLE_USERNAME_SHOWN, |
75 OTHER_POSSIBLE_USERNAME_SELECTED, | 79 OTHER_POSSIBLE_USERNAME_SELECTED, |
76 OTHER_POSSIBLE_USERNAMES_MAX | 80 OTHER_POSSIBLE_USERNAMES_MAX |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 bool logging_state_active_; | 204 bool logging_state_active_; |
201 | 205 |
202 base::WeakPtrFactory<PasswordAutofillAgent> weak_ptr_factory_; | 206 base::WeakPtrFactory<PasswordAutofillAgent> weak_ptr_factory_; |
203 | 207 |
204 DISALLOW_COPY_AND_ASSIGN(PasswordAutofillAgent); | 208 DISALLOW_COPY_AND_ASSIGN(PasswordAutofillAgent); |
205 }; | 209 }; |
206 | 210 |
207 } // namespace autofill | 211 } // namespace autofill |
208 | 212 |
209 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_AUTOFILL_AGENT_H_ | 213 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_AUTOFILL_AGENT_H_ |
OLD | NEW |