Skip to content

Commit

Permalink
Bug 1384753 - Add dummy login reputation service in reputationservice…
Browse files Browse the repository at this point in the history
… component. r=francois

Login reputation service is initialized during idle startup.

--HG--
extra : rebase_source : 6f851bbc9a1ef7c7821c09d8f739197468ab24df
  • Loading branch information
DimiDL committed Oct 26, 2017
1 parent 7a49148 commit 9711670
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 0 deletions.
6 changes: 6 additions & 0 deletions browser/components/nsBrowserGlue.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 6 additions & 0 deletions toolkit/components/build/nsToolkitCompsCID.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 } }

Expand Down
6 changes: 6 additions & 0 deletions toolkit/components/build/nsToolkitCompsModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "nsTypeAheadFind.h"

#include "ApplicationReputation.h"
#include "LoginReputation.h"
#include "nsUrlClassifierDBService.h"
#include "nsUrlClassifierStreamUpdater.h"
#include "nsUrlClassifierUtils.h"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 },
Expand Down Expand Up @@ -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 },
Expand Down
17 changes: 17 additions & 0 deletions toolkit/components/reputationservice/ILoginReputation.idl
Original file line number Diff line number Diff line change
@@ -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
};
38 changes: 38 additions & 0 deletions toolkit/components/reputationservice/LoginReputation.cpp
Original file line number Diff line number Diff line change
@@ -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>
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"));
}
36 changes: 36 additions & 0 deletions toolkit/components/reputationservice/LoginReputation.h
Original file line number Diff line number Diff line change
@@ -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<LoginReputationService> 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__
2 changes: 2 additions & 0 deletions toolkit/components/reputationservice/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ with Files('*'):
XPCSHELL_TESTS_MANIFESTS += ['test/unit/xpcshell.ini']

XPIDL_SOURCES += [
'ILoginReputation.idl',
'nsIApplicationReputation.idl',
]

Expand All @@ -18,6 +19,7 @@ XPIDL_MODULE = 'reputationservice'
UNIFIED_SOURCES += [
'ApplicationReputation.cpp',
'chromium/chrome/common/safe_browsing/csd.pb.cc',
'LoginReputation.cpp',
]

FINAL_LIBRARY = 'xul'
Expand Down

0 comments on commit 9711670

Please sign in to comment.