Chromium Code Reviews| 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 "base/gtest_prod_util.h" | |
| 10 #include "components/password_manager/content/browser/content_password_manager_d river.h" | 11 #include "components/password_manager/content/browser/content_password_manager_d river.h" |
| 11 #include "components/password_manager/core/browser/password_manager_client.h" | 12 #include "components/password_manager/core/browser/password_manager_client.h" |
| 12 #include "content/public/browser/web_contents_observer.h" | 13 #include "content/public/browser/web_contents_observer.h" |
| 13 #include "content/public/browser/web_contents_user_data.h" | 14 #include "content/public/browser/web_contents_user_data.h" |
| 14 #include "ui/gfx/rect.h" | 15 #include "ui/gfx/rect.h" |
| 15 | 16 |
| 16 class Profile; | 17 class Profile; |
| 17 | 18 |
| 18 namespace autofill { | 19 namespace autofill { |
| 19 class PasswordGenerationPopupObserver; | 20 class PasswordGenerationPopupObserver; |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 33 class ChromePasswordManagerClient | 34 class ChromePasswordManagerClient |
| 34 : public password_manager::PasswordManagerClient, | 35 : public password_manager::PasswordManagerClient, |
| 35 public content::WebContentsObserver, | 36 public content::WebContentsObserver, |
| 36 public content::WebContentsUserData<ChromePasswordManagerClient> { | 37 public content::WebContentsUserData<ChromePasswordManagerClient> { |
| 37 public: | 38 public: |
| 38 virtual ~ChromePasswordManagerClient(); | 39 virtual ~ChromePasswordManagerClient(); |
| 39 | 40 |
| 40 // PasswordManagerClient implementation. | 41 // PasswordManagerClient implementation. |
| 41 virtual bool IsAutomaticPasswordSavingEnabled() const OVERRIDE; | 42 virtual bool IsAutomaticPasswordSavingEnabled() const OVERRIDE; |
| 42 virtual bool IsPasswordManagerEnabledForCurrentPage() const OVERRIDE; | 43 virtual bool IsPasswordManagerEnabledForCurrentPage() const OVERRIDE; |
| 44 virtual bool ShouldFilterAutofillResult( | |
| 45 const autofill::PasswordForm& form) const OVERRIDE; | |
| 43 virtual bool IsSyncAccountCredential( | 46 virtual bool IsSyncAccountCredential( |
| 44 const std::string& username, const std::string& origin) const OVERRIDE; | 47 const std::string& username, const std::string& origin) const OVERRIDE; |
| 45 virtual void PromptUserToSavePassword( | 48 virtual void PromptUserToSavePassword( |
| 46 scoped_ptr<password_manager::PasswordFormManager> form_to_save) OVERRIDE; | 49 scoped_ptr<password_manager::PasswordFormManager> form_to_save) OVERRIDE; |
| 47 virtual void AutomaticPasswordSave( | 50 virtual void AutomaticPasswordSave( |
| 48 scoped_ptr<password_manager::PasswordFormManager> saved_form_manager) | 51 scoped_ptr<password_manager::PasswordFormManager> saved_form_manager) |
| 49 OVERRIDE; | 52 OVERRIDE; |
| 50 virtual void PasswordWasAutofilled( | 53 virtual void PasswordWasAutofilled( |
| 51 const autofill::PasswordFormMap& best_matches) const OVERRIDE; | 54 const autofill::PasswordFormMap& best_matches) const OVERRIDE; |
| 52 virtual void PasswordAutofillWasBlocked( | 55 virtual void PasswordAutofillWasBlocked( |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 84 void SetTestObserver(autofill::PasswordGenerationPopupObserver* observer); | 87 void SetTestObserver(autofill::PasswordGenerationPopupObserver* observer); |
| 85 | 88 |
| 86 // 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 |
| 87 // the sad old Infobar UI. | 90 // the sad old Infobar UI. |
| 88 static bool IsTheHotNewBubbleUIEnabled(); | 91 static bool IsTheHotNewBubbleUIEnabled(); |
| 89 | 92 |
| 90 // 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. |
| 91 static bool EnabledForSyncSignin(); | 94 static bool EnabledForSyncSignin(); |
| 92 | 95 |
| 93 private: | 96 private: |
| 97 enum AutofillForSyncCredentialsState { | |
| 98 ALLOW_SYNC_CREDENTIALS, | |
| 99 DISALLOW_SYNC_CREDENTIALS_FOR_REAUTH, | |
| 100 DISALLOW_SYNC_CREDENTIALS, | |
| 101 }; | |
| 102 | |
| 94 ChromePasswordManagerClient(content::WebContents* web_contents, | 103 ChromePasswordManagerClient(content::WebContents* web_contents, |
| 95 autofill::AutofillClient* autofill_client); | 104 autofill::AutofillClient* autofill_client); |
| 96 friend class content::WebContentsUserData<ChromePasswordManagerClient>; | 105 friend class content::WebContentsUserData<ChromePasswordManagerClient>; |
| 106 FRIEND_TEST_ALL_PREFIXES(ChromePasswordManagerClientTest, | |
| 107 LastLoadWasTransactionalReauthPage); | |
|
Ilya Sherman
2014/08/12 02:17:32
Can you test the public API, rather than testing a
Garrett Casto
2014/08/13 20:34:40
Done.
| |
| 97 | 108 |
| 98 // content::WebContentsObserver overrides. | 109 // content::WebContentsObserver overrides. |
| 99 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 110 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 100 | 111 |
| 101 // Callback method to be triggered when authentication is successful for a | 112 // Callback method to be triggered when authentication is successful for a |
| 102 // given password authentication request. If authentication is disabled or | 113 // given password authentication request. If authentication is disabled or |
| 103 // not supported, this will be triggered directly. | 114 // not supported, this will be triggered directly. |
| 104 void CommitFillPasswordForm(autofill::PasswordFormFillData* fill_data); | 115 void CommitFillPasswordForm(autofill::PasswordFormFillData* fill_data); |
| 105 | 116 |
| 106 // Given |bounds| in the renderers coordinate system, return the same bounds | 117 // Given |bounds| in the renderers coordinate system, return the same bounds |
| 107 // in the screens coordinate system. | 118 // in the screens coordinate system. |
| 108 gfx::RectF GetBoundsInScreenSpace(const gfx::RectF& bounds); | 119 gfx::RectF GetBoundsInScreenSpace(const gfx::RectF& bounds); |
| 109 | 120 |
| 110 // Causes the password generation UI to be shown for the specified form. | 121 // Causes the password generation UI to be shown for the specified form. |
| 111 // The popup will be anchored at |element_bounds|. The generated password | 122 // The popup will be anchored at |element_bounds|. The generated password |
| 112 // will be no longer than |max_length|. | 123 // will be no longer than |max_length|. |
| 113 void ShowPasswordGenerationPopup(const gfx::RectF& bounds, | 124 void ShowPasswordGenerationPopup(const gfx::RectF& bounds, |
| 114 int max_length, | 125 int max_length, |
| 115 const autofill::PasswordForm& form); | 126 const autofill::PasswordForm& form); |
| 116 | 127 |
| 117 // Causes the password editing UI to be shown anchored at |element_bounds|. | 128 // Causes the password editing UI to be shown anchored at |element_bounds|. |
| 118 void ShowPasswordEditingPopup( | 129 void ShowPasswordEditingPopup( |
| 119 const gfx::RectF& bounds, const autofill::PasswordForm& form); | 130 const gfx::RectF& bounds, const autofill::PasswordForm& form); |
| 120 | 131 |
| 121 // Sends a message to the renderer with the current value of | 132 // Sends a message to the renderer with the current value of |
| 122 // |can_use_log_router_|. | 133 // |can_use_log_router_|. |
| 123 void NotifyRendererOfLoggingAvailability(); | 134 void NotifyRendererOfLoggingAvailability(); |
| 124 | 135 |
| 136 // Returns true if the last loaded page was for transactional re-auth on a | |
| 137 // Google property. | |
| 138 bool LastLoadWasTransactionalReauthPage() const; | |
| 139 | |
| 140 // Sets |autofill_state_| based on experiment and flag values. | |
| 141 void SetupAutofillSyncState(); | |
|
Ilya Sherman
2014/08/12 02:17:32
nit: "Setup" -> "SetUp". "setup" is a noun; "set
Garrett Casto
2014/08/13 20:34:40
Done.
| |
| 142 | |
| 125 Profile* const profile_; | 143 Profile* const profile_; |
| 126 | 144 |
| 127 password_manager::ContentPasswordManagerDriver driver_; | 145 password_manager::ContentPasswordManagerDriver driver_; |
| 128 | 146 |
| 129 // Observer for password generation popup. | 147 // Observer for password generation popup. |
| 130 autofill::PasswordGenerationPopupObserver* observer_; | 148 autofill::PasswordGenerationPopupObserver* observer_; |
| 131 | 149 |
| 132 // Controls the popup | 150 // Controls the popup |
| 133 base::WeakPtr< | 151 base::WeakPtr< |
| 134 autofill::PasswordGenerationPopupControllerImpl> popup_controller_; | 152 autofill::PasswordGenerationPopupControllerImpl> popup_controller_; |
| 135 | 153 |
| 136 // Allows authentication callbacks to be destroyed when this client is gone. | 154 // Allows authentication callbacks to be destroyed when this client is gone. |
| 137 base::WeakPtrFactory<ChromePasswordManagerClient> weak_factory_; | 155 base::WeakPtrFactory<ChromePasswordManagerClient> weak_factory_; |
| 138 | 156 |
| 139 // True if |this| is registered with some LogRouter which can accept logs. | 157 // True if |this| is registered with some LogRouter which can accept logs. |
| 140 bool can_use_log_router_; | 158 bool can_use_log_router_; |
| 141 | 159 |
| 160 AutofillForSyncCredentialsState autofill_state_; | |
|
Ilya Sherman
2014/08/12 02:17:33
nit: Please document this variable. Also, "autofi
Garrett Casto
2014/08/13 20:34:40
Done.
| |
| 161 | |
| 142 DISALLOW_COPY_AND_ASSIGN(ChromePasswordManagerClient); | 162 DISALLOW_COPY_AND_ASSIGN(ChromePasswordManagerClient); |
| 143 }; | 163 }; |
| 144 | 164 |
| 145 #endif // CHROME_BROWSER_PASSWORD_MANAGER_CHROME_PASSWORD_MANAGER_CLIENT_H_ | 165 #endif // CHROME_BROWSER_PASSWORD_MANAGER_CHROME_PASSWORD_MANAGER_CLIENT_H_ |
| OLD | NEW |