Bug 1943650 - Command-line --help output misformatted after --dbus-service. r=emilio
[gecko.git] / toolkit / components / alerts / nsAlertsUtils.cpp
blobb63b368c75a3f2c9ea414a6034f3ffc07cd2064d
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #include "nsAlertsUtils.h"
7 #include "nsCOMPtr.h"
8 #include "nsContentUtils.h"
9 #include "nsIURI.h"
10 #include "nsString.h"
12 /* static */
13 bool nsAlertsUtils::IsActionablePrincipal(nsIPrincipal* aPrincipal) {
14 return aPrincipal &&
15 !nsContentUtils::IsSystemOrExpandedPrincipal(aPrincipal) &&
16 !aPrincipal->GetIsNullPrincipal();
19 /* static */
20 void nsAlertsUtils::GetSourceHostPort(nsIPrincipal* aPrincipal,
21 nsAString& aHostPort) {
22 if (!IsActionablePrincipal(aPrincipal)) {
23 return;
25 nsAutoCString hostPort;
26 if (NS_WARN_IF(NS_FAILED(aPrincipal->GetHostPort(hostPort)))) {
27 return;
29 CopyUTF8toUTF16(hostPort, aHostPort);