| 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 COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_STORE_H_ | 5 #ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_STORE_H_ |
| 6 #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_STORE_H_ | 6 #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_STORE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 // Implementations, however, should carry out most tasks asynchronously on a | 48 // Implementations, however, should carry out most tasks asynchronously on a |
| 49 // background thread: the base class provides functionality to facilitate this. | 49 // background thread: the base class provides functionality to facilitate this. |
| 50 // I/O heavy initialization should also be performed asynchronously in this | 50 // I/O heavy initialization should also be performed asynchronously in this |
| 51 // manner. If this deferred initialization fails, all subsequent method calls | 51 // manner. If this deferred initialization fails, all subsequent method calls |
| 52 // should fail without side effects, return no data, and send no notifications. | 52 // should fail without side effects, return no data, and send no notifications. |
| 53 // PasswordStoreSync is a hidden base class because only PasswordSyncableService | 53 // PasswordStoreSync is a hidden base class because only PasswordSyncableService |
| 54 // needs to access these methods. | 54 // needs to access these methods. |
| 55 class PasswordStore : protected PasswordStoreSync, | 55 class PasswordStore : protected PasswordStoreSync, |
| 56 public RefcountedKeyedService { | 56 public RefcountedKeyedService { |
| 57 public: | 57 public: |
| 58 // Whether or not it's acceptable for Chrome to request access to locked | |
| 59 // passwords, which requires prompting the user for permission. | |
| 60 enum AuthorizationPromptPolicy { ALLOW_PROMPT, DISALLOW_PROMPT }; | |
| 61 | |
| 62 // An interface used to notify clients (observers) of this object that data in | 58 // An interface used to notify clients (observers) of this object that data in |
| 63 // the password store has changed. Register the observer via | 59 // the password store has changed. Register the observer via |
| 64 // PasswordStore::AddObserver. | 60 // PasswordStore::AddObserver. |
| 65 class Observer { | 61 class Observer { |
| 66 public: | 62 public: |
| 67 // Notifies the observer that password data changed. Will be called from | 63 // Notifies the observer that password data changed. Will be called from |
| 68 // the UI thread. | 64 // the UI thread. |
| 69 virtual void OnLoginsChanged(const PasswordStoreChangeList& changes) = 0; | 65 virtual void OnLoginsChanged(const PasswordStoreChangeList& changes) = 0; |
| 70 | 66 |
| 71 protected: | 67 protected: |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 void RemoveStatisticsCreatedBetween(base::Time delete_begin, | 137 void RemoveStatisticsCreatedBetween(base::Time delete_begin, |
| 142 base::Time delete_end, | 138 base::Time delete_end, |
| 143 const base::Closure& completion); | 139 const base::Closure& completion); |
| 144 | 140 |
| 145 // Removes cached affiliation data that is no longer needed; provided that | 141 // Removes cached affiliation data that is no longer needed; provided that |
| 146 // affiliation-based matching is enabled. | 142 // affiliation-based matching is enabled. |
| 147 void TrimAffiliationCache(); | 143 void TrimAffiliationCache(); |
| 148 | 144 |
| 149 // Searches for a matching PasswordForm, and notifies |consumer| on | 145 // Searches for a matching PasswordForm, and notifies |consumer| on |
| 150 // completion. The request will be cancelled if the consumer is destroyed. | 146 // completion. The request will be cancelled if the consumer is destroyed. |
| 151 // |prompt_policy| indicates whether it's permissible to prompt the user to | |
| 152 // authorize access to locked passwords. This argument is only used on | |
| 153 // platforms that support prompting the user for access (such as Mac OS). | |
| 154 // NOTE: This means that this method can return different results depending | |
| 155 // on the value of |prompt_policy|. | |
| 156 // TODO(engedy): Currently, this will not return federated logins saved from | 147 // TODO(engedy): Currently, this will not return federated logins saved from |
| 157 // Android applications that are affiliated with the realm of |form|. Need to | 148 // Android applications that are affiliated with the realm of |form|. Need to |
| 158 // decide if this is the desired behavior. See: https://crbug.com/539844. | 149 // decide if this is the desired behavior. See: https://crbug.com/539844. |
| 159 virtual void GetLogins(const autofill::PasswordForm& form, | 150 virtual void GetLogins(const autofill::PasswordForm& form, |
| 160 AuthorizationPromptPolicy prompt_policy, | |
| 161 PasswordStoreConsumer* consumer); | 151 PasswordStoreConsumer* consumer); |
| 162 | 152 |
| 163 // Gets the complete list of PasswordForms that are not blacklist entries--and | 153 // Gets the complete list of PasswordForms that are not blacklist entries--and |
| 164 // are thus auto-fillable. |consumer| will be notified on completion. | 154 // are thus auto-fillable. |consumer| will be notified on completion. |
| 165 // The request will be cancelled if the consumer is destroyed. | 155 // The request will be cancelled if the consumer is destroyed. |
| 166 virtual void GetAutofillableLogins(PasswordStoreConsumer* consumer); | 156 virtual void GetAutofillableLogins(PasswordStoreConsumer* consumer); |
| 167 | 157 |
| 168 // Gets the complete list of PasswordForms that are blacklist entries, | 158 // Gets the complete list of PasswordForms that are blacklist entries, |
| 169 // and notify |consumer| on completion. The request will be cancelled if the | 159 // and notify |consumer| on completion. The request will be cancelled if the |
| 170 // consumer is destroyed. | 160 // consumer is destroyed. |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 virtual bool RemoveStatisticsCreatedBetweenImpl(base::Time delete_begin, | 255 virtual bool RemoveStatisticsCreatedBetweenImpl(base::Time delete_begin, |
| 266 base::Time delete_end) = 0; | 256 base::Time delete_end) = 0; |
| 267 | 257 |
| 268 // Finds all PasswordForms with a signon_realm that is equal to, or is a | 258 // Finds all PasswordForms with a signon_realm that is equal to, or is a |
| 269 // PSL-match to that of |form|, and takes care of notifying the consumer with | 259 // PSL-match to that of |form|, and takes care of notifying the consumer with |
| 270 // the results when done. | 260 // the results when done. |
| 271 // Note: subclasses should implement FillMatchingLogins() instead. This needs | 261 // Note: subclasses should implement FillMatchingLogins() instead. This needs |
| 272 // to be virtual only because asynchronous behavior in PasswordStoreWin. | 262 // to be virtual only because asynchronous behavior in PasswordStoreWin. |
| 273 // TODO(engedy): Make this non-virtual once https://crbug.com/78830 is fixed. | 263 // TODO(engedy): Make this non-virtual once https://crbug.com/78830 is fixed. |
| 274 virtual void GetLoginsImpl(const autofill::PasswordForm& form, | 264 virtual void GetLoginsImpl(const autofill::PasswordForm& form, |
| 275 AuthorizationPromptPolicy prompt_policy, | |
| 276 scoped_ptr<GetLoginsRequest> request); | 265 scoped_ptr<GetLoginsRequest> request); |
| 277 | 266 |
| 278 // Synchronous implementation provided by subclasses to add the given login. | 267 // Synchronous implementation provided by subclasses to add the given login. |
| 279 virtual PasswordStoreChangeList AddLoginImpl( | 268 virtual PasswordStoreChangeList AddLoginImpl( |
| 280 const autofill::PasswordForm& form) = 0; | 269 const autofill::PasswordForm& form) = 0; |
| 281 | 270 |
| 282 // Synchronous implementation provided by subclasses to update the given | 271 // Synchronous implementation provided by subclasses to update the given |
| 283 // login. | 272 // login. |
| 284 virtual PasswordStoreChangeList UpdateLoginImpl( | 273 virtual PasswordStoreChangeList UpdateLoginImpl( |
| 285 const autofill::PasswordForm& form) = 0; | 274 const autofill::PasswordForm& form) = 0; |
| 286 | 275 |
| 287 // Synchronous implementation provided by subclasses to remove the given | 276 // Synchronous implementation provided by subclasses to remove the given |
| 288 // login. | 277 // login. |
| 289 virtual PasswordStoreChangeList RemoveLoginImpl( | 278 virtual PasswordStoreChangeList RemoveLoginImpl( |
| 290 const autofill::PasswordForm& form) = 0; | 279 const autofill::PasswordForm& form) = 0; |
| 291 | 280 |
| 292 // Finds and returns all PasswordForms with the same signon_realm as |form|, | 281 // Finds and returns all PasswordForms with the same signon_realm as |form|, |
| 293 // or with a signon_realm that is a PSL-match to that of |form|. | 282 // or with a signon_realm that is a PSL-match to that of |form|. |
| 294 virtual ScopedVector<autofill::PasswordForm> FillMatchingLogins( | 283 virtual ScopedVector<autofill::PasswordForm> FillMatchingLogins( |
| 295 const autofill::PasswordForm& form, | 284 const autofill::PasswordForm& form) = 0; |
| 296 AuthorizationPromptPolicy prompt_policy) = 0; | |
| 297 | 285 |
| 298 // Synchronous implementation for manipulating with statistics. | 286 // Synchronous implementation for manipulating with statistics. |
| 299 virtual void AddSiteStatsImpl(const InteractionsStats& stats) = 0; | 287 virtual void AddSiteStatsImpl(const InteractionsStats& stats) = 0; |
| 300 virtual void RemoveSiteStatsImpl(const GURL& origin_domain) = 0; | 288 virtual void RemoveSiteStatsImpl(const GURL& origin_domain) = 0; |
| 301 virtual std::vector<scoped_ptr<InteractionsStats>> GetSiteStatsImpl( | 289 virtual std::vector<scoped_ptr<InteractionsStats>> GetSiteStatsImpl( |
| 302 const GURL& origin_domain) = 0; | 290 const GURL& origin_domain) = 0; |
| 303 | 291 |
| 304 // Log UMA stats for number of bulk deletions. | 292 // Log UMA stats for number of bulk deletions. |
| 305 void LogStatsForBulkDeletion(int num_deletions); | 293 void LogStatsForBulkDeletion(int num_deletions); |
| 306 | 294 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 | 367 |
| 380 // Extended version of GetLoginsImpl that also returns credentials stored for | 368 // Extended version of GetLoginsImpl that also returns credentials stored for |
| 381 // the specified affiliated Android applications. That is, it finds all | 369 // the specified affiliated Android applications. That is, it finds all |
| 382 // PasswordForms with a signon_realm that is either: | 370 // PasswordForms with a signon_realm that is either: |
| 383 // * equal to that of |form|, | 371 // * equal to that of |form|, |
| 384 // * is a PSL-match to the realm of |form|, | 372 // * is a PSL-match to the realm of |form|, |
| 385 // * is one of those in |additional_android_realms|, | 373 // * is one of those in |additional_android_realms|, |
| 386 // and takes care of notifying the consumer with the results when done. | 374 // and takes care of notifying the consumer with the results when done. |
| 387 void GetLoginsWithAffiliationsImpl( | 375 void GetLoginsWithAffiliationsImpl( |
| 388 const autofill::PasswordForm& form, | 376 const autofill::PasswordForm& form, |
| 389 AuthorizationPromptPolicy prompt_policy, | |
| 390 scoped_ptr<GetLoginsRequest> request, | 377 scoped_ptr<GetLoginsRequest> request, |
| 391 const std::vector<std::string>& additional_android_realms); | 378 const std::vector<std::string>& additional_android_realms); |
| 392 | 379 |
| 393 // Schedules GetLoginsWithAffiliationsImpl() to be run on the DB thread. | 380 // Schedules GetLoginsWithAffiliationsImpl() to be run on the DB thread. |
| 394 void ScheduleGetLoginsWithAffiliations( | 381 void ScheduleGetLoginsWithAffiliations( |
| 395 const autofill::PasswordForm& form, | 382 const autofill::PasswordForm& form, |
| 396 AuthorizationPromptPolicy prompt_policy, | |
| 397 scoped_ptr<GetLoginsRequest> request, | 383 scoped_ptr<GetLoginsRequest> request, |
| 398 const std::vector<std::string>& additional_android_realms); | 384 const std::vector<std::string>& additional_android_realms); |
| 399 | 385 |
| 400 // Retrieves the currently stored form, if any, with the same primary key as | 386 // Retrieves the currently stored form, if any, with the same primary key as |
| 401 // |form|, that is, with the same signon_realm, origin, username_element, | 387 // |form|, that is, with the same signon_realm, origin, username_element, |
| 402 // username_value and password_element attributes. To be called on the | 388 // username_value and password_element attributes. To be called on the |
| 403 // background thread. | 389 // background thread. |
| 404 scoped_ptr<autofill::PasswordForm> GetLoginImpl( | 390 scoped_ptr<autofill::PasswordForm> GetLoginImpl( |
| 405 const autofill::PasswordForm& primary_key); | 391 const autofill::PasswordForm& primary_key); |
| 406 | 392 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 bool is_propagating_password_changes_to_web_credentials_enabled_; | 430 bool is_propagating_password_changes_to_web_credentials_enabled_; |
| 445 | 431 |
| 446 bool shutdown_called_; | 432 bool shutdown_called_; |
| 447 | 433 |
| 448 DISALLOW_COPY_AND_ASSIGN(PasswordStore); | 434 DISALLOW_COPY_AND_ASSIGN(PasswordStore); |
| 449 }; | 435 }; |
| 450 | 436 |
| 451 } // namespace password_manager | 437 } // namespace password_manager |
| 452 | 438 |
| 453 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_STORE_H_ | 439 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_STORE_H_ |
| OLD | NEW |