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) const 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; |
45 virtual void PromptUserToSavePassword( | 47 virtual void PromptUserToSavePassword( |
46 scoped_ptr<password_manager::PasswordFormManager> form_to_save) OVERRIDE; | 48 scoped_ptr<password_manager::PasswordFormManager> form_to_save) OVERRIDE; |
47 virtual void AutomaticPasswordSave( | 49 virtual void AutomaticPasswordSave( |
48 scoped_ptr<password_manager::PasswordFormManager> saved_form_manager) | 50 scoped_ptr<password_manager::PasswordFormManager> saved_form_manager) |
49 OVERRIDE; | 51 OVERRIDE; |
50 virtual void PasswordWasAutofilled( | 52 virtual void PasswordWasAutofilled( |
51 const autofill::PasswordFormMap& best_matches) const OVERRIDE; | 53 const autofill::PasswordFormMap& best_matches) const OVERRIDE; |
52 virtual void PasswordAutofillWasBlocked( | 54 virtual void PasswordAutofillWasBlocked( |
(...skipping 30 matching lines...) Expand all Loading... |
83 // Observer for PasswordGenerationPopup events. Used for testing. | 85 // Observer for PasswordGenerationPopup events. Used for testing. |
84 void SetTestObserver(autofill::PasswordGenerationPopupObserver* observer); | 86 void SetTestObserver(autofill::PasswordGenerationPopupObserver* observer); |
85 | 87 |
86 // Returns true if the bubble UI is enabled, and false if we're still using | 88 // Returns true if the bubble UI is enabled, and false if we're still using |
87 // the sad old Infobar UI. | 89 // the sad old Infobar UI. |
88 static bool IsTheHotNewBubbleUIEnabled(); | 90 static bool IsTheHotNewBubbleUIEnabled(); |
89 | 91 |
90 // Returns true if the password manager should be enabled during sync signin. | 92 // Returns true if the password manager should be enabled during sync signin. |
91 static bool EnabledForSyncSignin(); | 93 static bool EnabledForSyncSignin(); |
92 | 94 |
93 private: | 95 protected: |
| 96 // Callable for tests. |
94 ChromePasswordManagerClient(content::WebContents* web_contents, | 97 ChromePasswordManagerClient(content::WebContents* web_contents, |
95 autofill::AutofillClient* autofill_client); | 98 autofill::AutofillClient* autofill_client); |
| 99 |
| 100 private: |
| 101 enum AutofillForSyncCredentialsState { |
| 102 ALLOW_SYNC_CREDENTIALS, |
| 103 DISALLOW_SYNC_CREDENTIALS_FOR_REAUTH, |
| 104 DISALLOW_SYNC_CREDENTIALS, |
| 105 }; |
| 106 |
96 friend class content::WebContentsUserData<ChromePasswordManagerClient>; | 107 friend class content::WebContentsUserData<ChromePasswordManagerClient>; |
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(); |
| 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 // How to handle the sync credential in ShouldFilterAutofillResult(). |
| 161 AutofillForSyncCredentialsState autofill_sync_state_; |
| 162 |
142 DISALLOW_COPY_AND_ASSIGN(ChromePasswordManagerClient); | 163 DISALLOW_COPY_AND_ASSIGN(ChromePasswordManagerClient); |
143 }; | 164 }; |
144 | 165 |
145 #endif // CHROME_BROWSER_PASSWORD_MANAGER_CHROME_PASSWORD_MANAGER_CLIENT_H_ | 166 #endif // CHROME_BROWSER_PASSWORD_MANAGER_CHROME_PASSWORD_MANAGER_CLIENT_H_ |
OLD | NEW |