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

Side by Side Diff: chrome/browser/password_manager/chrome_password_manager_client.h

Issue 2352533003: [Autofill] Migrate ChromePasswordManagerClient<-->PasswordGenerationAgent IPCs to mojo. (Closed)
Patch Set: Rebase only Created 4 years, 2 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
« no previous file with comments | « no previous file | chrome/browser/password_manager/chrome_password_manager_client.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 CHROME_BROWSER_PASSWORD_MANAGER_CHROME_PASSWORD_MANAGER_CLIENT_H_ 5 #ifndef CHROME_BROWSER_PASSWORD_MANAGER_CHROME_PASSWORD_MANAGER_CLIENT_H_
6 #define CHROME_BROWSER_PASSWORD_MANAGER_CHROME_PASSWORD_MANAGER_CLIENT_H_ 6 #define CHROME_BROWSER_PASSWORD_MANAGER_CHROME_PASSWORD_MANAGER_CLIENT_H_
7 7
8 #include <memory> 8 #include <memory>
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_driver.mojom.h"
13 #include "components/password_manager/content/browser/content_password_manager_d river_factory.h" 14 #include "components/password_manager/content/browser/content_password_manager_d river_factory.h"
14 #include "components/password_manager/content/browser/credential_manager_impl.h" 15 #include "components/password_manager/content/browser/credential_manager_impl.h"
15 #include "components/password_manager/core/browser/password_manager.h" 16 #include "components/password_manager/core/browser/password_manager.h"
16 #include "components/password_manager/core/browser/password_manager_client.h" 17 #include "components/password_manager/core/browser/password_manager_client.h"
17 #include "components/password_manager/sync/browser/sync_credentials_filter.h" 18 #include "components/password_manager/sync/browser/sync_credentials_filter.h"
18 #include "components/prefs/pref_member.h" 19 #include "components/prefs/pref_member.h"
20 #include "content/public/browser/web_contents_binding_set.h"
19 #include "content/public/browser/web_contents_observer.h" 21 #include "content/public/browser/web_contents_observer.h"
20 #include "content/public/browser/web_contents_user_data.h" 22 #include "content/public/browser/web_contents_user_data.h"
21 #include "ui/gfx/geometry/rect.h" 23 #include "ui/gfx/geometry/rect.h"
22 24
23 class Profile; 25 class Profile;
24 26
25 namespace autofill { 27 namespace autofill {
26 class PasswordGenerationPopupObserver; 28 class PasswordGenerationPopupObserver;
27 class PasswordGenerationPopupControllerImpl; 29 class PasswordGenerationPopupControllerImpl;
28 } 30 }
29 31
30 namespace content { 32 namespace content {
31 class WebContents; 33 class WebContents;
32 } 34 }
33 35
34 namespace password_manager { 36 namespace password_manager {
35 struct CredentialInfo; 37 struct CredentialInfo;
36 class PasswordGenerationManager; 38 class PasswordGenerationManager;
37 class PasswordManagerDriver; 39 class PasswordManagerDriver;
38 } 40 }
39 41
40 // ChromePasswordManagerClient implements the PasswordManagerClient interface. 42 // ChromePasswordManagerClient implements the PasswordManagerClient interface.
41 class ChromePasswordManagerClient 43 class ChromePasswordManagerClient
42 : public password_manager::PasswordManagerClient, 44 : public password_manager::PasswordManagerClient,
43 public content::WebContentsObserver, 45 public content::WebContentsObserver,
44 public content::WebContentsUserData<ChromePasswordManagerClient> { 46 public content::WebContentsUserData<ChromePasswordManagerClient>,
47 public autofill::mojom::PasswordManagerClient {
45 public: 48 public:
46 ~ChromePasswordManagerClient() override; 49 ~ChromePasswordManagerClient() override;
47 50
48 // PasswordManagerClient implementation. 51 // PasswordManagerClient implementation.
49 bool IsAutomaticPasswordSavingEnabled() const override; 52 bool IsAutomaticPasswordSavingEnabled() const override;
50 bool IsSavingAndFillingEnabledForCurrentPage() const override; 53 bool IsSavingAndFillingEnabledForCurrentPage() const override;
51 bool IsFillingEnabledForCurrentPage() const override; 54 bool IsFillingEnabledForCurrentPage() const override;
52 bool PromptUserToSaveOrUpdatePassword( 55 bool PromptUserToSaveOrUpdatePassword(
53 std::unique_ptr<password_manager::PasswordFormManager> form_to_save, 56 std::unique_ptr<password_manager::PasswordFormManager> form_to_save,
54 password_manager::CredentialSourceType type, 57 password_manager::CredentialSourceType type,
(...skipping 30 matching lines...) Expand all
85 const password_manager::PasswordManager* GetPasswordManager() const override; 88 const password_manager::PasswordManager* GetPasswordManager() const override;
86 autofill::AutofillManager* GetAutofillManagerForMainFrame() override; 89 autofill::AutofillManager* GetAutofillManagerForMainFrame() override;
87 const GURL& GetMainFrameURL() const override; 90 const GURL& GetMainFrameURL() const override;
88 bool IsUpdatePasswordUIEnabled() const override; 91 bool IsUpdatePasswordUIEnabled() const override;
89 const GURL& GetLastCommittedEntryURL() const override; 92 const GURL& GetLastCommittedEntryURL() const override;
90 void AnnotateNavigationEntry(bool has_password_field) override; 93 void AnnotateNavigationEntry(bool has_password_field) override;
91 const password_manager::CredentialsFilter* GetStoreResultFilter() 94 const password_manager::CredentialsFilter* GetStoreResultFilter()
92 const override; 95 const override;
93 const password_manager::LogManager* GetLogManager() const override; 96 const password_manager::LogManager* GetLogManager() const override;
94 97
95 // Hides any visible generation UI. 98 // autofill::mojom::PasswordManagerClient overrides.
96 void HidePasswordGenerationPopup(); 99 void ShowPasswordGenerationPopup(const gfx::RectF& bounds,
100 int max_length,
101 const base::string16& generation_element,
102 bool is_manually_triggered,
103 const autofill::PasswordForm& form) override;
104 void ShowPasswordEditingPopup(const gfx::RectF& bounds,
105 const autofill::PasswordForm& form) override;
106 void GenerationAvailableForForm(const autofill::PasswordForm& form) override;
107 void HidePasswordGenerationPopup() override;
97 108
98 static void CreateForWebContentsWithAutofillClient( 109 static void CreateForWebContentsWithAutofillClient(
99 content::WebContents* contents, 110 content::WebContents* contents,
100 autofill::AutofillClient* autofill_client); 111 autofill::AutofillClient* autofill_client);
101 112
102 // Observer for PasswordGenerationPopup events. Used for testing. 113 // Observer for PasswordGenerationPopup events. Used for testing.
103 void SetTestObserver(autofill::PasswordGenerationPopupObserver* observer); 114 void SetTestObserver(autofill::PasswordGenerationPopupObserver* observer);
104 115
105 static void BindCredentialManager( 116 static void BindCredentialManager(
106 content::RenderFrameHost* render_frame_host, 117 content::RenderFrameHost* render_frame_host,
107 password_manager::mojom::CredentialManagerRequest request); 118 password_manager::mojom::CredentialManagerRequest request);
108 119
109 protected: 120 protected:
110 // Callable for tests. 121 // Callable for tests.
111 ChromePasswordManagerClient(content::WebContents* web_contents, 122 ChromePasswordManagerClient(content::WebContents* web_contents,
112 autofill::AutofillClient* autofill_client); 123 autofill::AutofillClient* autofill_client);
113 124
114 private: 125 private:
115 friend class content::WebContentsUserData<ChromePasswordManagerClient>; 126 friend class content::WebContentsUserData<ChromePasswordManagerClient>;
116 127
117 // content::WebContentsObserver overrides. 128 // content::WebContentsObserver overrides.
118 bool OnMessageReceived(const IPC::Message& message,
119 content::RenderFrameHost* render_frame_host) override;
120 void DidStartNavigation( 129 void DidStartNavigation(
121 content::NavigationHandle* navigation_handle) override; 130 content::NavigationHandle* navigation_handle) override;
122 131
123 // Given |bounds| in the renderers coordinate system, return the same bounds 132 // Given |bounds| in the renderers coordinate system, return the same bounds
124 // in the screens coordinate system. 133 // in the screens coordinate system.
125 gfx::RectF GetBoundsInScreenSpace(const gfx::RectF& bounds); 134 gfx::RectF GetBoundsInScreenSpace(const gfx::RectF& bounds);
126 135
127 // Checks if the current page fulfils the conditions for the password manager 136 // Checks if the current page fulfils the conditions for the password manager
128 // to be active on it, for example Sync credentials are not saved or auto 137 // to be active on it, for example Sync credentials are not saved or auto
129 // filled. 138 // filled.
130 bool IsPasswordManagementEnabledForCurrentPage() const; 139 bool IsPasswordManagementEnabledForCurrentPage() const;
131 140
132 // Causes the password generation UI to be shown for the specified form.
133 // The popup will be anchored at |element_bounds|. The generated password
134 // will be no longer than |max_length|. |generation_element| should contain a
135 // name of a password field at which generation popup is attached.
136 // |is_manually_triggered| informs whether it is automatically or manually
137 // triggered generation.
138 void ShowPasswordGenerationPopup(content::RenderFrameHost* render_frame_host,
139 const gfx::RectF& bounds,
140 int max_length,
141 const base::string16& generation_element,
142 bool is_manually_triggered,
143 const autofill::PasswordForm& form);
144
145 // Causes the password editing UI to be shown anchored at |element_bounds|.
146 void ShowPasswordEditingPopup(content::RenderFrameHost* render_frame_host,
147 const gfx::RectF& bounds,
148 const autofill::PasswordForm& form);
149
150 // Shows the dialog where the user can accept or decline the global autosignin 141 // Shows the dialog where the user can accept or decline the global autosignin
151 // setting as a first run experience. The dialog won't appear in Incognito or 142 // setting as a first run experience. The dialog won't appear in Incognito or
152 // when the autosign-in is off. 143 // when the autosign-in is off.
153 void PromptUserToEnableAutosigninIfNecessary(); 144 void PromptUserToEnableAutosigninIfNecessary();
154 145
155 // Notify the PasswordManager that generation is available for |form|. Used
156 // for UMA stats.
157 void GenerationAvailableForForm(const autofill::PasswordForm& form);
158
159 // Called as a response to PromptUserToChooseCredentials. nullptr in |form| 146 // Called as a response to PromptUserToChooseCredentials. nullptr in |form|
160 // means that nothing was chosen. |one_local_credential| is true if there was 147 // means that nothing was chosen. |one_local_credential| is true if there was
161 // just one local credential to be chosen from. 148 // just one local credential to be chosen from.
162 void OnCredentialsChosen(const CredentialsCallback& callback, 149 void OnCredentialsChosen(const CredentialsCallback& callback,
163 bool one_local_credential, 150 bool one_local_credential,
164 const autofill::PasswordForm* form); 151 const autofill::PasswordForm* form);
165 152
166 // Returns true if this profile has metrics reporting and active sync 153 // Returns true if this profile has metrics reporting and active sync
167 // without custom sync passphrase. 154 // without custom sync passphrase.
168 static bool ShouldAnnotateNavigationEntries(Profile* profile); 155 static bool ShouldAnnotateNavigationEntries(Profile* profile);
169 156
170 Profile* const profile_; 157 Profile* const profile_;
171 158
172 password_manager::PasswordManager password_manager_; 159 password_manager::PasswordManager password_manager_;
173 160
174 password_manager::ContentPasswordManagerDriverFactory* driver_factory_; 161 password_manager::ContentPasswordManagerDriverFactory* driver_factory_;
175 162
176 // As a mojo service, will be registered into service registry 163 // As a mojo service, will be registered into service registry
177 // of the main frame host by ChromeContentBrowserClient 164 // of the main frame host by ChromeContentBrowserClient
178 // once main frame host was created. 165 // once main frame host was created.
179 password_manager::CredentialManagerImpl credential_manager_impl_; 166 password_manager::CredentialManagerImpl credential_manager_impl_;
180 167
168 content::WebContentsFrameBindingSet<autofill::mojom::PasswordManagerClient>
169 password_manager_client_bindings_;
170
181 // Observer for password generation popup. 171 // Observer for password generation popup.
182 autofill::PasswordGenerationPopupObserver* observer_; 172 autofill::PasswordGenerationPopupObserver* observer_;
183 173
184 // Controls the popup 174 // Controls the popup
185 base::WeakPtr< 175 base::WeakPtr<
186 autofill::PasswordGenerationPopupControllerImpl> popup_controller_; 176 autofill::PasswordGenerationPopupControllerImpl> popup_controller_;
187 177
188 // Set to false to disable password saving (will no longer ask if you 178 // Set to false to disable password saving (will no longer ask if you
189 // want to save passwords and also won't fill the passwords). 179 // want to save passwords and also won't fill the passwords).
190 BooleanPrefMember saving_and_filling_passwords_enabled_; 180 BooleanPrefMember saving_and_filling_passwords_enabled_;
191 181
192 const password_manager::SyncCredentialsFilter credentials_filter_; 182 const password_manager::SyncCredentialsFilter credentials_filter_;
193 183
194 std::unique_ptr<password_manager::LogManager> log_manager_; 184 std::unique_ptr<password_manager::LogManager> log_manager_;
195 185
196 // Set during 'NotifyUserCouldBeAutoSignedIn' in order to store the 186 // Set during 'NotifyUserCouldBeAutoSignedIn' in order to store the
197 // form for potential use during 'NotifySuccessfulLoginWithExistingPassword'. 187 // form for potential use during 'NotifySuccessfulLoginWithExistingPassword'.
198 std::unique_ptr<autofill::PasswordForm> possible_auto_sign_in_; 188 std::unique_ptr<autofill::PasswordForm> possible_auto_sign_in_;
199 189
200 DISALLOW_COPY_AND_ASSIGN(ChromePasswordManagerClient); 190 DISALLOW_COPY_AND_ASSIGN(ChromePasswordManagerClient);
201 }; 191 };
202 192
203 #endif // CHROME_BROWSER_PASSWORD_MANAGER_CHROME_PASSWORD_MANAGER_CLIENT_H_ 193 #endif // CHROME_BROWSER_PASSWORD_MANAGER_CHROME_PASSWORD_MANAGER_CLIENT_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/password_manager/chrome_password_manager_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698