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 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 "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "components/password_manager/content/browser/content_credential_manager
_dispatcher.h" | 10 #include "components/password_manager/content/browser/content_credential_manager
_dispatcher.h" |
11 #include "components/password_manager/content/browser/content_password_manager_d
river.h" | 11 #include "components/password_manager/content/browser/content_password_manager_d
river_factory.h" |
| 12 #include "components/password_manager/core/browser/password_manager.h" |
12 #include "components/password_manager/core/browser/password_manager_client.h" | 13 #include "components/password_manager/core/browser/password_manager_client.h" |
13 #include "content/public/browser/web_contents_observer.h" | 14 #include "content/public/browser/web_contents_observer.h" |
14 #include "content/public/browser/web_contents_user_data.h" | 15 #include "content/public/browser/web_contents_user_data.h" |
15 #include "ui/gfx/rect.h" | 16 #include "ui/gfx/rect.h" |
16 | 17 |
17 class Profile; | 18 class Profile; |
18 | 19 |
19 namespace autofill { | 20 namespace autofill { |
20 class PasswordGenerationPopupObserver; | 21 class PasswordGenerationPopupObserver; |
21 class PasswordGenerationPopupControllerImpl; | 22 class PasswordGenerationPopupControllerImpl; |
22 } | 23 } |
23 | 24 |
24 namespace content { | 25 namespace content { |
25 class WebContents; | 26 class WebContents; |
26 } | 27 } |
27 | 28 |
28 namespace password_manager { | 29 namespace password_manager { |
29 struct CredentialInfo; | 30 struct CredentialInfo; |
30 class PasswordGenerationManager; | 31 class PasswordGenerationManager; |
31 class PasswordManager; | 32 class PasswordManagerDriver; |
32 } | 33 } |
33 | 34 |
34 // ChromePasswordManagerClient implements the PasswordManagerClient interface. | 35 // ChromePasswordManagerClient implements the PasswordManagerClient interface. |
35 class ChromePasswordManagerClient | 36 class ChromePasswordManagerClient |
36 : public password_manager::PasswordManagerClient, | 37 : public password_manager::PasswordManagerClient, |
37 public content::WebContentsObserver, | 38 public content::WebContentsObserver, |
38 public content::WebContentsUserData<ChromePasswordManagerClient> { | 39 public content::WebContentsUserData<ChromePasswordManagerClient> { |
39 public: | 40 public: |
40 ~ChromePasswordManagerClient() override; | 41 ~ChromePasswordManagerClient() override; |
41 | 42 |
(...skipping 14 matching lines...) Expand all Loading... |
56 base::Callback<void(const password_manager::CredentialInfo&)> | 57 base::Callback<void(const password_manager::CredentialInfo&)> |
57 callback) override; | 58 callback) override; |
58 void AutomaticPasswordSave(scoped_ptr<password_manager::PasswordFormManager> | 59 void AutomaticPasswordSave(scoped_ptr<password_manager::PasswordFormManager> |
59 saved_form_manager) override; | 60 saved_form_manager) override; |
60 void PasswordWasAutofilled( | 61 void PasswordWasAutofilled( |
61 const autofill::PasswordFormMap& best_matches) const override; | 62 const autofill::PasswordFormMap& best_matches) const override; |
62 void PasswordAutofillWasBlocked( | 63 void PasswordAutofillWasBlocked( |
63 const autofill::PasswordFormMap& best_matches) const override; | 64 const autofill::PasswordFormMap& best_matches) const override; |
64 PrefService* GetPrefs() override; | 65 PrefService* GetPrefs() override; |
65 password_manager::PasswordStore* GetPasswordStore() override; | 66 password_manager::PasswordStore* GetPasswordStore() override; |
66 password_manager::PasswordManagerDriver* GetDriver() override; | |
67 base::FieldTrial::Probability GetProbabilityForExperiment( | 67 base::FieldTrial::Probability GetProbabilityForExperiment( |
68 const std::string& experiment_name) override; | 68 const std::string& experiment_name) override; |
69 bool IsPasswordSyncEnabled( | 69 bool IsPasswordSyncEnabled( |
70 password_manager::CustomPassphraseState state) override; | 70 password_manager::CustomPassphraseState state) override; |
71 void OnLogRouterAvailabilityChanged(bool router_can_be_used) override; | 71 void OnLogRouterAvailabilityChanged(bool router_can_be_used) override; |
72 void LogSavePasswordProgress(const std::string& text) const override; | 72 void LogSavePasswordProgress(const std::string& text) const override; |
73 bool IsLoggingActive() const override; | 73 bool IsLoggingActive() const override; |
74 bool WasLastNavigationHTTPError() const override; | 74 bool WasLastNavigationHTTPError() const override; |
| 75 bool DidLastPageLoadEncounterSSLErrors() override; |
| 76 bool IsOffTheRecord() override; |
| 77 password_manager::PasswordManager* GetPasswordManager() override; |
75 | 78 |
76 // Hides any visible generation UI. | 79 // Hides any visible generation UI. |
77 void HidePasswordGenerationPopup(); | 80 void HidePasswordGenerationPopup(); |
78 | 81 |
79 static void CreateForWebContentsWithAutofillClient( | 82 static void CreateForWebContentsWithAutofillClient( |
80 content::WebContents* contents, | 83 content::WebContents* contents, |
81 autofill::AutofillClient* autofill_client); | 84 autofill::AutofillClient* autofill_client); |
82 | 85 |
83 // Convenience method to allow //chrome code easy access to a PasswordManager | |
84 // from a WebContents instance. | |
85 static password_manager::PasswordManager* GetManagerFromWebContents( | |
86 content::WebContents* contents); | |
87 | |
88 // Convenience method to allow //chrome code easy access to a | |
89 // PasswordGenerationManager from a WebContents instance. | |
90 static password_manager::PasswordGenerationManager* | |
91 GetGenerationManagerFromWebContents(content::WebContents* contents); | |
92 | |
93 // Observer for PasswordGenerationPopup events. Used for testing. | 86 // Observer for PasswordGenerationPopup events. Used for testing. |
94 void SetTestObserver(autofill::PasswordGenerationPopupObserver* observer); | 87 void SetTestObserver(autofill::PasswordGenerationPopupObserver* observer); |
95 | 88 |
96 // Returns true if the bubble UI is enabled, and false if we're still using | 89 // Returns true if the bubble UI is enabled, and false if we're still using |
97 // the sad old Infobar UI. | 90 // the sad old Infobar UI. |
98 static bool IsTheHotNewBubbleUIEnabled(); | 91 static bool IsTheHotNewBubbleUIEnabled(); |
99 | 92 |
100 // Returns true if the password manager should be enabled during sync signin. | 93 // Returns true if the password manager should be enabled during sync signin. |
101 static bool EnabledForSyncSignin(); | 94 static bool EnabledForSyncSignin(); |
102 | 95 |
103 protected: | 96 protected: |
104 // Callable for tests. | 97 // Callable for tests. |
105 ChromePasswordManagerClient(content::WebContents* web_contents, | 98 ChromePasswordManagerClient(content::WebContents* web_contents, |
106 autofill::AutofillClient* autofill_client); | 99 autofill::AutofillClient* autofill_client); |
107 | 100 |
108 private: | 101 private: |
109 enum AutofillForSyncCredentialsState { | 102 enum AutofillForSyncCredentialsState { |
110 ALLOW_SYNC_CREDENTIALS, | 103 ALLOW_SYNC_CREDENTIALS, |
111 DISALLOW_SYNC_CREDENTIALS_FOR_REAUTH, | 104 DISALLOW_SYNC_CREDENTIALS_FOR_REAUTH, |
112 DISALLOW_SYNC_CREDENTIALS, | 105 DISALLOW_SYNC_CREDENTIALS, |
113 }; | 106 }; |
114 | 107 |
115 friend class content::WebContentsUserData<ChromePasswordManagerClient>; | 108 friend class content::WebContentsUserData<ChromePasswordManagerClient>; |
116 | 109 |
117 // content::WebContentsObserver overrides. | 110 // content::WebContentsObserver overrides. |
118 bool OnMessageReceived(const IPC::Message& message) override; | 111 bool OnMessageReceived(const IPC::Message& message, |
| 112 content::RenderFrameHost* render_frame_host) override; |
119 | 113 |
120 // Given |bounds| in the renderers coordinate system, return the same bounds | 114 // Given |bounds| in the renderers coordinate system, return the same bounds |
121 // in the screens coordinate system. | 115 // in the screens coordinate system. |
122 gfx::RectF GetBoundsInScreenSpace(const gfx::RectF& bounds); | 116 gfx::RectF GetBoundsInScreenSpace(const gfx::RectF& bounds); |
123 | 117 |
124 // Causes the password generation UI to be shown for the specified form. | 118 // Causes the password generation UI to be shown for the specified form. |
125 // The popup will be anchored at |element_bounds|. The generated password | 119 // The popup will be anchored at |element_bounds|. The generated password |
126 // will be no longer than |max_length|. | 120 // will be no longer than |max_length|. |
127 void ShowPasswordGenerationPopup(const gfx::RectF& bounds, | 121 void ShowPasswordGenerationPopup(content::RenderFrameHost* render_frame_host, |
| 122 const gfx::RectF& bounds, |
128 int max_length, | 123 int max_length, |
129 const autofill::PasswordForm& form); | 124 const autofill::PasswordForm& form); |
130 | 125 |
131 // Causes the password editing UI to be shown anchored at |element_bounds|. | 126 // Causes the password editing UI to be shown anchored at |element_bounds|. |
132 void ShowPasswordEditingPopup( | 127 void ShowPasswordEditingPopup(content::RenderFrameHost* render_frame_host, |
133 const gfx::RectF& bounds, const autofill::PasswordForm& form); | 128 const gfx::RectF& bounds, |
| 129 const autofill::PasswordForm& form); |
134 | 130 |
135 // Sends a message to the renderer with the current value of | 131 // Sends a message to the renderer with the current value of |
136 // |can_use_log_router_|. | 132 // |can_use_log_router_|. |
137 void NotifyRendererOfLoggingAvailability(); | 133 void NotifyRendererOfLoggingAvailability(); |
138 | 134 |
139 // Returns true if the last loaded page was for transactional re-auth on a | 135 // Returns true if the last loaded page was for transactional re-auth on a |
140 // Google property. | 136 // Google property. |
141 bool LastLoadWasTransactionalReauthPage() const; | 137 bool LastLoadWasTransactionalReauthPage() const; |
142 | 138 |
143 // Returns true if |url| is the reauth page for accessing the password | 139 // Returns true if |url| is the reauth page for accessing the password |
144 // website. | 140 // website. |
145 bool IsURLPasswordWebsiteReauth(const GURL& url) const; | 141 bool IsURLPasswordWebsiteReauth(const GURL& url) const; |
146 | 142 |
147 // Sets |autofill_state_| based on experiment and flag values. | 143 // Sets |autofill_state_| based on experiment and flag values. |
148 void SetUpAutofillSyncState(); | 144 void SetUpAutofillSyncState(); |
149 | 145 |
150 Profile* const profile_; | 146 Profile* const profile_; |
151 | 147 |
152 password_manager::ContentPasswordManagerDriver driver_; | 148 password_manager::PasswordManager password_manager_; |
| 149 |
| 150 password_manager::ContentPasswordManagerDriverFactory* driver_factory_; |
153 | 151 |
154 password_manager::ContentCredentialManagerDispatcher | 152 password_manager::ContentCredentialManagerDispatcher |
155 credential_manager_dispatcher_; | 153 credential_manager_dispatcher_; |
156 | 154 |
157 // Observer for password generation popup. | 155 // Observer for password generation popup. |
158 autofill::PasswordGenerationPopupObserver* observer_; | 156 autofill::PasswordGenerationPopupObserver* observer_; |
159 | 157 |
160 // Controls the popup | 158 // Controls the popup |
161 base::WeakPtr< | 159 base::WeakPtr< |
162 autofill::PasswordGenerationPopupControllerImpl> popup_controller_; | 160 autofill::PasswordGenerationPopupControllerImpl> popup_controller_; |
163 | 161 |
164 // True if |this| is registered with some LogRouter which can accept logs. | 162 // True if |this| is registered with some LogRouter which can accept logs. |
165 bool can_use_log_router_; | 163 bool can_use_log_router_; |
166 | 164 |
167 // How to handle the sync credential in ShouldFilterAutofillResult(). | 165 // How to handle the sync credential in ShouldFilterAutofillResult(). |
168 AutofillForSyncCredentialsState autofill_sync_state_; | 166 AutofillForSyncCredentialsState autofill_sync_state_; |
169 | 167 |
170 // If the sync credential was filtered during autofill. Used for statistics | 168 // If the sync credential was filtered during autofill. Used for statistics |
171 // reporting. | 169 // reporting. |
172 bool sync_credential_was_filtered_; | 170 bool sync_credential_was_filtered_; |
173 | 171 |
174 DISALLOW_COPY_AND_ASSIGN(ChromePasswordManagerClient); | 172 DISALLOW_COPY_AND_ASSIGN(ChromePasswordManagerClient); |
175 }; | 173 }; |
176 | 174 |
177 #endif // CHROME_BROWSER_PASSWORD_MANAGER_CHROME_PASSWORD_MANAGER_CLIENT_H_ | 175 #endif // CHROME_BROWSER_PASSWORD_MANAGER_CHROME_PASSWORD_MANAGER_CLIENT_H_ |
OLD | NEW |