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