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