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

Side by Side Diff: components/password_manager/content/browser/content_password_manager_driver.h

Issue 2270333002: Reland: [Autofill] Migrate ContentPasswordManagerDriver<-->Password{Autofill,Generation}Agent IPCs … (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 3 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 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"
14 #include "components/autofill/core/common/password_form_field_prediction_map.h" 15 #include "components/autofill/core/common/password_form_field_prediction_map.h"
15 #include "components/autofill/core/common/password_form_generation_data.h" 16 #include "components/autofill/core/common/password_form_generation_data.h"
16 #include "components/password_manager/core/browser/password_autofill_manager.h" 17 #include "components/password_manager/core/browser/password_autofill_manager.h"
17 #include "components/password_manager/core/browser/password_generation_manager.h " 18 #include "components/password_manager/core/browser/password_generation_manager.h "
18 #include "components/password_manager/core/browser/password_manager.h" 19 #include "components/password_manager/core/browser/password_manager.h"
19 #include "components/password_manager/core/browser/password_manager_driver.h" 20 #include "components/password_manager/core/browser/password_manager_driver.h"
21 #include "mojo/public/cpp/bindings/binding.h"
20 22
21 namespace autofill { 23 namespace autofill {
22 class AutofillManager; 24 class AutofillManager;
23 struct PasswordForm; 25 struct PasswordForm;
24 } 26 }
25 27
26 namespace content { 28 namespace content {
27 struct FrameNavigateParams; 29 struct FrameNavigateParams;
28 struct LoadCommittedDetails; 30 struct LoadCommittedDetails;
29 class RenderFrameHost; 31 class RenderFrameHost;
30 class WebContents; 32 class WebContents;
31 } 33 }
32 34
33 namespace IPC { 35 namespace IPC {
34 class Message; 36 class Message;
35 } 37 }
36 38
37 namespace password_manager { 39 namespace password_manager {
38 enum class BadMessageReason; 40 enum class BadMessageReason;
39 41
40 // There is one ContentPasswordManagerDriver per RenderFrameHost. 42 // There is one ContentPasswordManagerDriver per RenderFrameHost.
41 // The lifetime is managed by the ContentPasswordManagerDriverFactory. 43 // The lifetime is managed by the ContentPasswordManagerDriverFactory.
42 class ContentPasswordManagerDriver : public PasswordManagerDriver { 44 class ContentPasswordManagerDriver
45 : public PasswordManagerDriver,
46 public autofill::mojom::PasswordManagerDriver {
43 public: 47 public:
44 ContentPasswordManagerDriver(content::RenderFrameHost* render_frame_host, 48 ContentPasswordManagerDriver(content::RenderFrameHost* render_frame_host,
45 PasswordManagerClient* client, 49 PasswordManagerClient* client,
46 autofill::AutofillClient* autofill_client); 50 autofill::AutofillClient* autofill_client);
47 ~ContentPasswordManagerDriver() override; 51 ~ContentPasswordManagerDriver() override;
48 52
49 // Gets the driver for |render_frame_host|. 53 // Gets the driver for |render_frame_host|.
50 static ContentPasswordManagerDriver* GetForRenderFrameHost( 54 static ContentPasswordManagerDriver* GetForRenderFrameHost(
51 content::RenderFrameHost* render_frame_host); 55 content::RenderFrameHost* render_frame_host);
52 56
57 void BindRequest(autofill::mojom::PasswordManagerDriverRequest request);
58
53 // PasswordManagerDriver implementation. 59 // PasswordManagerDriver implementation.
54 void FillPasswordForm( 60 void FillPasswordForm(
55 const autofill::PasswordFormFillData& form_data) override; 61 const autofill::PasswordFormFillData& form_data) override;
56 void AllowPasswordGenerationForForm( 62 void AllowPasswordGenerationForForm(
57 const autofill::PasswordForm& form) override; 63 const autofill::PasswordForm& form) override;
58 void FormsEligibleForGenerationFound( 64 void FormsEligibleForGenerationFound(
59 const std::vector<autofill::PasswordFormGenerationData>& forms) override; 65 const std::vector<autofill::PasswordFormGenerationData>& forms) override;
60 void AutofillDataReceived( 66 void AutofillDataReceived(
61 const std::map<autofill::FormData, 67 const std::map<autofill::FormData,
62 autofill::PasswordFormFieldPredictionMap>& predictions) 68 autofill::PasswordFormFieldPredictionMap>& predictions)
63 override; 69 override;
64 void GeneratedPasswordAccepted(const base::string16& password) override; 70 void GeneratedPasswordAccepted(const base::string16& password) override;
65 void FillSuggestion(const base::string16& username, 71 void FillSuggestion(const base::string16& username,
66 const base::string16& password) override; 72 const base::string16& password) override;
67 void PreviewSuggestion(const base::string16& username, 73 void PreviewSuggestion(const base::string16& username,
68 const base::string16& password) override; 74 const base::string16& password) override;
69 void ShowInitialPasswordAccountSuggestions( 75 void ShowInitialPasswordAccountSuggestions(
70 const autofill::PasswordFormFillData& form_data) override; 76 const autofill::PasswordFormFillData& form_data) override;
71 void ClearPreviewedForm() override; 77 void ClearPreviewedForm() override;
72 void ForceSavePassword() override; 78 void ForceSavePassword() override;
73 void GeneratePassword() override; 79 void GeneratePassword() override;
74 void SendLoggingAvailability() override; 80 void SendLoggingAvailability() override;
75 void AllowToRunFormClassifier() override; 81 void AllowToRunFormClassifier() override;
76 82
77 PasswordGenerationManager* GetPasswordGenerationManager() override; 83 PasswordGenerationManager* GetPasswordGenerationManager() override;
78 PasswordManager* GetPasswordManager() override; 84 PasswordManager* GetPasswordManager() override;
79 PasswordAutofillManager* GetPasswordAutofillManager() override; 85 PasswordAutofillManager* GetPasswordAutofillManager() override;
80 86
81 bool HandleMessage(const IPC::Message& message);
82 void DidNavigateFrame(const content::LoadCommittedDetails& details, 87 void DidNavigateFrame(const content::LoadCommittedDetails& details,
83 const content::FrameNavigateParams& params); 88 const content::FrameNavigateParams& params);
84 89
85 // Pass-throughs to PasswordManager. 90 // autofill::mojom::PasswordManagerDriver:
86 void OnPasswordFormsParsed(const std::vector<autofill::PasswordForm>& forms); 91 void PasswordFormsParsed(
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
87 void OnPasswordFormsParsedNoRenderCheck( 114 void OnPasswordFormsParsedNoRenderCheck(
88 const std::vector<autofill::PasswordForm>& forms); 115 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);
96 void OnFocusedPasswordFormFound(const autofill::PasswordForm& password_form); 116 void OnFocusedPasswordFormFound(const autofill::PasswordForm& password_form);
97 void OnSaveGenerationFieldDetectedByClassifier(
98 const autofill::PasswordForm& password_form,
99 const base::string16& generation_field);
100 117
101 private: 118 private:
102 bool CheckChildProcessSecurityPolicy(const GURL& url, 119 bool CheckChildProcessSecurityPolicy(const GURL& url,
103 BadMessageReason reason); 120 BadMessageReason reason);
104 121
105 const autofill::mojom::AutofillAgentPtr& GetAutofillAgent(); 122 const autofill::mojom::AutofillAgentPtr& GetAutofillAgent();
106 123
124 const autofill::mojom::PasswordAutofillAgentPtr& GetPasswordAutofillAgent();
125
126 const autofill::mojom::PasswordGenerationAgentPtr&
127 GetPasswordGenerationAgent();
128
107 content::RenderFrameHost* render_frame_host_; 129 content::RenderFrameHost* render_frame_host_;
108 PasswordManagerClient* client_; 130 PasswordManagerClient* client_;
109 PasswordGenerationManager password_generation_manager_; 131 PasswordGenerationManager password_generation_manager_;
110 PasswordAutofillManager password_autofill_manager_; 132 PasswordAutofillManager password_autofill_manager_;
111 133
112 // Every instance of PasswordFormFillData created by |*this| and sent to 134 // Every instance of PasswordFormFillData created by |*this| and sent to
113 // PasswordAutofillManager and PasswordAutofillAgent is given an ID, so that 135 // PasswordAutofillManager and PasswordAutofillAgent is given an ID, so that
114 // the latter two classes can reference to the same instance without sending 136 // the latter two classes can reference to the same instance without sending
115 // it to each other over IPC. The counter below is used to generate new IDs. 137 // it to each other over IPC. The counter below is used to generate new IDs.
116 int next_free_key_; 138 int next_free_key_;
117 139
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
118 DISALLOW_COPY_AND_ASSIGN(ContentPasswordManagerDriver); 148 DISALLOW_COPY_AND_ASSIGN(ContentPasswordManagerDriver);
119 }; 149 };
120 150
121 } // namespace password_manager 151 } // namespace password_manager
122 152
123 #endif // COMPONENTS_PASSWORD_MANAGER_CONTENT_BROWSER_CONTENT_PASSWORD_MANAGER_ DRIVER_H_ 153 #endif // COMPONENTS_PASSWORD_MANAGER_CONTENT_BROWSER_CONTENT_PASSWORD_MANAGER_ DRIVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698