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_GENERATION_MANAGER_H_ | 5 #ifndef COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_GENERATION_MANAGER_H_ |
6 #define COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_GENERATION_MANAGER_H_ | 6 #define COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_GENERATION_MANAGER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "content/public/renderer/render_view_observer.h" | 12 #include "content/public/renderer/render_view_observer.h" |
13 #include "third_party/WebKit/public/web/WebInputElement.h" | 13 #include "third_party/WebKit/public/web/WebInputElement.h" |
14 #include "third_party/WebKit/public/web/WebPasswordGeneratorClient.h" | 14 #include "third_party/WebKit/public/web/WebPasswordGeneratorClient.h" |
15 #include "url/gurl.h" | 15 #include "url/gurl.h" |
16 | 16 |
17 namespace WebKit { | 17 namespace WebKit { |
18 class WebCString; | 18 class WebCString; |
19 class WebDocument; | 19 class WebDocument; |
20 } | 20 } |
21 | 21 |
22 namespace content { | |
23 struct PasswordForm; | |
24 } | |
25 | |
26 namespace autofill { | 22 namespace autofill { |
27 | 23 |
24 struct PasswordForm; | |
25 | |
28 // This class is responsible for controlling communication for password | 26 // This class is responsible for controlling communication for password |
29 // generation between the browser (which shows the popup and generates | 27 // generation between the browser (which shows the popup and generates |
30 // passwords) and WebKit (shows the generation icon in the password field). | 28 // passwords) and WebKit (shows the generation icon in the password field). |
31 class PasswordGenerationManager : public content::RenderViewObserver, | 29 class PasswordGenerationManager : public content::RenderViewObserver, |
32 public WebKit::WebPasswordGeneratorClient { | 30 public WebKit::WebPasswordGeneratorClient { |
33 public: | 31 public: |
34 explicit PasswordGenerationManager(content::RenderView* render_view); | 32 explicit PasswordGenerationManager(content::RenderView* render_view); |
35 virtual ~PasswordGenerationManager(); | 33 virtual ~PasswordGenerationManager(); |
36 | 34 |
37 protected: | 35 protected: |
38 // Returns true if this document is one that we should consider analyzing. | 36 // Returns true if this document is one that we should consider analyzing. |
39 // Virtual so that it can be overriden during testing. | 37 // Virtual so that it can be overriden during testing. |
40 virtual bool ShouldAnalyzeDocument(const WebKit::WebDocument& document) const; | 38 virtual bool ShouldAnalyzeDocument(const WebKit::WebDocument& document) const; |
41 | 39 |
42 // RenderViewObserver: | 40 // RenderViewObserver: |
43 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 41 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
44 | 42 |
45 private: | 43 private: |
46 // RenderViewObserver: | 44 // RenderViewObserver: |
47 virtual void DidFinishDocumentLoad(WebKit::WebFrame* frame) OVERRIDE; | 45 virtual void DidFinishDocumentLoad(WebKit::WebFrame* frame) OVERRIDE; |
48 virtual void DidFinishLoad(WebKit::WebFrame* frame) OVERRIDE; | 46 virtual void DidFinishLoad(WebKit::WebFrame* frame) OVERRIDE; |
49 | 47 |
50 // WebPasswordGeneratorClient: | 48 // WebPasswordGeneratorClient: |
51 virtual void openPasswordGenerator(WebKit::WebInputElement& element) OVERRIDE; | 49 virtual void openPasswordGenerator(WebKit::WebInputElement& element) OVERRIDE; |
52 | 50 |
53 // Message handlers. | 51 // Message handlers. |
54 void OnFormNotBlacklisted(const content::PasswordForm& form); | 52 void OnFormNotBlacklisted(const autofill::PasswordForm& form); |
Ilya Sherman
2013/09/05 22:53:35
nit: No need for namespace.
blundell
2013/09/06 08:36:25
Done.
| |
55 void OnPasswordAccepted(const base::string16& password); | 53 void OnPasswordAccepted(const base::string16& password); |
56 void OnPasswordGenerationEnabled(bool enabled); | 54 void OnPasswordGenerationEnabled(bool enabled); |
57 | 55 |
58 // Helper function to decide whether we should show password generation icon. | 56 // Helper function to decide whether we should show password generation icon. |
59 void MaybeShowIcon(); | 57 void MaybeShowIcon(); |
60 | 58 |
61 content::RenderView* render_view_; | 59 content::RenderView* render_view_; |
62 | 60 |
63 // True if password generation is enabled for the profile associated | 61 // True if password generation is enabled for the profile associated |
64 // with this renderer. | 62 // with this renderer. |
65 bool enabled_; | 63 bool enabled_; |
66 | 64 |
67 // Stores the origin of the account creation form we detected. | 65 // Stores the origin of the account creation form we detected. |
68 GURL account_creation_form_origin_; | 66 GURL account_creation_form_origin_; |
69 | 67 |
70 // Stores the origins of the password forms confirmed not to be blacklisted | 68 // Stores the origins of the password forms confirmed not to be blacklisted |
71 // by the browser. A form can be blacklisted if a user chooses "never save | 69 // by the browser. A form can be blacklisted if a user chooses "never save |
72 // passwords for this site". | 70 // passwords for this site". |
73 std::vector<GURL> not_blacklisted_password_form_origins_; | 71 std::vector<GURL> not_blacklisted_password_form_origins_; |
74 | 72 |
75 std::vector<WebKit::WebInputElement> passwords_; | 73 std::vector<WebKit::WebInputElement> passwords_; |
76 | 74 |
77 DISALLOW_COPY_AND_ASSIGN(PasswordGenerationManager); | 75 DISALLOW_COPY_AND_ASSIGN(PasswordGenerationManager); |
78 }; | 76 }; |
79 | 77 |
80 } // namespace autofill | 78 } // namespace autofill |
81 | 79 |
82 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_GENERATION_MANAGER_H_ | 80 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_GENERATION_MANAGER_H_ |
OLD | NEW |