1 /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 2 -*-
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
9 #include "mozilla/Logging.h"
10 #include "mozilla/net/NeckoCommon.h"
11 #include "nsOSHelperAppServiceChild.h"
12 #include "nsMIMEInfoChild.h"
13 #include "nsISupports.h"
17 #include "nsIHandlerService.h"
18 #include "nsMimeTypes.h"
19 #include "nsMIMEInfoImpl.h"
22 #include "nsEmbedCID.h"
26 MOZ_LOG(nsExternalHelperAppService::mLog, mozilla::LogLevel::Info, args)
28 #define LOG_ERR(args) \
29 MOZ_LOG(nsExternalHelperAppService::mLog, mozilla::LogLevel::Error, args)
31 #define LOG_ENABLED() \
32 MOZ_LOG_TEST(nsExternalHelperAppService::mLog, mozilla::LogLevel::Info)
34 nsresult
nsOSHelperAppServiceChild::ExternalProtocolHandlerExists(
35 const char* aProtocolScheme
, bool* aHandlerExists
) {
37 nsCOMPtr
<nsIHandlerService
> handlerSvc
=
38 do_GetService(NS_HANDLERSERVICE_CONTRACTID
, &rv
);
39 if (NS_WARN_IF(NS_FAILED(rv
))) {
40 LOG_ERR(("nsOSHelperAppServiceChild error: no handler service"));
44 nsAutoCString
scheme(aProtocolScheme
);
45 *aHandlerExists
= false;
46 rv
= handlerSvc
->ExistsForProtocol(scheme
, aHandlerExists
);
48 ("nsOSHelperAppServiceChild::ExternalProtocolHandlerExists(): "
49 "protocol: %s, result: %" PRId32
,
50 aProtocolScheme
, static_cast<uint32_t>(rv
)));
51 mozilla::Unused
<< NS_WARN_IF(NS_FAILED(rv
));
55 nsresult
nsOSHelperAppServiceChild::OSProtocolHandlerExists(const char* aScheme
,
57 // Use ExternalProtocolHandlerExists() which includes the
58 // OS-level check and remotes the call to the parent process.
59 return NS_ERROR_NOT_IMPLEMENTED
;
63 nsOSHelperAppServiceChild::GetApplicationDescription(const nsACString
& aScheme
,
66 nsCOMPtr
<nsIHandlerService
> handlerSvc
=
67 do_GetService(NS_HANDLERSERVICE_CONTRACTID
, &rv
);
68 if (NS_WARN_IF(NS_FAILED(rv
))) {
69 LOG_ERR(("nsOSHelperAppServiceChild error: no handler service"));
73 rv
= handlerSvc
->GetApplicationDescription(aScheme
, aRetVal
);
75 ("nsOSHelperAppServiceChild::GetApplicationDescription(): "
76 "scheme: %s, result: %" PRId32
", description: %s",
77 PromiseFlatCString(aScheme
).get(), static_cast<uint32_t>(rv
),
78 NS_ConvertUTF16toUTF8(aRetVal
).get()));
79 mozilla::Unused
<< NS_WARN_IF(NS_FAILED(rv
));
84 nsOSHelperAppServiceChild::GetMIMEInfoFromOS(const nsACString
& aMIMEType
,
85 const nsACString
& aFileExt
,
87 nsIMIMEInfo
** aMIMEInfo
) {
88 RefPtr
<nsChildProcessMIMEInfo
> mimeInfo
=
89 new nsChildProcessMIMEInfo(aMIMEType
);
91 nsCOMPtr
<nsIHandlerService
> handlerSvc
=
92 do_GetService(NS_HANDLERSERVICE_CONTRACTID
);
95 handlerSvc
->GetMIMEInfoFromOS(mimeInfo
, aMIMEType
, aFileExt
, aFound
);
97 ("nsOSHelperAppServiceChild::GetMIMEInfoFromOS(): "
98 "MIME type: %s, extension: %s, result: %" PRId32
,
99 PromiseFlatCString(aMIMEType
).get(),
100 PromiseFlatCString(aFileExt
).get(), static_cast<uint32_t>(rv
)));
101 mozilla::Unused
<< NS_WARN_IF(NS_FAILED(rv
));
106 LOG_ERR(("nsOSHelperAppServiceChild error: no handler service"));
110 mimeInfo
.forget(aMIMEInfo
);
115 nsOSHelperAppServiceChild::GetProtocolHandlerInfoFromOS(
116 const nsACString
& aScheme
, bool* aFound
, nsIHandlerInfo
** aRetVal
) {
117 return NS_ERROR_NOT_IMPLEMENTED
;
121 nsOSHelperAppServiceChild::IsCurrentAppOSDefaultForProtocol(
122 const nsACString
& aScheme
, bool* aRetVal
) {
123 return NS_ERROR_NOT_IMPLEMENTED
;
126 nsresult
nsOSHelperAppServiceChild::GetFileTokenForPath(
127 const char16_t
* platformAppPath
, nsIFile
** aFile
) {
128 return NS_ERROR_NOT_IMPLEMENTED
;