mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-30 20:37:31 +09:00
import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo
This commit is contained in:
commit
dcd9973243
150858 changed files with 23884658 additions and 0 deletions
31
uriloader/exthandler/unix/nsExternalSharingAppService.h
Normal file
31
uriloader/exthandler/unix/nsExternalSharingAppService.h
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/* 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 NS_EXTERNAL_SHARING_APP_SERVICE_H
|
||||
#define NS_EXTERNAL_SHARING_APP_SERVICE_H
|
||||
|
||||
#include "nsIExternalSharingAppService.h"
|
||||
#include "nsAutoPtr.h"
|
||||
|
||||
class ShareUiInterface;
|
||||
|
||||
#define NS_EXTERNALSHARINGAPPSERVICE_CID \
|
||||
{0xea782c90, 0xc6ec, 0x11df, \
|
||||
{0xbd, 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66, 0x74}}
|
||||
|
||||
class nsExternalSharingAppService : public nsIExternalSharingAppService
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIEXTERNALSHARINGAPPSERVICE
|
||||
|
||||
nsExternalSharingAppService();
|
||||
|
||||
private:
|
||||
~nsExternalSharingAppService();
|
||||
|
||||
protected:
|
||||
nsAutoPtr<ShareUiInterface> mShareUi;
|
||||
};
|
||||
#endif
|
||||
109
uriloader/exthandler/unix/nsGNOMERegistry.cpp
Normal file
109
uriloader/exthandler/unix/nsGNOMERegistry.cpp
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
/* -*- Mode: C++; tab-width: 2; 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 "nsGNOMERegistry.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsMIMEInfoUnix.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsIGIOService.h"
|
||||
|
||||
/* static */ bool
|
||||
nsGNOMERegistry::HandlerExists(const char *aProtocolScheme)
|
||||
{
|
||||
nsCOMPtr<nsIGIOService> giovfs = do_GetService(NS_GIOSERVICE_CONTRACTID);
|
||||
if (!giovfs) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIGIOMimeApp> app;
|
||||
return NS_SUCCEEDED(giovfs->GetAppForURIScheme(nsDependentCString(aProtocolScheme),
|
||||
getter_AddRefs(app)));
|
||||
}
|
||||
|
||||
// XXX Check HandlerExists() before calling LoadURL.
|
||||
|
||||
/* static */ nsresult
|
||||
nsGNOMERegistry::LoadURL(nsIURI *aURL)
|
||||
{
|
||||
nsCOMPtr<nsIGIOService> giovfs = do_GetService(NS_GIOSERVICE_CONTRACTID);
|
||||
if (!giovfs) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return giovfs->ShowURI(aURL);
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
nsGNOMERegistry::GetAppDescForScheme(const nsACString& aScheme,
|
||||
nsAString& aDesc)
|
||||
{
|
||||
nsCOMPtr<nsIGIOService> giovfs = do_GetService(NS_GIOSERVICE_CONTRACTID);
|
||||
if (!giovfs)
|
||||
return;
|
||||
|
||||
nsAutoCString name;
|
||||
nsCOMPtr<nsIGIOMimeApp> app;
|
||||
if (NS_FAILED(giovfs->GetAppForURIScheme(aScheme, getter_AddRefs(app))))
|
||||
return;
|
||||
|
||||
app->GetName(name);
|
||||
|
||||
CopyUTF8toUTF16(name, aDesc);
|
||||
}
|
||||
|
||||
|
||||
/* static */ already_AddRefed<nsMIMEInfoBase>
|
||||
nsGNOMERegistry::GetFromExtension(const nsACString& aFileExt)
|
||||
{
|
||||
nsAutoCString mimeType;
|
||||
nsCOMPtr<nsIGIOService> giovfs = do_GetService(NS_GIOSERVICE_CONTRACTID);
|
||||
if (!giovfs) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Get the MIME type from the extension, then call GetFromType to
|
||||
// fill in the MIMEInfo.
|
||||
if (NS_FAILED(giovfs->GetMimeTypeFromExtension(aFileExt, mimeType)) ||
|
||||
mimeType.EqualsLiteral("application/octet-stream")) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<nsMIMEInfoBase> mi = GetFromType(mimeType);
|
||||
if (mi) {
|
||||
mi->AppendExtension(aFileExt);
|
||||
}
|
||||
|
||||
return mi.forget();
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<nsMIMEInfoBase>
|
||||
nsGNOMERegistry::GetFromType(const nsACString& aMIMEType)
|
||||
{
|
||||
RefPtr<nsMIMEInfoUnix> mimeInfo = new nsMIMEInfoUnix(aMIMEType);
|
||||
NS_ENSURE_TRUE(mimeInfo, nullptr);
|
||||
|
||||
nsAutoCString name;
|
||||
nsAutoCString description;
|
||||
|
||||
nsCOMPtr<nsIGIOService> giovfs = do_GetService(NS_GIOSERVICE_CONTRACTID);
|
||||
if (!giovfs) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIGIOMimeApp> gioHandlerApp;
|
||||
if (NS_FAILED(giovfs->GetAppForMimeType(aMIMEType, getter_AddRefs(gioHandlerApp))) ||
|
||||
!gioHandlerApp) {
|
||||
return nullptr;
|
||||
}
|
||||
gioHandlerApp->GetName(name);
|
||||
giovfs->GetDescriptionForMimeType(aMIMEType, description);
|
||||
|
||||
mimeInfo->SetDefaultDescription(NS_ConvertUTF8toUTF16(name));
|
||||
mimeInfo->SetPreferredAction(nsIMIMEInfo::useSystemDefault);
|
||||
mimeInfo->SetDescription(NS_ConvertUTF8toUTF16(description));
|
||||
|
||||
return mimeInfo.forget();
|
||||
}
|
||||
28
uriloader/exthandler/unix/nsGNOMERegistry.h
Normal file
28
uriloader/exthandler/unix/nsGNOMERegistry.h
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/* 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 nsGNOMERegistry_h
|
||||
#define nsGNOMERegistry_h
|
||||
|
||||
#include "nsIURI.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
class nsMIMEInfoBase;
|
||||
|
||||
class nsGNOMERegistry
|
||||
{
|
||||
public:
|
||||
static bool HandlerExists(const char *aProtocolScheme);
|
||||
|
||||
static nsresult LoadURL(nsIURI *aURL);
|
||||
|
||||
static void GetAppDescForScheme(const nsACString& aScheme,
|
||||
nsAString& aDesc);
|
||||
|
||||
static already_AddRefed<nsMIMEInfoBase> GetFromExtension(const nsACString& aFileExt);
|
||||
|
||||
static already_AddRefed<nsMIMEInfoBase> GetFromType(const nsACString& aMIMEType);
|
||||
};
|
||||
|
||||
#endif // nsGNOMERegistry_h
|
||||
136
uriloader/exthandler/unix/nsMIMEInfoUnix.cpp
Normal file
136
uriloader/exthandler/unix/nsMIMEInfoUnix.cpp
Normal file
|
|
@ -0,0 +1,136 @@
|
|||
/* -*- Mode: C++; tab-width: 3; 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 "nsMIMEInfoUnix.h"
|
||||
#include "nsGNOMERegistry.h"
|
||||
#include "nsIGIOService.h"
|
||||
#include "nsNetCID.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#ifdef MOZ_ENABLE_DBUS
|
||||
#include "nsDBusHandlerApp.h"
|
||||
#endif
|
||||
|
||||
nsresult
|
||||
nsMIMEInfoUnix::LoadUriInternal(nsIURI * aURI)
|
||||
{
|
||||
return nsGNOMERegistry::LoadURL(aURI);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMIMEInfoUnix::GetHasDefaultHandler(bool *_retval)
|
||||
{
|
||||
// if mDefaultApplication is set, it means the application has been set from
|
||||
// either /etc/mailcap or ${HOME}/.mailcap, in which case we don't want to
|
||||
// give the GNOME answer.
|
||||
if (mDefaultApplication)
|
||||
return nsMIMEInfoImpl::GetHasDefaultHandler(_retval);
|
||||
|
||||
*_retval = false;
|
||||
|
||||
if (mClass == eProtocolInfo) {
|
||||
*_retval = nsGNOMERegistry::HandlerExists(mSchemeOrType.get());
|
||||
} else {
|
||||
RefPtr<nsMIMEInfoBase> mimeInfo = nsGNOMERegistry::GetFromType(mSchemeOrType);
|
||||
if (!mimeInfo) {
|
||||
nsAutoCString ext;
|
||||
nsresult rv = GetPrimaryExtension(ext);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
mimeInfo = nsGNOMERegistry::GetFromExtension(ext);
|
||||
}
|
||||
}
|
||||
if (mimeInfo)
|
||||
*_retval = true;
|
||||
}
|
||||
|
||||
if (*_retval)
|
||||
return NS_OK;
|
||||
|
||||
#if defined(MOZ_ENABLE_CONTENTACTION)
|
||||
ContentAction::Action action =
|
||||
ContentAction::Action::defaultActionForFile(QUrl(), QString(mSchemeOrType.get()));
|
||||
if (action.isValid()) {
|
||||
*_retval = true;
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMIMEInfoUnix::LaunchDefaultWithFile(nsIFile *aFile)
|
||||
{
|
||||
// if mDefaultApplication is set, it means the application has been set from
|
||||
// either /etc/mailcap or ${HOME}/.mailcap, in which case we don't want to
|
||||
// give the GNOME answer.
|
||||
if (mDefaultApplication)
|
||||
return nsMIMEInfoImpl::LaunchDefaultWithFile(aFile);
|
||||
|
||||
nsAutoCString nativePath;
|
||||
aFile->GetNativePath(nativePath);
|
||||
|
||||
#if defined(MOZ_ENABLE_CONTENTACTION)
|
||||
QUrl uri = QUrl::fromLocalFile(QString::fromUtf8(nativePath.get()));
|
||||
ContentAction::Action action =
|
||||
ContentAction::Action::defaultActionForFile(uri, QString(mSchemeOrType.get()));
|
||||
if (action.isValid()) {
|
||||
action.trigger();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
#endif
|
||||
|
||||
nsCOMPtr<nsIGIOService> giovfs = do_GetService(NS_GIOSERVICE_CONTRACTID);
|
||||
if (!giovfs) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// nsGIOMimeApp->Launch wants a URI string instead of local file
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIIOService> ioservice = do_GetService(NS_IOSERVICE_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
rv = ioservice->NewFileURI(aFile, getter_AddRefs(uri));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsAutoCString uriSpec;
|
||||
uri->GetSpec(uriSpec);
|
||||
|
||||
nsCOMPtr<nsIGIOMimeApp> app;
|
||||
if (NS_FAILED(giovfs->GetAppForMimeType(mSchemeOrType, getter_AddRefs(app))) || !app) {
|
||||
return NS_ERROR_FILE_NOT_FOUND;
|
||||
}
|
||||
|
||||
return app->Launch(uriSpec);
|
||||
}
|
||||
|
||||
#if defined(MOZ_ENABLE_CONTENTACTION)
|
||||
NS_IMETHODIMP
|
||||
nsMIMEInfoUnix::GetPossibleApplicationHandlers(nsIMutableArray ** aPossibleAppHandlers)
|
||||
{
|
||||
if (!mPossibleApplications) {
|
||||
mPossibleApplications = do_CreateInstance(NS_ARRAY_CONTRACTID);
|
||||
|
||||
if (!mPossibleApplications)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
QList<ContentAction::Action> actions =
|
||||
ContentAction::Action::actionsForFile(QUrl(), QString(mSchemeOrType.get()));
|
||||
|
||||
for (int i = 0; i < actions.size(); ++i) {
|
||||
nsContentHandlerApp* app =
|
||||
new nsContentHandlerApp(nsString((char16_t*)actions[i].name().data()),
|
||||
mSchemeOrType, actions[i]);
|
||||
mPossibleApplications->AppendElement(app, false);
|
||||
}
|
||||
}
|
||||
|
||||
*aPossibleAppHandlers = mPossibleApplications;
|
||||
NS_ADDREF(*aPossibleAppHandlers);
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
32
uriloader/exthandler/unix/nsMIMEInfoUnix.h
Normal file
32
uriloader/exthandler/unix/nsMIMEInfoUnix.h
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/* -*- Mode: C++; tab-width: 3; 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 nsMIMEInfoUnix_h_
|
||||
#define nsMIMEInfoUnix_h_
|
||||
|
||||
#include "nsMIMEInfoImpl.h"
|
||||
|
||||
class nsMIMEInfoUnix : public nsMIMEInfoImpl
|
||||
{
|
||||
public:
|
||||
explicit nsMIMEInfoUnix(const char *aMIMEType = "") : nsMIMEInfoImpl(aMIMEType) {}
|
||||
explicit nsMIMEInfoUnix(const nsACString& aMIMEType) : nsMIMEInfoImpl(aMIMEType) {}
|
||||
nsMIMEInfoUnix(const nsACString& aType, HandlerClass aClass) :
|
||||
nsMIMEInfoImpl(aType, aClass) {}
|
||||
static bool HandlerExists(const char *aProtocolScheme);
|
||||
|
||||
protected:
|
||||
NS_IMETHOD GetHasDefaultHandler(bool *_retval);
|
||||
|
||||
virtual nsresult LoadUriInternal(nsIURI *aURI);
|
||||
|
||||
virtual nsresult LaunchDefaultWithFile(nsIFile *aFile);
|
||||
#if defined(MOZ_ENABLE_CONTENTACTION)
|
||||
NS_IMETHOD GetPossibleApplicationHandlers(nsIMutableArray * *aPossibleAppHandlers);
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // nsMIMEInfoUnix_h_
|
||||
1537
uriloader/exthandler/unix/nsOSHelperAppService.cpp
Normal file
1537
uriloader/exthandler/unix/nsOSHelperAppService.cpp
Normal file
File diff suppressed because it is too large
Load diff
128
uriloader/exthandler/unix/nsOSHelperAppService.h
Normal file
128
uriloader/exthandler/unix/nsOSHelperAppService.h
Normal file
|
|
@ -0,0 +1,128 @@
|
|||
/* -*- Mode: C++; tab-width: 3; 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 nsOSHelperAppService_h__
|
||||
#define nsOSHelperAppService_h__
|
||||
|
||||
// The OS helper app service is a subclass of nsExternalHelperAppService and is implemented on each
|
||||
// platform. It contains platform specific code for finding helper applications for a given mime type
|
||||
// in addition to launching those applications.
|
||||
|
||||
#include "nsExternalHelperAppService.h"
|
||||
#include "nsCExternalHandlerService.h"
|
||||
#include "nsMIMEInfoImpl.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
class nsILineInputStream;
|
||||
|
||||
class nsOSHelperAppService : public nsExternalHelperAppService
|
||||
{
|
||||
public:
|
||||
nsOSHelperAppService();
|
||||
virtual ~nsOSHelperAppService();
|
||||
|
||||
// method overrides for mime.types and mime.info look up steps
|
||||
already_AddRefed<nsIMIMEInfo> GetMIMEInfoFromOS(const nsACString& aMimeType,
|
||||
const nsACString& aFileExt,
|
||||
bool *aFound);
|
||||
NS_IMETHOD GetProtocolHandlerInfoFromOS(const nsACString &aScheme,
|
||||
bool *found,
|
||||
nsIHandlerInfo **_retval);
|
||||
|
||||
// override nsIExternalProtocolService methods
|
||||
nsresult OSProtocolHandlerExists(const char * aProtocolScheme, bool * aHandlerExists);
|
||||
NS_IMETHOD GetApplicationDescription(const nsACString& aScheme, nsAString& _retval);
|
||||
|
||||
// GetFileTokenForPath must be implemented by each platform.
|
||||
// platformAppPath --> a platform specific path to an application that we got out of the
|
||||
// rdf data source. This can be a mac file spec, a unix path or a windows path depending on the platform
|
||||
// aFile --> an nsIFile representation of that platform application path.
|
||||
virtual nsresult GetFileTokenForPath(const char16_t * platformAppPath, nsIFile ** aFile);
|
||||
|
||||
protected:
|
||||
already_AddRefed<nsMIMEInfoBase> GetFromType(const nsCString& aMimeType);
|
||||
already_AddRefed<nsMIMEInfoBase> GetFromExtension(const nsCString& aFileExt);
|
||||
|
||||
private:
|
||||
uint32_t mPermissions;
|
||||
|
||||
// Helper methods which have to access static members
|
||||
static nsresult UnescapeCommand(const nsAString& aEscapedCommand,
|
||||
const nsAString& aMajorType,
|
||||
const nsAString& aMinorType,
|
||||
nsACString& aUnEscapedCommand);
|
||||
static nsresult GetFileLocation(const char* aPrefName,
|
||||
const char* aEnvVarName,
|
||||
nsAString& aFileLocation);
|
||||
static nsresult LookUpTypeAndDescription(const nsAString& aFileExtension,
|
||||
nsAString& aMajorType,
|
||||
nsAString& aMinorType,
|
||||
nsAString& aDescription,
|
||||
bool aUserData);
|
||||
static nsresult CreateInputStream(const nsAString& aFilename,
|
||||
nsIFileInputStream ** aFileInputStream,
|
||||
nsILineInputStream ** aLineInputStream,
|
||||
nsACString& aBuffer,
|
||||
bool * aNetscapeFormat,
|
||||
bool * aMore);
|
||||
|
||||
static nsresult GetTypeAndDescriptionFromMimetypesFile(const nsAString& aFilename,
|
||||
const nsAString& aFileExtension,
|
||||
nsAString& aMajorType,
|
||||
nsAString& aMinorType,
|
||||
nsAString& aDescription);
|
||||
|
||||
static nsresult LookUpExtensionsAndDescription(const nsAString& aMajorType,
|
||||
const nsAString& aMinorType,
|
||||
nsAString& aFileExtensions,
|
||||
nsAString& aDescription);
|
||||
|
||||
static nsresult GetExtensionsAndDescriptionFromMimetypesFile(const nsAString& aFilename,
|
||||
const nsAString& aMajorType,
|
||||
const nsAString& aMinorType,
|
||||
nsAString& aFileExtensions,
|
||||
nsAString& aDescription);
|
||||
|
||||
static nsresult ParseNetscapeMIMETypesEntry(const nsAString& aEntry,
|
||||
nsAString::const_iterator& aMajorTypeStart,
|
||||
nsAString::const_iterator& aMajorTypeEnd,
|
||||
nsAString::const_iterator& aMinorTypeStart,
|
||||
nsAString::const_iterator& aMinorTypeEnd,
|
||||
nsAString& aExtensions,
|
||||
nsAString::const_iterator& aDescriptionStart,
|
||||
nsAString::const_iterator& aDescriptionEnd);
|
||||
|
||||
static nsresult ParseNormalMIMETypesEntry(const nsAString& aEntry,
|
||||
nsAString::const_iterator& aMajorTypeStart,
|
||||
nsAString::const_iterator& aMajorTypeEnd,
|
||||
nsAString::const_iterator& aMinorTypeStart,
|
||||
nsAString::const_iterator& aMinorTypeEnd,
|
||||
nsAString& aExtensions,
|
||||
nsAString::const_iterator& aDescriptionStart,
|
||||
nsAString::const_iterator& aDescriptionEnd);
|
||||
|
||||
static nsresult LookUpHandlerAndDescription(const nsAString& aMajorType,
|
||||
const nsAString& aMinorType,
|
||||
nsAString& aHandler,
|
||||
nsAString& aDescription,
|
||||
nsAString& aMozillaFlags);
|
||||
|
||||
static nsresult DoLookUpHandlerAndDescription(const nsAString& aMajorType,
|
||||
const nsAString& aMinorType,
|
||||
nsAString& aHandler,
|
||||
nsAString& aDescription,
|
||||
nsAString& aMozillaFlags,
|
||||
bool aUserData);
|
||||
|
||||
static nsresult GetHandlerAndDescriptionFromMailcapFile(const nsAString& aFilename,
|
||||
const nsAString& aMajorType,
|
||||
const nsAString& aMinorType,
|
||||
nsAString& aHandler,
|
||||
nsAString& aDescription,
|
||||
nsAString& aMozillaFlags);
|
||||
};
|
||||
|
||||
#endif // nsOSHelperAppService_h__
|
||||
Loading…
Add table
Add a link
Reference in a new issue