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