Bug 1384753 - Add dummy login reputation service in reputationservice component. r=francois
authorDimiL <dlee@mozilla.com>
Thu, 26 Oct 2017 11:27:17 +0800
changeset 388954 a6217947aff0592b4258f71b2e133e76acb8b373
parent 388953 45181edd35f6f6c778670e227d16b1a540dfad4c
child 388955 0efc275f78e6935dda99574aa8ffeb26cc9874d5
push id32772
push userccoroiu@mozilla.com
push dateMon, 30 Oct 2017 10:15:13 +0000
treeherdermozilla-central@acc9f95343e7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfrancois
bugs1384753
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1384753 - Add dummy login reputation service in reputationservice component. r=francois Login reputation service is initialized during idle startup.
browser/components/nsBrowserGlue.js
toolkit/components/build/nsToolkitCompsCID.h
toolkit/components/build/nsToolkitCompsModule.cpp
toolkit/components/reputationservice/ILoginReputation.idl
toolkit/components/reputationservice/LoginReputation.cpp
toolkit/components/reputationservice/LoginReputation.h
toolkit/components/reputationservice/moz.build
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -1106,16 +1106,22 @@ BrowserGlue.prototype = {
         Cu.reportError(ex);
       }
     }, 3000);
 
     // It's important that SafeBrowsing is initialized reasonably
     // 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) {
       UnsubmittedCrashHandler.scheduleCheckForUnsubmittedCrashReports();
     }
 
     if (AppConstants.platform == "win") {
       Services.tm.idleDispatchToMainThread(() => {
--- a/toolkit/components/build/nsToolkitCompsCID.h
+++ b/toolkit/components/build/nsToolkitCompsCID.h
@@ -176,16 +176,22 @@
 #endif
 
 #define NS_APPLICATION_REPUTATION_SERVICE_CONTRACTID \
   "@mozilla.org/reputationservice/application-reputation-service;1"
 
 #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 } }
 
 #define NS_ADDON_PATH_SERVICE_CID \
 { 0xa39f39d0, 0xdfb6, 0x11e3, { 0x8b, 0x68, 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66 } }
 
 #define NS_ADDON_POLICY_SERVICE_CID \
 { 0x562de129, 0x8338, 0x482c, { 0xbb, 0x96, 0xa1, 0xff, 0x09, 0xee, 0x53, 0xcc } }
--- a/toolkit/components/build/nsToolkitCompsModule.cpp
+++ b/toolkit/components/build/nsToolkitCompsModule.cpp
@@ -21,16 +21,17 @@
 
 #include "nsDownloadManager.h"
 #include "DownloadPlatform.h"
 #include "rdf.h"
 
 #include "nsTypeAheadFind.h"
 
 #include "ApplicationReputation.h"
+#include "LoginReputation.h"
 #include "nsUrlClassifierDBService.h"
 #include "nsUrlClassifierStreamUpdater.h"
 #include "nsUrlClassifierUtils.h"
 #include "nsUrlClassifierPrefixSet.h"
 
 #include "nsBrowserStatusFilter.h"
 #include "mozilla/FinalizationWitnessService.h"
 #include "mozilla/NativeOSFileInternals.h"
@@ -86,16 +87,18 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsAlertsS
 NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsDownloadManager,
                                          nsDownloadManager::GetSingleton)
 NS_GENERIC_FACTORY_CONSTRUCTOR(DownloadPlatform)
 
 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)
 
 static nsresult
 nsUrlClassifierDBServiceConstructor(nsISupports *aOuter, REFNSIID aIID,
                                     void **aResult)
 {
@@ -141,16 +144,17 @@ NS_DEFINE_NAMED_CID(NS_ALERTSSERVICE_CID
 #if !defined(MOZ_DISABLE_PARENTAL_CONTROLS)
 NS_DEFINE_NAMED_CID(NS_PARENTALCONTROLSSERVICE_CID);
 #endif
 NS_DEFINE_NAMED_CID(NS_DOWNLOADMANAGER_CID);
 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);
 NS_DEFINE_NAMED_CID(NS_URLCLASSIFIERUTILS_CID);
 NS_DEFINE_NAMED_CID(NS_BROWSERSTATUSFILTER_CID);
 #if defined(MOZ_UPDATER) && !defined(MOZ_WIDGET_ANDROID)
 NS_DEFINE_NAMED_CID(NS_UPDATEPROCESSOR_CID);
 #endif
@@ -176,16 +180,17 @@ static const Module::CIDEntry kToolkitCI
 #if !defined(MOZ_DISABLE_PARENTAL_CONTROLS)
   { &kNS_PARENTALCONTROLSSERVICE_CID, false, nullptr, nsParentalControlsServiceConstructor },
 #endif
   { &kNS_DOWNLOADMANAGER_CID, false, nullptr, nsDownloadManagerConstructor },
   { &kNS_DOWNLOADPLATFORM_CID, false, nullptr, DownloadPlatformConstructor },
   { &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 },
   { &kNS_URLCLASSIFIERUTILS_CID, false, nullptr, nsUrlClassifierUtilsConstructor },
   { &kNS_BROWSERSTATUSFILTER_CID, false, nullptr, nsBrowserStatusFilterConstructor },
 #if defined(MOZ_UPDATER) && !defined(MOZ_WIDGET_ANDROID)
   { &kNS_UPDATEPROCESSOR_CID, false, nullptr, nsUpdateProcessorConstructor },
 #endif
@@ -213,16 +218,17 @@ static const Module::ContractIDEntry kTo
 #if !defined(MOZ_DISABLE_PARENTAL_CONTROLS)
   { NS_PARENTALCONTROLSSERVICE_CONTRACTID, &kNS_PARENTALCONTROLSSERVICE_CID },
 #endif
   { NS_DOWNLOADMANAGER_CONTRACTID, &kNS_DOWNLOADMANAGER_CID },
   { NS_DOWNLOADPLATFORM_CONTRACTID, &kNS_DOWNLOADPLATFORM_CID },
   { 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 },
   { NS_URLCLASSIFIERSTREAMUPDATER_CONTRACTID, &kNS_URLCLASSIFIERSTREAMUPDATER_CID },
   { NS_URLCLASSIFIERUTILS_CONTRACTID, &kNS_URLCLASSIFIERUTILS_CID },
   { NS_BROWSERSTATUSFILTER_CONTRACTID, &kNS_BROWSERSTATUSFILTER_CID },
 #if defined(MOZ_UPDATER) && !defined(MOZ_WIDGET_ANDROID)
   { NS_UPDATEPROCESSOR_CONTRACTID, &kNS_UPDATEPROCESSOR_CID },
new file mode 100644
--- /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
+};
new file mode 100644
--- /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>
+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"));
+}
new file mode 100644
--- /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<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__
--- a/toolkit/components/reputationservice/moz.build
+++ b/toolkit/components/reputationservice/moz.build
@@ -5,24 +5,26 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 with Files('*'):
     BUG_COMPONENT = ('Toolkit', 'Safe Browsing')
 
 XPCSHELL_TESTS_MANIFESTS += ['test/unit/xpcshell.ini']
 
 XPIDL_SOURCES += [
+    'ILoginReputation.idl',
     'nsIApplicationReputation.idl',
 ]
 
 XPIDL_MODULE = 'reputationservice'
 
 UNIFIED_SOURCES += [
     'ApplicationReputation.cpp',
     'chromium/chrome/common/safe_browsing/csd.pb.cc',
+    'LoginReputation.cpp',
 ]
 
 FINAL_LIBRARY = 'xul'
 
 LOCAL_INCLUDES += [
     '../protobuf',
     '/ipc/chromium/src',
     'chromium',