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_password_manager_d river.h" | 10 #include "components/password_manager/content/browser/content_password_manager_d river.h" |
(...skipping 22 matching lines...) Expand all Loading... | |
33 class ChromePasswordManagerClient | 33 class ChromePasswordManagerClient |
34 : public password_manager::PasswordManagerClient, | 34 : public password_manager::PasswordManagerClient, |
35 public content::WebContentsObserver, | 35 public content::WebContentsObserver, |
36 public content::WebContentsUserData<ChromePasswordManagerClient> { | 36 public content::WebContentsUserData<ChromePasswordManagerClient> { |
37 public: | 37 public: |
38 virtual ~ChromePasswordManagerClient(); | 38 virtual ~ChromePasswordManagerClient(); |
39 | 39 |
40 // PasswordManagerClient implementation. | 40 // PasswordManagerClient implementation. |
41 virtual bool IsAutomaticPasswordSavingEnabled() const OVERRIDE; | 41 virtual bool IsAutomaticPasswordSavingEnabled() const OVERRIDE; |
42 virtual bool IsPasswordManagerEnabledForCurrentPage() const OVERRIDE; | 42 virtual bool IsPasswordManagerEnabledForCurrentPage() const OVERRIDE; |
43 virtual bool ShouldFilterAutofillResult( | |
44 const autofill::PasswordForm& form) OVERRIDE; | |
43 virtual bool IsSyncAccountCredential( | 45 virtual bool IsSyncAccountCredential( |
44 const std::string& username, const std::string& origin) const OVERRIDE; | 46 const std::string& username, const std::string& origin) const OVERRIDE; |
47 virtual void AutofillResultsComputed() 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( |
53 const autofill::PasswordFormMap& best_matches) const OVERRIDE; | 56 const autofill::PasswordFormMap& best_matches) const OVERRIDE; |
54 virtual void AuthenticateAutofillAndFillForm( | 57 virtual void AuthenticateAutofillAndFillForm( |
(...skipping 28 matching lines...) Expand all Loading... | |
83 // Observer for PasswordGenerationPopup events. Used for testing. | 86 // Observer for PasswordGenerationPopup events. Used for testing. |
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 protected: |
97 // Callable for tests. | |
94 ChromePasswordManagerClient(content::WebContents* web_contents, | 98 ChromePasswordManagerClient(content::WebContents* web_contents, |
95 autofill::AutofillClient* autofill_client); | 99 autofill::AutofillClient* autofill_client); |
100 | |
101 private: | |
102 enum AutofillForSyncCredentialsState { | |
103 ALLOW_SYNC_CREDENTIALS, | |
104 DISALLOW_SYNC_CREDENTIALS_FOR_REAUTH, | |
105 DISALLOW_SYNC_CREDENTIALS, | |
106 }; | |
107 | |
96 friend class content::WebContentsUserData<ChromePasswordManagerClient>; | 108 friend class content::WebContentsUserData<ChromePasswordManagerClient>; |
97 | 109 |
98 // content::WebContentsObserver overrides. | 110 // content::WebContentsObserver overrides. |
99 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 111 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
100 | 112 |
101 // Callback method to be triggered when authentication is successful for a | 113 // Callback method to be triggered when authentication is successful for a |
102 // given password authentication request. If authentication is disabled or | 114 // given password authentication request. If authentication is disabled or |
103 // not supported, this will be triggered directly. | 115 // not supported, this will be triggered directly. |
104 void CommitFillPasswordForm(autofill::PasswordFormFillData* fill_data); | 116 void CommitFillPasswordForm(autofill::PasswordFormFillData* fill_data); |
105 | 117 |
106 // Given |bounds| in the renderers coordinate system, return the same bounds | 118 // Given |bounds| in the renderers coordinate system, return the same bounds |
107 // in the screens coordinate system. | 119 // in the screens coordinate system. |
108 gfx::RectF GetBoundsInScreenSpace(const gfx::RectF& bounds); | 120 gfx::RectF GetBoundsInScreenSpace(const gfx::RectF& bounds); |
109 | 121 |
110 // Causes the password generation UI to be shown for the specified form. | 122 // Causes the password generation UI to be shown for the specified form. |
111 // The popup will be anchored at |element_bounds|. The generated password | 123 // The popup will be anchored at |element_bounds|. The generated password |
112 // will be no longer than |max_length|. | 124 // will be no longer than |max_length|. |
113 void ShowPasswordGenerationPopup(const gfx::RectF& bounds, | 125 void ShowPasswordGenerationPopup(const gfx::RectF& bounds, |
114 int max_length, | 126 int max_length, |
115 const autofill::PasswordForm& form); | 127 const autofill::PasswordForm& form); |
116 | 128 |
117 // Causes the password editing UI to be shown anchored at |element_bounds|. | 129 // Causes the password editing UI to be shown anchored at |element_bounds|. |
118 void ShowPasswordEditingPopup( | 130 void ShowPasswordEditingPopup( |
119 const gfx::RectF& bounds, const autofill::PasswordForm& form); | 131 const gfx::RectF& bounds, const autofill::PasswordForm& form); |
120 | 132 |
121 // Sends a message to the renderer with the current value of | 133 // Sends a message to the renderer with the current value of |
122 // |can_use_log_router_|. | 134 // |can_use_log_router_|. |
123 void NotifyRendererOfLoggingAvailability(); | 135 void NotifyRendererOfLoggingAvailability(); |
124 | 136 |
137 // Returns true if the last loaded page was for transactional re-auth on a | |
138 // Google property. | |
139 bool LastLoadWasTransactionalReauthPage() const; | |
140 | |
141 // Sets |autofill_state_| based on experiment and flag values. | |
142 void SetUpAutofillSyncState(); | |
143 | |
125 Profile* const profile_; | 144 Profile* const profile_; |
126 | 145 |
127 password_manager::ContentPasswordManagerDriver driver_; | 146 password_manager::ContentPasswordManagerDriver driver_; |
128 | 147 |
129 // Observer for password generation popup. | 148 // Observer for password generation popup. |
130 autofill::PasswordGenerationPopupObserver* observer_; | 149 autofill::PasswordGenerationPopupObserver* observer_; |
131 | 150 |
132 // Controls the popup | 151 // Controls the popup |
133 base::WeakPtr< | 152 base::WeakPtr< |
134 autofill::PasswordGenerationPopupControllerImpl> popup_controller_; | 153 autofill::PasswordGenerationPopupControllerImpl> popup_controller_; |
135 | 154 |
136 // Allows authentication callbacks to be destroyed when this client is gone. | 155 // Allows authentication callbacks to be destroyed when this client is gone. |
137 base::WeakPtrFactory<ChromePasswordManagerClient> weak_factory_; | 156 base::WeakPtrFactory<ChromePasswordManagerClient> weak_factory_; |
138 | 157 |
139 // True if |this| is registered with some LogRouter which can accept logs. | 158 // True if |this| is registered with some LogRouter which can accept logs. |
140 bool can_use_log_router_; | 159 bool can_use_log_router_; |
141 | 160 |
161 // How to handle the sync credential in ShouldFilterAutofillResult(). | |
162 AutofillForSyncCredentialsState autofill_sync_state_; | |
163 | |
164 // If the sync credential was filtered during autofill. Used for statistics | |
165 // reporting. | |
166 bool sync_credential_filtered_; | |
Ilya Sherman
2014/08/14 07:38:14
Optional nit: Perhaps "filtered_" -> "was_filtered
Garrett Casto
2014/08/14 19:48:43
Done.
| |
167 | |
142 DISALLOW_COPY_AND_ASSIGN(ChromePasswordManagerClient); | 168 DISALLOW_COPY_AND_ASSIGN(ChromePasswordManagerClient); |
143 }; | 169 }; |
144 | 170 |
145 #endif // CHROME_BROWSER_PASSWORD_MANAGER_CHROME_PASSWORD_MANAGER_CLIENT_H_ | 171 #endif // CHROME_BROWSER_PASSWORD_MANAGER_CHROME_PASSWORD_MANAGER_CLIENT_H_ |
OLD | NEW |