OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_PASSWORD_MANAGER_CONTENT_BROWSER_CONTENT_PASSWORD_MANAGER_DRI
VER_H_ | 5 #ifndef COMPONENTS_PASSWORD_MANAGER_CONTENT_BROWSER_CONTENT_PASSWORD_MANAGER_DRI
VER_H_ |
6 #define COMPONENTS_PASSWORD_MANAGER_CONTENT_BROWSER_CONTENT_PASSWORD_MANAGER_DRI
VER_H_ | 6 #define COMPONENTS_PASSWORD_MANAGER_CONTENT_BROWSER_CONTENT_PASSWORD_MANAGER_DRI
VER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "components/autofill/content/public/interfaces/autofill_agent.mojom.h" | 13 #include "components/autofill/content/public/interfaces/autofill_agent.mojom.h" |
14 #include "components/autofill/content/public/interfaces/autofill_driver.mojom.h" | |
15 #include "components/autofill/core/common/password_form_field_prediction_map.h" | 14 #include "components/autofill/core/common/password_form_field_prediction_map.h" |
16 #include "components/autofill/core/common/password_form_generation_data.h" | 15 #include "components/autofill/core/common/password_form_generation_data.h" |
17 #include "components/password_manager/core/browser/password_autofill_manager.h" | 16 #include "components/password_manager/core/browser/password_autofill_manager.h" |
18 #include "components/password_manager/core/browser/password_generation_manager.h
" | 17 #include "components/password_manager/core/browser/password_generation_manager.h
" |
19 #include "components/password_manager/core/browser/password_manager.h" | 18 #include "components/password_manager/core/browser/password_manager.h" |
20 #include "components/password_manager/core/browser/password_manager_driver.h" | 19 #include "components/password_manager/core/browser/password_manager_driver.h" |
21 #include "mojo/public/cpp/bindings/binding.h" | |
22 | 20 |
23 namespace autofill { | 21 namespace autofill { |
24 class AutofillManager; | 22 class AutofillManager; |
25 struct PasswordForm; | 23 struct PasswordForm; |
26 } | 24 } |
27 | 25 |
28 namespace content { | 26 namespace content { |
29 struct FrameNavigateParams; | 27 struct FrameNavigateParams; |
30 struct LoadCommittedDetails; | 28 struct LoadCommittedDetails; |
31 class RenderFrameHost; | 29 class RenderFrameHost; |
32 class WebContents; | 30 class WebContents; |
33 } | 31 } |
34 | 32 |
35 namespace IPC { | 33 namespace IPC { |
36 class Message; | 34 class Message; |
37 } | 35 } |
38 | 36 |
39 namespace password_manager { | 37 namespace password_manager { |
40 enum class BadMessageReason; | 38 enum class BadMessageReason; |
41 | 39 |
42 // There is one ContentPasswordManagerDriver per RenderFrameHost. | 40 // There is one ContentPasswordManagerDriver per RenderFrameHost. |
43 // The lifetime is managed by the ContentPasswordManagerDriverFactory. | 41 // The lifetime is managed by the ContentPasswordManagerDriverFactory. |
44 class ContentPasswordManagerDriver | 42 class ContentPasswordManagerDriver : public PasswordManagerDriver { |
45 : public PasswordManagerDriver, | |
46 public autofill::mojom::PasswordManagerDriver { | |
47 public: | 43 public: |
48 ContentPasswordManagerDriver(content::RenderFrameHost* render_frame_host, | 44 ContentPasswordManagerDriver(content::RenderFrameHost* render_frame_host, |
49 PasswordManagerClient* client, | 45 PasswordManagerClient* client, |
50 autofill::AutofillClient* autofill_client); | 46 autofill::AutofillClient* autofill_client); |
51 ~ContentPasswordManagerDriver() override; | 47 ~ContentPasswordManagerDriver() override; |
52 | 48 |
53 // Gets the driver for |render_frame_host|. | 49 // Gets the driver for |render_frame_host|. |
54 static ContentPasswordManagerDriver* GetForRenderFrameHost( | 50 static ContentPasswordManagerDriver* GetForRenderFrameHost( |
55 content::RenderFrameHost* render_frame_host); | 51 content::RenderFrameHost* render_frame_host); |
56 | 52 |
57 void BindRequest(autofill::mojom::PasswordManagerDriverRequest request); | |
58 | |
59 // PasswordManagerDriver implementation. | 53 // PasswordManagerDriver implementation. |
60 void FillPasswordForm( | 54 void FillPasswordForm( |
61 const autofill::PasswordFormFillData& form_data) override; | 55 const autofill::PasswordFormFillData& form_data) override; |
62 void AllowPasswordGenerationForForm( | 56 void AllowPasswordGenerationForForm( |
63 const autofill::PasswordForm& form) override; | 57 const autofill::PasswordForm& form) override; |
64 void FormsEligibleForGenerationFound( | 58 void FormsEligibleForGenerationFound( |
65 const std::vector<autofill::PasswordFormGenerationData>& forms) override; | 59 const std::vector<autofill::PasswordFormGenerationData>& forms) override; |
66 void AutofillDataReceived( | 60 void AutofillDataReceived( |
67 const std::map<autofill::FormData, | 61 const std::map<autofill::FormData, |
68 autofill::PasswordFormFieldPredictionMap>& predictions) | 62 autofill::PasswordFormFieldPredictionMap>& predictions) |
69 override; | 63 override; |
70 void GeneratedPasswordAccepted(const base::string16& password) override; | 64 void GeneratedPasswordAccepted(const base::string16& password) override; |
71 void FillSuggestion(const base::string16& username, | 65 void FillSuggestion(const base::string16& username, |
72 const base::string16& password) override; | 66 const base::string16& password) override; |
73 void PreviewSuggestion(const base::string16& username, | 67 void PreviewSuggestion(const base::string16& username, |
74 const base::string16& password) override; | 68 const base::string16& password) override; |
75 void ShowInitialPasswordAccountSuggestions( | 69 void ShowInitialPasswordAccountSuggestions( |
76 const autofill::PasswordFormFillData& form_data) override; | 70 const autofill::PasswordFormFillData& form_data) override; |
77 void ClearPreviewedForm() override; | 71 void ClearPreviewedForm() override; |
78 void ForceSavePassword() override; | 72 void ForceSavePassword() override; |
79 void GeneratePassword() override; | 73 void GeneratePassword() override; |
80 void SendLoggingAvailability() override; | 74 void SendLoggingAvailability() override; |
81 void AllowToRunFormClassifier() override; | 75 void AllowToRunFormClassifier() override; |
82 | 76 |
83 PasswordGenerationManager* GetPasswordGenerationManager() override; | 77 PasswordGenerationManager* GetPasswordGenerationManager() override; |
84 PasswordManager* GetPasswordManager() override; | 78 PasswordManager* GetPasswordManager() override; |
85 PasswordAutofillManager* GetPasswordAutofillManager() override; | 79 PasswordAutofillManager* GetPasswordAutofillManager() override; |
86 | 80 |
| 81 bool HandleMessage(const IPC::Message& message); |
87 void DidNavigateFrame(const content::LoadCommittedDetails& details, | 82 void DidNavigateFrame(const content::LoadCommittedDetails& details, |
88 const content::FrameNavigateParams& params); | 83 const content::FrameNavigateParams& params); |
89 | 84 |
90 // autofill::mojom::PasswordManagerDriver: | 85 // Pass-throughs to PasswordManager. |
91 void PasswordFormsParsed( | 86 void OnPasswordFormsParsed(const std::vector<autofill::PasswordForm>& forms); |
92 const std::vector<autofill::PasswordForm>& forms) override; | |
93 void PasswordFormsRendered( | |
94 const std::vector<autofill::PasswordForm>& visible_forms, | |
95 bool did_stop_loading) override; | |
96 void PasswordFormSubmitted( | |
97 const autofill::PasswordForm& password_form) override; | |
98 void InPageNavigation(const autofill::PasswordForm& password_form) override; | |
99 void PresaveGeneratedPassword( | |
100 const autofill::PasswordForm& password_form) override; | |
101 void PasswordNoLongerGenerated( | |
102 const autofill::PasswordForm& password_form) override; | |
103 void ShowPasswordSuggestions(int key, | |
104 base::i18n::TextDirection text_direction, | |
105 const base::string16& typed_username, | |
106 int options, | |
107 const gfx::RectF& bounds) override; | |
108 void PasswordAutofillAgentConstructed() override; | |
109 void RecordSavePasswordProgress(const std::string& log) override; | |
110 void SaveGenerationFieldDetectedByClassifier( | |
111 const autofill::PasswordForm& password_form, | |
112 const base::string16& generation_field) override; | |
113 | |
114 void OnPasswordFormsParsedNoRenderCheck( | 87 void OnPasswordFormsParsedNoRenderCheck( |
115 const std::vector<autofill::PasswordForm>& forms); | 88 const std::vector<autofill::PasswordForm>& forms); |
| 89 void OnPasswordFormsRendered( |
| 90 const std::vector<autofill::PasswordForm>& visible_forms, |
| 91 bool did_stop_loading); |
| 92 void OnPasswordFormSubmitted(const autofill::PasswordForm& password_form); |
| 93 void OnInPageNavigation(const autofill::PasswordForm& password_form); |
| 94 void OnPresaveGeneratedPassword(const autofill::PasswordForm& password_form); |
| 95 void OnPasswordNoLongerGenerated(const autofill::PasswordForm& password_form); |
116 void OnFocusedPasswordFormFound(const autofill::PasswordForm& password_form); | 96 void OnFocusedPasswordFormFound(const autofill::PasswordForm& password_form); |
| 97 void OnSaveGenerationFieldDetectedByClassifier( |
| 98 const autofill::PasswordForm& password_form, |
| 99 const base::string16& generation_field); |
117 | 100 |
118 private: | 101 private: |
119 bool CheckChildProcessSecurityPolicy(const GURL& url, | 102 bool CheckChildProcessSecurityPolicy(const GURL& url, |
120 BadMessageReason reason); | 103 BadMessageReason reason); |
121 | 104 |
122 const autofill::mojom::AutofillAgentPtr& GetAutofillAgent(); | 105 const autofill::mojom::AutofillAgentPtr& GetAutofillAgent(); |
123 | 106 |
124 const autofill::mojom::PasswordAutofillAgentPtr& GetPasswordAutofillAgent(); | |
125 | |
126 const autofill::mojom::PasswordGenerationAgentPtr& | |
127 GetPasswordGenerationAgent(); | |
128 | |
129 content::RenderFrameHost* render_frame_host_; | 107 content::RenderFrameHost* render_frame_host_; |
130 PasswordManagerClient* client_; | 108 PasswordManagerClient* client_; |
131 PasswordGenerationManager password_generation_manager_; | 109 PasswordGenerationManager password_generation_manager_; |
132 PasswordAutofillManager password_autofill_manager_; | 110 PasswordAutofillManager password_autofill_manager_; |
133 | 111 |
134 // Every instance of PasswordFormFillData created by |*this| and sent to | 112 // Every instance of PasswordFormFillData created by |*this| and sent to |
135 // PasswordAutofillManager and PasswordAutofillAgent is given an ID, so that | 113 // PasswordAutofillManager and PasswordAutofillAgent is given an ID, so that |
136 // the latter two classes can reference to the same instance without sending | 114 // the latter two classes can reference to the same instance without sending |
137 // it to each other over IPC. The counter below is used to generate new IDs. | 115 // it to each other over IPC. The counter below is used to generate new IDs. |
138 int next_free_key_; | 116 int next_free_key_; |
139 | 117 |
140 autofill::mojom::PasswordAutofillAgentPtr password_autofill_agent_; | |
141 | |
142 autofill::mojom::PasswordGenerationAgentPtr password_gen_agent_; | |
143 | |
144 mojo::Binding<autofill::mojom::PasswordManagerDriver> binding_; | |
145 | |
146 base::WeakPtrFactory<ContentPasswordManagerDriver> weak_factory_; | |
147 | |
148 DISALLOW_COPY_AND_ASSIGN(ContentPasswordManagerDriver); | 118 DISALLOW_COPY_AND_ASSIGN(ContentPasswordManagerDriver); |
149 }; | 119 }; |
150 | 120 |
151 } // namespace password_manager | 121 } // namespace password_manager |
152 | 122 |
153 #endif // COMPONENTS_PASSWORD_MANAGER_CONTENT_BROWSER_CONTENT_PASSWORD_MANAGER_
DRIVER_H_ | 123 #endif // COMPONENTS_PASSWORD_MANAGER_CONTENT_BROWSER_CONTENT_PASSWORD_MANAGER_
DRIVER_H_ |
OLD | NEW |