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
{
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
,
31 public nsSupportsWeakReference
{
34 NS_DECL_NSILOGINDETECTIONSERVICE
35 NS_DECL_NSILOGINSEARCHCALLBACK
38 static already_AddRefed
<LoginDetectionService
> GetSingleton();
40 void MaybeStartMonitoring();
43 LoginDetectionService();
44 virtual ~LoginDetectionService();
46 // Fetch saved logins from the password manager.
49 void RegisterObserver();
50 void UnregisterObserver();
52 nsCOMPtr
<nsIObserverService
> mObs
;
54 // Used by testcase to make sure logins are fetched.
58 } // namespace mozilla::dom