Bug 1407878 - P2. Add PLoginReputation.ipdl for LoginReputationService. r?francois, billm
Right now the only parameter will be sent via the IPC message is form URI.
IPC is triggered when a password field is focusd (See P2.)
MozReview-Commit-ID: J8lVwRhTFIr
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -30,16 +30,17 @@
#include "mozilla/dom/ContentParent.h"
#include "mozilla/dom/DataTransfer.h"
#include "mozilla/dom/DocGroup.h"
#include "mozilla/dom/ExternalHelperAppChild.h"
#include "mozilla/dom/FileCreatorHelper.h"
#include "mozilla/dom/GetFilesHelper.h"
#include "mozilla/dom/IPCBlobUtils.h"
#include "mozilla/dom/MemoryReportRequest.h"
+#include "mozilla/dom/PLoginReputationChild.h"
#include "mozilla/dom/ProcessGlobal.h"
#include "mozilla/dom/PushNotifier.h"
#include "mozilla/dom/TabGroup.h"
#include "mozilla/dom/workers/ServiceWorkerManager.h"
#include "mozilla/dom/nsIContentChild.h"
#include "mozilla/dom/URLClassifierChild.h"
#include "mozilla/gfx/gfxVars.h"
#include "mozilla/psm/PSMContentListener.h"
@@ -3429,16 +3430,30 @@ ContentChild::AllocPURLClassifierLocalCh
bool
ContentChild::DeallocPURLClassifierLocalChild(PURLClassifierLocalChild* aActor)
{
MOZ_ASSERT(aActor);
delete aActor;
return true;
}
+PLoginReputationChild*
+ContentChild::AllocPLoginReputationChild(const URIParams& aUri)
+{
+ return new PLoginReputationChild();
+}
+
+bool
+ContentChild::DeallocPLoginReputationChild(PLoginReputationChild* aActor)
+{
+ MOZ_ASSERT(aActor);
+ delete aActor;
+ return true;
+}
+
// The IPC code will call this method asking us to assign an event target to new
// actors created by the ContentParent.
already_AddRefed<nsIEventTarget>
ContentChild::GetConstructedEventTarget(const Message& aMsg)
{
// Currently we only set targets for PBrowser.
if (aMsg.type() != PContent::Msg_PBrowserConstructor__ID) {
return nullptr;
--- a/dom/ipc/ContentChild.h
+++ b/dom/ipc/ContentChild.h
@@ -657,16 +657,22 @@ public:
// PURLClassifierLocalChild
virtual PURLClassifierLocalChild*
AllocPURLClassifierLocalChild(const URIParams& aUri,
const nsCString& aTables) override;
virtual bool
DeallocPURLClassifierLocalChild(PURLClassifierLocalChild* aActor) override;
+ virtual PLoginReputationChild*
+ AllocPLoginReputationChild(const URIParams& aUri) override;
+
+ virtual bool
+ DeallocPLoginReputationChild(PLoginReputationChild* aActor) override;
+
nsTArray<LookAndFeelInt>&
LookAndFeelCache() {
return mLookAndFeelCache;
}
/**
* Helper function for protocols that use the GPU process when available.
* Overrides FatalError to just be a warning when communicating with the
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -74,16 +74,17 @@
#include "mozilla/intl/LocaleService.h"
#include "mozilla/jsipc/CrossProcessObjectWrappers.h"
#include "mozilla/layers/PAPZParent.h"
#include "mozilla/layers/CompositorThread.h"
#include "mozilla/layers/ImageBridgeParent.h"
#include "mozilla/layers/LayerTreeOwnerTracker.h"
#include "mozilla/layout/RenderFrameParent.h"
#include "mozilla/loader/ScriptCacheActors.h"
+#include "mozilla/LoginReputationIPC.h"
#include "mozilla/LookAndFeel.h"
#include "mozilla/media/MediaParent.h"
#include "mozilla/Move.h"
#include "mozilla/net/NeckoParent.h"
#include "mozilla/net/CookieServiceParent.h"
#include "mozilla/net/PCookieServiceParent.h"
#include "mozilla/plugins/PluginBridge.h"
#include "mozilla/Preferences.h"
@@ -5344,16 +5345,52 @@ ContentParent::DeallocPURLClassifierLoca
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aActor);
RefPtr<URLClassifierLocalParent> actor =
dont_AddRef(static_cast<URLClassifierLocalParent*>(aActor));
return true;
}
+PLoginReputationParent*
+ContentParent::AllocPLoginReputationParent(const URIParams& aURI)
+{
+ MOZ_ASSERT(NS_IsMainThread());
+
+ RefPtr<LoginReputationParent> actor = new LoginReputationParent();
+ return actor.forget().take();
+}
+
+mozilla::ipc::IPCResult
+ContentParent::RecvPLoginReputationConstructor(PLoginReputationParent* aActor,
+ const URIParams& aURI)
+{
+ MOZ_ASSERT(NS_IsMainThread());
+ MOZ_ASSERT(aActor);
+
+ nsCOMPtr<nsIURI> uri = DeserializeURI(aURI);
+ if (!uri) {
+ return IPC_FAIL_NO_REASON(this);
+ }
+
+ auto* actor = static_cast<LoginReputationParent*>(aActor);
+ return actor->QueryReputation(uri);
+}
+
+bool
+ContentParent::DeallocPLoginReputationParent(PLoginReputationParent* aActor)
+{
+ MOZ_ASSERT(NS_IsMainThread());
+ MOZ_ASSERT(aActor);
+
+ RefPtr<LoginReputationParent> actor =
+ dont_AddRef(static_cast<LoginReputationParent*>(aActor));
+ return true;
+}
+
mozilla::ipc::IPCResult
ContentParent::RecvClassifyLocal(const URIParams& aURI, const nsCString& aTables,
nsresult *aRv, nsTArray<nsCString>* aResults)
{
MOZ_ASSERT(aResults);
nsCOMPtr<nsIURI> uri = DeserializeURI(aURI);
if (!uri) {
return IPC_FAIL_NO_REASON(this);
--- a/dom/ipc/ContentParent.h
+++ b/dom/ipc/ContentParent.h
@@ -601,16 +601,26 @@ public:
virtual PURLClassifierLocalParent*
AllocPURLClassifierLocalParent(const URIParams& aURI,
const nsCString& aTables) override;
virtual mozilla::ipc::IPCResult
RecvPURLClassifierLocalConstructor(PURLClassifierLocalParent* aActor,
const URIParams& aURI,
const nsCString& aTables) override;
+ virtual PLoginReputationParent*
+ AllocPLoginReputationParent(const URIParams& aURI) override;
+
+ virtual mozilla::ipc::IPCResult
+ RecvPLoginReputationConstructor(PLoginReputationParent* aActor,
+ const URIParams& aURI) override;
+
+ virtual bool
+ DeallocPLoginReputationParent(PLoginReputationParent* aActor) override;
+
virtual bool SendActivate(PBrowserParent* aTab) override
{
return PContentParent::SendActivate(aTab);
}
virtual bool SendDeactivate(PBrowserParent* aTab) override
{
return PContentParent::SendDeactivate(aTab);
--- a/dom/ipc/PContent.ipdl
+++ b/dom/ipc/PContent.ipdl
@@ -15,16 +15,17 @@ include protocol PPSMContentDownloader;
include protocol PExternalHelperApp;
include protocol PHandlerService;
include protocol PFileDescriptorSet;
include protocol PHal;
include protocol PHeapSnapshotTempFileHelper;
include protocol PProcessHangMonitor;
include protocol PImageBridge;
include protocol PIPCBlobInputStream;
+include protocol PLoginReputation;
include protocol PMedia;
include protocol PNecko;
include protocol PStreamFilter;
include protocol PGMPContent;
include protocol PGMPService;
include protocol PPluginModule;
include protocol PGMP;
include protocol PPrinting;
@@ -311,16 +312,17 @@ nested(upto inside_cpow) sync protocol P
manages PJavaScript;
manages PRemoteSpellcheckEngine;
manages PWebBrowserPersistDocument;
manages PWebrtcGlobal;
manages PPresentation;
manages PURLClassifier;
manages PURLClassifierLocal;
manages PScriptCache;
+ manages PLoginReputation;
both:
// Depending on exactly how the new browser is being created, it might be
// created from either the child or parent process!
//
// The child creates the PBrowser as part of
// TabChild::BrowserFrameProvideWindow (which happens when the child's
// content calls window.open()), and the parent creates the PBrowser as part
@@ -764,16 +766,18 @@ parent:
sync PURLClassifier(Principal principal, bool useTrackingProtection)
returns (bool success);
sync ClassifyLocal(URIParams uri, nsCString tables)
returns (nsresult rv, nsCString[] results);
// The async version of ClassifyLocal.
async PURLClassifierLocal(URIParams uri, nsCString tables);
+ async PLoginReputation(URIParams formURI);
+
// Services remoting
async StartVisitedQuery(URIParams uri);
async VisitURI(URIParams uri, OptionalURIParams referrer, uint32_t flags);
async SetURITitle(URIParams uri, nsString title);
async LoadURIExternal(URIParams uri, PBrowser windowContext);
async ExtProtocolChannelConnectParent(uint32_t registrarId);
new file mode 100644
--- /dev/null
+++ b/dom/ipc/PLoginReputation.ipdl
@@ -0,0 +1,26 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ * vim: sw=2 ts=8 et :
+ */
+/* 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 protocol PContent;
+
+namespace mozilla {
+namespace dom {
+
+// PLoginReputation allows child to send URL to parent when user focuses
+// on a password field. Right now this is an one way IPC call (No callback
+// will return after parent receives the IPC message) since we just process
+// the URL in parent (LoginReputationService) and stores the result to telemetry.
+protocol PLoginReputation
+{
+ manager PContent;
+
+child:
+ async __delete__();
+};
+
+} // namespace dom
+} // namespace mozilla
--- a/dom/ipc/moz.build
+++ b/dom/ipc/moz.build
@@ -91,16 +91,17 @@ IPDL_SOURCES += [
'PColorPicker.ipdl',
'PContent.ipdl',
'PContentBridge.ipdl',
'PContentPermission.ipdlh',
'PContentPermissionRequest.ipdl',
'PCycleCollectWithLogs.ipdl',
'PDocumentRenderer.ipdl',
'PFilePicker.ipdl',
+ 'PLoginReputation.ipdl',
'PPluginWidget.ipdl',
'PProcessHangMonitor.ipdl',
'PTabContext.ipdlh',
'PURLClassifier.ipdl',
'PURLClassifierInfo.ipdlh',
'PURLClassifierLocal.ipdl',
'ServiceWorkerConfiguration.ipdlh',
]
--- a/toolkit/components/reputationservice/LoginReputation.cpp
+++ b/toolkit/components/reputationservice/LoginReputation.cpp
@@ -1,16 +1,18 @@
/* -*- 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"
#include "nsIDOMHTMLInputElement.h"
#include "mozilla/Preferences.h"
+#include "mozilla/dom/ContentChild.h"
+#include "mozilla/ipc/URIUtils.h"
using namespace mozilla;
using namespace mozilla::dom;
#define PREF_PP_ENABLED "browser.safebrowsing.passwords.enabled"
static bool sPasswordProtectionEnabled = false;
// MOZ_LOG=LoginReputation:5
@@ -121,16 +123,29 @@ LoginReputationService::QueryReputationA
nsCOMPtr<nsINode> node = do_QueryInterface(aInput);
NS_ENSURE_STATE(node);
nsIURI* documentURI = node->OwnerDoc()->GetDocumentURI();
NS_ENSURE_STATE(documentURI);
if (XRE_IsContentProcess()) {
+ using namespace mozilla::ipc;
+
+ ContentChild* content = ContentChild::GetSingleton();
+ if (content->IsShuttingDown()) {
+ return NS_ERROR_FAILURE;
+ }
+
+ URIParams uri;
+ SerializeURI(documentURI, uri);
+
+ if (!content->SendPLoginReputationConstructor(uri)) {
+ return NS_ERROR_FAILURE;
+ }
} else {
nsCOMPtr<nsILoginReputationQuery> query =
LoginReputationService::ConstructQueryParam(documentURI);
nsresult rv = QueryReputation(query, aCallback);
return rv;
}
new file mode 100644
--- /dev/null
+++ b/toolkit/components/reputationservice/LoginReputationIPC.cpp
@@ -0,0 +1,57 @@
+
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=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 "LoginReputationIPC.h"
+#include "mozilla/Unused.h"
+
+using namespace mozilla;
+using namespace mozilla::dom;
+
+// MOZ_LOG=LoginReputation:5
+extern LazyLogModule gLoginReputationLogModule;
+#define LR_LOG(args) MOZ_LOG(gLoginReputationLogModule, mozilla::LogLevel::Debug, args)
+#define LR_LOG_ENABLED() MOZ_LOG_TEST(gLoginReputationLogModule, mozilla::LogLevel::Debug)
+
+NS_IMPL_ISUPPORTS(LoginReputationParent, nsILoginReputationQueryCallback)
+
+mozilla::ipc::IPCResult
+LoginReputationParent::QueryReputation(nsIURI* aURI)
+{
+ nsresult rv;
+ nsCOMPtr<nsILoginReputationService> service =
+ do_GetService(NS_LOGIN_REPUTATION_SERVICE_CONTRACTID, &rv);
+ if (NS_FAILED(rv)) {
+ Unused << Send__delete__(this);
+ return IPC_OK();
+ }
+
+ nsCOMPtr<nsILoginReputationQuery> query =
+ LoginReputationService::ConstructQueryParam(aURI);
+ rv = service->QueryReputation(query, this);
+ if (NS_FAILED(rv)) {
+ Unused << Send__delete__(this);
+ }
+
+ return IPC_OK();
+}
+
+NS_IMETHODIMP
+LoginReputationParent::OnQueryComplete(uint16_t aResult)
+{
+ LR_LOG(("OnQueryComplete() [result=%d]", aResult));
+
+ if (mIPCOpen) {
+ Unused << Send__delete__(this);
+ }
+ return NS_OK;
+}
+
+void
+LoginReputationParent::ActorDestroy(ActorDestroyReason aWhy)
+{
+ mIPCOpen = false;
+}
new file mode 100644
--- /dev/null
+++ b/toolkit/components/reputationservice/LoginReputationIPC.h
@@ -0,0 +1,37 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=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/. */
+
+#ifndef mozilla_dom_LoginReputationIPC_h
+#define mozilla_dom_LoginReputationIPC_h
+
+#include "mozilla/dom/PLoginReputationParent.h"
+#include "nsILoginReputation.h"
+
+namespace mozilla {
+namespace dom {
+
+class LoginReputationParent : public nsILoginReputationQueryCallback,
+ public PLoginReputationParent
+{
+public:
+ NS_DECL_THREADSAFE_ISUPPORTS
+ NS_DECL_NSILOGINREPUTATIONQUERYCALLBACK
+
+ LoginReputationParent() = default;
+
+ mozilla::ipc::IPCResult QueryReputation(nsIURI* aURI);
+
+ void ActorDestroy(ActorDestroyReason aWhy) override;
+
+private:
+ ~LoginReputationParent() = default;
+ bool mIPCOpen = true;
+};
+
+} // namespace dom
+} // namespace mozilla
+
+#endif // mozilla_dom_LoginReputationIPC_h
--- a/toolkit/components/reputationservice/moz.build
+++ b/toolkit/components/reputationservice/moz.build
@@ -4,34 +4,41 @@
# 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/.
with Files('*'):
BUG_COMPONENT = ('Toolkit', 'Safe Browsing')
XPCSHELL_TESTS_MANIFESTS += ['test/unit/xpcshell.ini']
+EXPORTS.mozilla += [
+ 'LoginReputationIPC.h'
+]
+
XPIDL_SOURCES += [
'nsIApplicationReputation.idl',
'nsILoginReputation.idl',
]
XPIDL_MODULE = 'reputationservice'
UNIFIED_SOURCES += [
'ApplicationReputation.cpp',
'chromium/chrome/common/safe_browsing/csd.pb.cc',
'LoginReputation.cpp',
+ 'LoginReputationIPC.cpp',
]
FINAL_LIBRARY = 'xul'
LOCAL_INCLUDES += [
'../protobuf',
'/ipc/chromium/src',
'chromium',
]
DEFINES['GOOGLE_PROTOBUF_NO_RTTI'] = True
DEFINES['GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER'] = True
if CONFIG['CC_TYPE'] in ('clang', 'gcc'):
CXXFLAGS += ['-Wno-shadow']
+
+include('/ipc/chromium/chromium-config.mozbuild')