Bug 1861467 - [wpt-sync] Update web-platform-tests to eedf737ce39c512d0ca3471f988972e...
[gecko.git] / dom / ipc / LoginDetectionService.h
blobb0fd17085533adc5cfb847dc740af9d6cc4d302e
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_LoginDetectionService_h
8 #define mozilla_dom_LoginDetectionService_h
10 #include "nsIObserver.h"
11 #include "nsIObserverService.h"
12 #include "nsILoginDetectionService.h"
13 #include "nsILoginManager.h"
14 #include "nsWeakReference.h"
15 #include "mozilla/Logging.h"
16 #include "mozilla/Preferences.h"
18 namespace mozilla::dom {
20 /**
21 * Detect whether the user is 'possibly' logged in to a site, and add the
22 * HighValue permission to the permission manager. We say 'possibly' because
23 * the detection is done in a very loose way. For example, for sites that have
24 * an associated login stored in the password manager are considered `logged in`
25 * by the service, which is not always true in terms of whether the users is
26 * really logged in to the site.
28 class LoginDetectionService final : public nsILoginDetectionService,
29 public nsILoginSearchCallback,
30 public nsIObserver,
31 public nsSupportsWeakReference {
32 public:
33 NS_DECL_ISUPPORTS
34 NS_DECL_NSILOGINDETECTIONSERVICE
35 NS_DECL_NSILOGINSEARCHCALLBACK
36 NS_DECL_NSIOBSERVER
38 static already_AddRefed<LoginDetectionService> GetSingleton();
40 void MaybeStartMonitoring();
42 private:
43 LoginDetectionService();
44 virtual ~LoginDetectionService();
46 // Fetch saved logins from the password manager.
47 void FetchLogins();
49 void RegisterObserver();
50 void UnregisterObserver();
52 nsCOMPtr<nsIObserverService> mObs;
54 // Used by testcase to make sure logins are fetched.
55 bool mIsLoginsLoaded;
58 } // namespace mozilla::dom
60 #endif