1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/uriloader/exthandler/unix/nsOSHelperAppService.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,128 @@ 1.4 +/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 2 -*- 1.5 + * 1.6 + * This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#ifndef nsOSHelperAppService_h__ 1.11 +#define nsOSHelperAppService_h__ 1.12 + 1.13 +// The OS helper app service is a subclass of nsExternalHelperAppService and is implemented on each 1.14 +// platform. It contains platform specific code for finding helper applications for a given mime type 1.15 +// in addition to launching those applications. 1.16 + 1.17 +#include "nsExternalHelperAppService.h" 1.18 +#include "nsCExternalHandlerService.h" 1.19 +#include "nsMIMEInfoImpl.h" 1.20 +#include "nsCOMPtr.h" 1.21 + 1.22 +class nsILineInputStream; 1.23 + 1.24 +class nsOSHelperAppService : public nsExternalHelperAppService 1.25 +{ 1.26 +public: 1.27 + nsOSHelperAppService(); 1.28 + virtual ~nsOSHelperAppService(); 1.29 + 1.30 + // method overrides for mime.types and mime.info look up steps 1.31 + already_AddRefed<nsIMIMEInfo> GetMIMEInfoFromOS(const nsACString& aMimeType, 1.32 + const nsACString& aFileExt, 1.33 + bool *aFound); 1.34 + NS_IMETHOD GetProtocolHandlerInfoFromOS(const nsACString &aScheme, 1.35 + bool *found, 1.36 + nsIHandlerInfo **_retval); 1.37 + 1.38 + // override nsIExternalProtocolService methods 1.39 + nsresult OSProtocolHandlerExists(const char * aProtocolScheme, bool * aHandlerExists); 1.40 + NS_IMETHOD GetApplicationDescription(const nsACString& aScheme, nsAString& _retval); 1.41 + 1.42 + // GetFileTokenForPath must be implemented by each platform. 1.43 + // platformAppPath --> a platform specific path to an application that we got out of the 1.44 + // rdf data source. This can be a mac file spec, a unix path or a windows path depending on the platform 1.45 + // aFile --> an nsIFile representation of that platform application path. 1.46 + virtual nsresult GetFileTokenForPath(const char16_t * platformAppPath, nsIFile ** aFile); 1.47 + 1.48 +protected: 1.49 + already_AddRefed<nsMIMEInfoBase> GetFromType(const nsCString& aMimeType); 1.50 + already_AddRefed<nsMIMEInfoBase> GetFromExtension(const nsCString& aFileExt); 1.51 + 1.52 +private: 1.53 + uint32_t mPermissions; 1.54 + 1.55 + // Helper methods which have to access static members 1.56 + static nsresult UnescapeCommand(const nsAString& aEscapedCommand, 1.57 + const nsAString& aMajorType, 1.58 + const nsAString& aMinorType, 1.59 + nsACString& aUnEscapedCommand); 1.60 + static nsresult GetFileLocation(const char* aPrefName, 1.61 + const char* aEnvVarName, 1.62 + nsAString& aFileLocation); 1.63 + static nsresult LookUpTypeAndDescription(const nsAString& aFileExtension, 1.64 + nsAString& aMajorType, 1.65 + nsAString& aMinorType, 1.66 + nsAString& aDescription, 1.67 + bool aUserData); 1.68 + static nsresult CreateInputStream(const nsAString& aFilename, 1.69 + nsIFileInputStream ** aFileInputStream, 1.70 + nsILineInputStream ** aLineInputStream, 1.71 + nsACString& aBuffer, 1.72 + bool * aNetscapeFormat, 1.73 + bool * aMore); 1.74 + 1.75 + static nsresult GetTypeAndDescriptionFromMimetypesFile(const nsAString& aFilename, 1.76 + const nsAString& aFileExtension, 1.77 + nsAString& aMajorType, 1.78 + nsAString& aMinorType, 1.79 + nsAString& aDescription); 1.80 + 1.81 + static nsresult LookUpExtensionsAndDescription(const nsAString& aMajorType, 1.82 + const nsAString& aMinorType, 1.83 + nsAString& aFileExtensions, 1.84 + nsAString& aDescription); 1.85 + 1.86 + static nsresult GetExtensionsAndDescriptionFromMimetypesFile(const nsAString& aFilename, 1.87 + const nsAString& aMajorType, 1.88 + const nsAString& aMinorType, 1.89 + nsAString& aFileExtensions, 1.90 + nsAString& aDescription); 1.91 + 1.92 + static nsresult ParseNetscapeMIMETypesEntry(const nsAString& aEntry, 1.93 + nsAString::const_iterator& aMajorTypeStart, 1.94 + nsAString::const_iterator& aMajorTypeEnd, 1.95 + nsAString::const_iterator& aMinorTypeStart, 1.96 + nsAString::const_iterator& aMinorTypeEnd, 1.97 + nsAString& aExtensions, 1.98 + nsAString::const_iterator& aDescriptionStart, 1.99 + nsAString::const_iterator& aDescriptionEnd); 1.100 + 1.101 + static nsresult ParseNormalMIMETypesEntry(const nsAString& aEntry, 1.102 + nsAString::const_iterator& aMajorTypeStart, 1.103 + nsAString::const_iterator& aMajorTypeEnd, 1.104 + nsAString::const_iterator& aMinorTypeStart, 1.105 + nsAString::const_iterator& aMinorTypeEnd, 1.106 + nsAString& aExtensions, 1.107 + nsAString::const_iterator& aDescriptionStart, 1.108 + nsAString::const_iterator& aDescriptionEnd); 1.109 + 1.110 + static nsresult LookUpHandlerAndDescription(const nsAString& aMajorType, 1.111 + const nsAString& aMinorType, 1.112 + nsAString& aHandler, 1.113 + nsAString& aDescription, 1.114 + nsAString& aMozillaFlags); 1.115 + 1.116 + static nsresult DoLookUpHandlerAndDescription(const nsAString& aMajorType, 1.117 + const nsAString& aMinorType, 1.118 + nsAString& aHandler, 1.119 + nsAString& aDescription, 1.120 + nsAString& aMozillaFlags, 1.121 + bool aUserData); 1.122 + 1.123 + static nsresult GetHandlerAndDescriptionFromMailcapFile(const nsAString& aFilename, 1.124 + const nsAString& aMajorType, 1.125 + const nsAString& aMinorType, 1.126 + nsAString& aHandler, 1.127 + nsAString& aDescription, 1.128 + nsAString& aMozillaFlags); 1.129 +}; 1.130 + 1.131 +#endif // nsOSHelperAppService_h__