diff --git a/browser/components/nsBrowserGlue.js b/browser/components/nsBrowserGlue.js index c880da574cb86..659a56ff806dc 100644 --- a/browser/components/nsBrowserGlue.js +++ b/browser/components/nsBrowserGlue.js @@ -1109,6 +1109,12 @@ BrowserGlue.prototype = { // early, so we use a maximum timeout for it. Services.tm.idleDispatchToMainThread(() => { SafeBrowsing.init(); + + // Login reputation depends on the Safe Browsing API. + if (Services.prefs.getBoolPref("browser.safebrowsing.passwords.enabled")) { + Cc["@mozilla.org/reputationservice/login-reputation-service;1"] + .getService(Ci.ILoginReputationService); + } }, 5000); if (AppConstants.MOZ_CRASHREPORTER) { diff --git a/toolkit/components/build/nsToolkitCompsCID.h b/toolkit/components/build/nsToolkitCompsCID.h index 9383e6856f8fe..6dd7e17ec90ab 100644 --- a/toolkit/components/build/nsToolkitCompsCID.h +++ b/toolkit/components/build/nsToolkitCompsCID.h @@ -181,6 +181,12 @@ #define NS_APPLICATION_REPUTATION_SERVICE_CID \ { 0xd21b4c33, 0x716f, 0x4117, { 0x80, 0x41, 0x27, 0x70, 0xb5, 0x9f, 0xf8, 0xa6 } } +#define NS_LOGIN_REPUTATION_SERVICE_CONTRACTID \ + "@mozilla.org/reputationservice/login-reputation-service;1" + +#define NS_LOGIN_REPUTATION_SERVICE_CID \ +{ 0x91fa9e67, 0x1427, 0x4ee9, { 0x8e, 0xe0, 0x1a, 0x6e, 0xd5, 0x78, 0xbe, 0xe1 } } + #define NS_ADDONCONTENTPOLICY_CID \ { 0xc26a8241, 0xecf4, 0x4aed, { 0x9f, 0x3c, 0xf1, 0xf5, 0xc7, 0x13, 0xb9, 0xa5 } } diff --git a/toolkit/components/build/nsToolkitCompsModule.cpp b/toolkit/components/build/nsToolkitCompsModule.cpp index 675afc4a55901..cc28fc5d83d4d 100644 --- a/toolkit/components/build/nsToolkitCompsModule.cpp +++ b/toolkit/components/build/nsToolkitCompsModule.cpp @@ -26,6 +26,7 @@ #include "nsTypeAheadFind.h" #include "ApplicationReputation.h" +#include "LoginReputation.h" #include "nsUrlClassifierDBService.h" #include "nsUrlClassifierStreamUpdater.h" #include "nsUrlClassifierUtils.h" @@ -91,6 +92,8 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsTypeAheadFind) NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(ApplicationReputationService, ApplicationReputationService::GetSingleton) +NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(LoginReputationService, + LoginReputationService::GetSingleton) NS_GENERIC_FACTORY_CONSTRUCTOR(nsUrlClassifierPrefixSet) NS_GENERIC_FACTORY_CONSTRUCTOR(nsUrlClassifierStreamUpdater) NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsUrlClassifierUtils, Init) @@ -146,6 +149,7 @@ NS_DEFINE_NAMED_CID(NS_DOWNLOADPLATFORM_CID); NS_DEFINE_NAMED_CID(NS_FIND_SERVICE_CID); NS_DEFINE_NAMED_CID(NS_TYPEAHEADFIND_CID); NS_DEFINE_NAMED_CID(NS_APPLICATION_REPUTATION_SERVICE_CID); +NS_DEFINE_NAMED_CID(NS_LOGIN_REPUTATION_SERVICE_CID); NS_DEFINE_NAMED_CID(NS_URLCLASSIFIERPREFIXSET_CID); NS_DEFINE_NAMED_CID(NS_URLCLASSIFIERDBSERVICE_CID); NS_DEFINE_NAMED_CID(NS_URLCLASSIFIERSTREAMUPDATER_CID); @@ -181,6 +185,7 @@ static const Module::CIDEntry kToolkitCIDs[] = { { &kNS_FIND_SERVICE_CID, false, nullptr, nsFindServiceConstructor }, { &kNS_TYPEAHEADFIND_CID, false, nullptr, nsTypeAheadFindConstructor }, { &kNS_APPLICATION_REPUTATION_SERVICE_CID, false, nullptr, ApplicationReputationServiceConstructor }, + { &kNS_LOGIN_REPUTATION_SERVICE_CID, false, nullptr, LoginReputationServiceConstructor }, { &kNS_URLCLASSIFIERPREFIXSET_CID, false, nullptr, nsUrlClassifierPrefixSetConstructor }, { &kNS_URLCLASSIFIERDBSERVICE_CID, false, nullptr, nsUrlClassifierDBServiceConstructor }, { &kNS_URLCLASSIFIERSTREAMUPDATER_CID, false, nullptr, nsUrlClassifierStreamUpdaterConstructor }, @@ -218,6 +223,7 @@ static const Module::ContractIDEntry kToolkitContracts[] = { { NS_FIND_SERVICE_CONTRACTID, &kNS_FIND_SERVICE_CID }, { NS_TYPEAHEADFIND_CONTRACTID, &kNS_TYPEAHEADFIND_CID }, { NS_APPLICATION_REPUTATION_SERVICE_CONTRACTID, &kNS_APPLICATION_REPUTATION_SERVICE_CID }, + { NS_LOGIN_REPUTATION_SERVICE_CONTRACTID, &kNS_LOGIN_REPUTATION_SERVICE_CID }, { NS_URLCLASSIFIERPREFIXSET_CONTRACTID, &kNS_URLCLASSIFIERPREFIXSET_CID }, { NS_URLCLASSIFIERDBSERVICE_CONTRACTID, &kNS_URLCLASSIFIERDBSERVICE_CID }, { NS_URICLASSIFIERSERVICE_CONTRACTID, &kNS_URLCLASSIFIERDBSERVICE_CID }, diff --git a/toolkit/components/reputationservice/ILoginReputation.idl b/toolkit/components/reputationservice/ILoginReputation.idl new file mode 100644 index 0000000000000..ded4948d3e4b2 --- /dev/null +++ b/toolkit/components/reputationservice/ILoginReputation.idl @@ -0,0 +1,17 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "nsISupports.idl" + +[scriptable, uuid(b527be1e-8fbb-41d9-bee4-267a71236368)] +interface ILoginReputationQueryCallback : nsISupports { + void onQueryComplete(); +}; + +[scriptable, uuid(1b3f1dfe-ce3a-486b-953e-ce5ac863eff9)] +interface ILoginReputationService : nsISupports { + // XXX : Add QueryReputation interface +}; diff --git a/toolkit/components/reputationservice/LoginReputation.cpp b/toolkit/components/reputationservice/LoginReputation.cpp new file mode 100644 index 0000000000000..163934502ef8f --- /dev/null +++ b/toolkit/components/reputationservice/LoginReputation.cpp @@ -0,0 +1,38 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "LoginReputation.h" + +using namespace mozilla; + +// MOZ_LOG=LoginReputation:5 +LazyLogModule LoginReputationService::prlog("LoginReputation"); +#define LR_LOG(args) MOZ_LOG(LoginReputationService::prlog, mozilla::LogLevel::Debug, args) +#define LR_LOG_ENABLED() MOZ_LOG_TEST(LoginReputationService::prlog, mozilla::LogLevel::Debug) + +NS_IMPL_ISUPPORTS(LoginReputationService, + ILoginReputationService) + +LoginReputationService* + LoginReputationService::gLoginReputationService = nullptr; + +already_AddRefed +LoginReputationService::GetSingleton() +{ + if (!gLoginReputationService) { + gLoginReputationService = new LoginReputationService(); + } + return do_AddRef(gLoginReputationService); +} + +LoginReputationService::LoginReputationService() +{ + LR_LOG(("Login reputation service starting up")); +} + +LoginReputationService::~LoginReputationService() +{ + LR_LOG(("Login reputation service shutting down")); +} diff --git a/toolkit/components/reputationservice/LoginReputation.h b/toolkit/components/reputationservice/LoginReputation.h new file mode 100644 index 0000000000000..76a80139d7e51 --- /dev/null +++ b/toolkit/components/reputationservice/LoginReputation.h @@ -0,0 +1,36 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef LoginReputation_h__ +#define LoginReputation_h__ + +#include "ILoginReputation.h" +#include "mozilla/Logging.h" + +class LoginReputationService final : public ILoginReputationService +{ +public: + NS_DECL_ISUPPORTS + NS_DECL_ILOGINREPUTATIONSERVICE + +public: + static already_AddRefed GetSingleton(); + +private: + /** + * Global singleton object for holding this factory service. + */ + static LoginReputationService* gLoginReputationService; + + /** + * MOZ_LOG=LoginReputation:5 + */ + static mozilla::LazyLogModule prlog; + + LoginReputationService(); + ~LoginReputationService(); +}; + +#endif // LoginReputation_h__ diff --git a/toolkit/components/reputationservice/moz.build b/toolkit/components/reputationservice/moz.build index 67f95849f26d6..c8dd45a47c2c1 100644 --- a/toolkit/components/reputationservice/moz.build +++ b/toolkit/components/reputationservice/moz.build @@ -10,6 +10,7 @@ with Files('*'): XPCSHELL_TESTS_MANIFESTS += ['test/unit/xpcshell.ini'] XPIDL_SOURCES += [ + 'ILoginReputation.idl', 'nsIApplicationReputation.idl', ] @@ -18,6 +19,7 @@ XPIDL_MODULE = 'reputationservice' UNIFIED_SOURCES += [ 'ApplicationReputation.cpp', 'chromium/chrome/common/safe_browsing/csd.pb.cc', + 'LoginReputation.cpp', ] FINAL_LIBRARY = 'xul'