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