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 <memory> | 8 #include <memory> |
9 #include <ostream> | 9 #include <ostream> |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "base/observer_list_threadsafe.h" | 16 #include "base/observer_list_threadsafe.h" |
17 #include "base/single_thread_task_runner.h" | 17 #include "base/single_thread_task_runner.h" |
18 #include "base/time/time.h" | 18 #include "base/time/time.h" |
19 #include "components/keyed_service/core/refcounted_keyed_service.h" | 19 #include "components/keyed_service/core/refcounted_keyed_service.h" |
20 #include "components/password_manager/core/browser/password_reuse_detector.h" | |
21 #include "components/password_manager/core/browser/password_reuse_detector_consu
mer.h" | |
22 #include "components/password_manager/core/browser/password_store_change.h" | 20 #include "components/password_manager/core/browser/password_store_change.h" |
23 #include "components/password_manager/core/browser/password_store_sync.h" | 21 #include "components/password_manager/core/browser/password_store_sync.h" |
24 #include "components/sync/model/syncable_service.h" | 22 #include "components/sync/model/syncable_service.h" |
25 | 23 |
| 24 // TODO(crbug.com/706392): Fix password reuse detection for Android. |
| 25 #if !defined(OS_ANDROID) && !defined(OS_IOS) |
| 26 #include "components/password_manager/core/browser/password_reuse_detector.h" |
| 27 #include "components/password_manager/core/browser/password_reuse_detector_consu
mer.h" |
| 28 #endif |
| 29 |
26 class PasswordStoreProxyMac; | 30 class PasswordStoreProxyMac; |
27 | 31 |
28 namespace autofill { | 32 namespace autofill { |
29 struct PasswordForm; | 33 struct PasswordForm; |
30 } | 34 } |
31 | 35 |
32 namespace syncer { | 36 namespace syncer { |
33 class SyncableService; | 37 class SyncableService; |
34 } | 38 } |
35 | 39 |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 void AddObserver(Observer* observer); | 224 void AddObserver(Observer* observer); |
221 | 225 |
222 // Removes |observer| from the observer list. | 226 // Removes |observer| from the observer list. |
223 void RemoveObserver(Observer* observer); | 227 void RemoveObserver(Observer* observer); |
224 | 228 |
225 // Schedules the given |task| to be run on the PasswordStore's TaskRunner. | 229 // Schedules the given |task| to be run on the PasswordStore's TaskRunner. |
226 bool ScheduleTask(const base::Closure& task); | 230 bool ScheduleTask(const base::Closure& task); |
227 | 231 |
228 base::WeakPtr<syncer::SyncableService> GetPasswordSyncableService(); | 232 base::WeakPtr<syncer::SyncableService> GetPasswordSyncableService(); |
229 | 233 |
| 234 // TODO(crbug.com/706392): Fix password reuse detection for Android. |
| 235 #if !defined(OS_ANDROID) && !defined(OS_IOS) |
230 // Checks that some suffix of |input| equals to a password saved on another | 236 // Checks that some suffix of |input| equals to a password saved on another |
231 // registry controlled domain than |domain|. | 237 // registry controlled domain than |domain|. |
232 // If such suffix is found, |consumer|->OnReuseFound() is called on the same | 238 // If such suffix is found, |consumer|->OnReuseFound() is called on the same |
233 // thread on which this method is called. | 239 // thread on which this method is called. |
234 // |consumer| must not be null. | 240 // |consumer| must not be null. |
235 virtual void CheckReuse(const base::string16& input, | 241 virtual void CheckReuse(const base::string16& input, |
236 const std::string& domain, | 242 const std::string& domain, |
237 PasswordReuseDetectorConsumer* consumer); | 243 PasswordReuseDetectorConsumer* consumer); |
| 244 #endif |
238 | 245 |
239 protected: | 246 protected: |
240 friend class base::RefCountedThreadSafe<PasswordStore>; | 247 friend class base::RefCountedThreadSafe<PasswordStore>; |
241 | 248 |
242 typedef base::Callback<PasswordStoreChangeList(void)> ModificationTask; | 249 typedef base::Callback<PasswordStoreChangeList(void)> ModificationTask; |
243 | 250 |
244 // Represents a single GetLogins() request. Implements functionality to filter | 251 // Represents a single GetLogins() request. Implements functionality to filter |
245 // results and send them to the consumer on the consumer's message loop. | 252 // results and send them to the consumer on the consumer's message loop. |
246 class GetLoginsRequest { | 253 class GetLoginsRequest { |
247 public: | 254 public: |
(...skipping 16 matching lines...) Expand all Loading... |
264 private: | 271 private: |
265 // See GetLogins(). Logins older than this will be removed from the reply. | 272 // See GetLogins(). Logins older than this will be removed from the reply. |
266 base::Time ignore_logins_cutoff_; | 273 base::Time ignore_logins_cutoff_; |
267 | 274 |
268 scoped_refptr<base::SingleThreadTaskRunner> origin_task_runner_; | 275 scoped_refptr<base::SingleThreadTaskRunner> origin_task_runner_; |
269 base::WeakPtr<PasswordStoreConsumer> consumer_weak_; | 276 base::WeakPtr<PasswordStoreConsumer> consumer_weak_; |
270 | 277 |
271 DISALLOW_COPY_AND_ASSIGN(GetLoginsRequest); | 278 DISALLOW_COPY_AND_ASSIGN(GetLoginsRequest); |
272 }; | 279 }; |
273 | 280 |
| 281 // TODO(crbug.com/706392): Fix password reuse detection for Android. |
| 282 #if !defined(OS_ANDROID) && !defined(OS_IOS) |
274 // Represents a single CheckReuse() request. Implements functionality to | 283 // Represents a single CheckReuse() request. Implements functionality to |
275 // listen to reuse events and propagate them to |consumer| on the thread on | 284 // listen to reuse events and propagate them to |consumer| on the thread on |
276 // which CheckReuseRequest is created. | 285 // which CheckReuseRequest is created. |
277 class CheckReuseRequest : public PasswordReuseDetectorConsumer { | 286 class CheckReuseRequest : public PasswordReuseDetectorConsumer { |
278 public: | 287 public: |
279 // |consumer| must not be null. | 288 // |consumer| must not be null. |
280 explicit CheckReuseRequest(PasswordReuseDetectorConsumer* consumer); | 289 explicit CheckReuseRequest(PasswordReuseDetectorConsumer* consumer); |
281 ~CheckReuseRequest() override; | 290 ~CheckReuseRequest() override; |
282 | 291 |
283 // PasswordReuseDetectorConsumer | 292 // PasswordReuseDetectorConsumer |
284 void OnReuseFound(const base::string16& password, | 293 void OnReuseFound(const base::string16& password, |
285 const std::string& saved_domain, | 294 const std::string& saved_domain, |
286 int saved_passwords, | 295 int saved_passwords, |
287 int number_matches) override; | 296 int number_matches) override; |
288 | 297 |
289 private: | 298 private: |
290 const scoped_refptr<base::SingleThreadTaskRunner> origin_task_runner_; | 299 const scoped_refptr<base::SingleThreadTaskRunner> origin_task_runner_; |
291 const base::WeakPtr<PasswordReuseDetectorConsumer> consumer_weak_; | 300 const base::WeakPtr<PasswordReuseDetectorConsumer> consumer_weak_; |
292 | 301 |
293 DISALLOW_COPY_AND_ASSIGN(CheckReuseRequest); | 302 DISALLOW_COPY_AND_ASSIGN(CheckReuseRequest); |
294 }; | 303 }; |
| 304 #endif |
295 | 305 |
296 ~PasswordStore() override; | 306 ~PasswordStore() override; |
297 | 307 |
298 // Get the TaskRunner to use for PasswordStore background tasks. | 308 // Get the TaskRunner to use for PasswordStore background tasks. |
299 // By default, a SingleThreadTaskRunner on the DB thread is used, but | 309 // By default, a SingleThreadTaskRunner on the DB thread is used, but |
300 // subclasses can override. | 310 // subclasses can override. |
301 virtual scoped_refptr<base::SingleThreadTaskRunner> GetBackgroundTaskRunner(); | 311 virtual scoped_refptr<base::SingleThreadTaskRunner> GetBackgroundTaskRunner(); |
302 | 312 |
303 // Methods below will be run in PasswordStore's own thread. | 313 // Methods below will be run in PasswordStore's own thread. |
304 // Synchronous implementation that reports usage metrics. | 314 // Synchronous implementation that reports usage metrics. |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 PasswordStoreChangeList UpdateLoginSync( | 389 PasswordStoreChangeList UpdateLoginSync( |
380 const autofill::PasswordForm& form) override; | 390 const autofill::PasswordForm& form) override; |
381 PasswordStoreChangeList RemoveLoginSync( | 391 PasswordStoreChangeList RemoveLoginSync( |
382 const autofill::PasswordForm& form) override; | 392 const autofill::PasswordForm& form) override; |
383 | 393 |
384 // Called by WrapModificationTask() once the underlying data-modifying | 394 // Called by WrapModificationTask() once the underlying data-modifying |
385 // operation has been performed. Notifies observers that password store data | 395 // operation has been performed. Notifies observers that password store data |
386 // may have been changed. | 396 // may have been changed. |
387 void NotifyLoginsChanged(const PasswordStoreChangeList& changes) override; | 397 void NotifyLoginsChanged(const PasswordStoreChangeList& changes) override; |
388 | 398 |
| 399 // TODO(crbug.com/706392): Fix password reuse detection for Android. |
| 400 #if !defined(OS_ANDROID) && !defined(OS_IOS) |
389 // Synchronous implementation of CheckReuse(). | 401 // Synchronous implementation of CheckReuse(). |
390 void CheckReuseImpl(std::unique_ptr<CheckReuseRequest> request, | 402 void CheckReuseImpl(std::unique_ptr<CheckReuseRequest> request, |
391 const base::string16& input, | 403 const base::string16& input, |
392 const std::string& domain); | 404 const std::string& domain); |
| 405 #endif |
393 | 406 |
394 // TaskRunner for tasks that run on the main thread (usually the UI thread). | 407 // TaskRunner for tasks that run on the main thread (usually the UI thread). |
395 scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner_; | 408 scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner_; |
396 | 409 |
397 // TaskRunner for the DB thread. By default, this is the task runner used for | 410 // TaskRunner for the DB thread. By default, this is the task runner used for |
398 // background tasks -- see |GetBackgroundTaskRunner|. | 411 // background tasks -- see |GetBackgroundTaskRunner|. |
399 scoped_refptr<base::SingleThreadTaskRunner> db_thread_runner_; | 412 scoped_refptr<base::SingleThreadTaskRunner> db_thread_runner_; |
400 | 413 |
401 private: | 414 private: |
402 FRIEND_TEST_ALL_PREFIXES(PasswordStoreTest, GetLoginImpl); | 415 FRIEND_TEST_ALL_PREFIXES(PasswordStoreTest, GetLoginImpl); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 const syncer::SyncableService::StartSyncFlare& flare); | 547 const syncer::SyncableService::StartSyncFlare& flare); |
535 | 548 |
536 // Deletes objest that should be destroyed on the background thread. | 549 // Deletes objest that should be destroyed on the background thread. |
537 void DestroyOnBackgroundThread(); | 550 void DestroyOnBackgroundThread(); |
538 | 551 |
539 // The observers. | 552 // The observers. |
540 scoped_refptr<base::ObserverListThreadSafe<Observer>> observers_; | 553 scoped_refptr<base::ObserverListThreadSafe<Observer>> observers_; |
541 | 554 |
542 std::unique_ptr<PasswordSyncableService> syncable_service_; | 555 std::unique_ptr<PasswordSyncableService> syncable_service_; |
543 std::unique_ptr<AffiliatedMatchHelper> affiliated_match_helper_; | 556 std::unique_ptr<AffiliatedMatchHelper> affiliated_match_helper_; |
| 557 // TODO(crbug.com/706392): Fix password reuse detection for Android. |
| 558 #if !defined(OS_ANDROID) && !defined(OS_IOS) |
544 std::unique_ptr<PasswordReuseDetector> reuse_detector_; | 559 std::unique_ptr<PasswordReuseDetector> reuse_detector_; |
| 560 #endif |
545 bool is_propagating_password_changes_to_web_credentials_enabled_; | 561 bool is_propagating_password_changes_to_web_credentials_enabled_; |
546 | 562 |
547 bool shutdown_called_; | 563 bool shutdown_called_; |
548 | 564 |
549 DISALLOW_COPY_AND_ASSIGN(PasswordStore); | 565 DISALLOW_COPY_AND_ASSIGN(PasswordStore); |
550 }; | 566 }; |
551 | 567 |
552 // For logging only. | 568 // For logging only. |
553 std::ostream& operator<<(std::ostream& os, | 569 std::ostream& operator<<(std::ostream& os, |
554 const PasswordStore::FormDigest& digest); | 570 const PasswordStore::FormDigest& digest); |
555 | 571 |
556 } // namespace password_manager | 572 } // namespace password_manager |
557 | 573 |
558 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_STORE_H_ | 574 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_STORE_H_ |
OLD | NEW |