uriloader/exthandler/win/nsOSHelperAppService.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/uriloader/exthandler/win/nsOSHelperAppService.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,66 @@
     1.4 +/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 2 -*-
     1.5 + * This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef nsOSHelperAppService_h__
    1.10 +#define nsOSHelperAppService_h__
    1.11 +
    1.12 +// The OS helper app service is a subclass of nsExternalHelperAppService and is implemented on each
    1.13 +// platform. It contains platform specific code for finding helper applications for a given mime type
    1.14 +// in addition to launching those applications.
    1.15 +
    1.16 +#include "nsExternalHelperAppService.h"
    1.17 +#include "nsCExternalHandlerService.h"
    1.18 +#include "nsMIMEInfoImpl.h"
    1.19 +#include "nsCOMPtr.h"
    1.20 +#include <windows.h>
    1.21 +
    1.22 +#ifdef _WIN32_WINNT
    1.23 +#undef _WIN32_WINNT
    1.24 +#endif
    1.25 +#define _WIN32_WINNT 0x0600
    1.26 +#include <shlobj.h>
    1.27 +
    1.28 +class nsMIMEInfoWin;
    1.29 +
    1.30 +class nsOSHelperAppService : public nsExternalHelperAppService
    1.31 +{
    1.32 +public:
    1.33 +  nsOSHelperAppService();
    1.34 +  virtual ~nsOSHelperAppService();
    1.35 +
    1.36 +  // override nsIExternalProtocolService methods
    1.37 +  nsresult OSProtocolHandlerExists(const char * aProtocolScheme, bool * aHandlerExists);
    1.38 +  nsresult LoadUriInternal(nsIURI * aURL);
    1.39 +  NS_IMETHOD GetApplicationDescription(const nsACString& aScheme, nsAString& _retval);
    1.40 +
    1.41 +  // method overrides for windows registry look up steps....
    1.42 +  already_AddRefed<nsIMIMEInfo> GetMIMEInfoFromOS(const nsACString& aMIMEType, const nsACString& aFileExt, bool *aFound);
    1.43 +  NS_IMETHOD GetProtocolHandlerInfoFromOS(const nsACString &aScheme, 
    1.44 +                                          bool *found,
    1.45 +                                          nsIHandlerInfo **_retval);
    1.46 +
    1.47 +  /** Get the string value of a registry value and store it in result.
    1.48 +   * @return true on success, false on failure
    1.49 +   */
    1.50 +  static bool GetValueString(HKEY hKey, const char16_t* pValueName, nsAString& result);
    1.51 +
    1.52 +  // Removes registry command handler parameters, quotes, and expands environment strings.
    1.53 +  static bool CleanupCmdHandlerPath(nsAString& aCommandHandler);
    1.54 +
    1.55 +protected:
    1.56 +  nsresult GetDefaultAppInfo(const nsAString& aTypeName, nsAString& aDefaultDescription, nsIFile** aDefaultApplication);
    1.57 +  // Lookup a mime info by extension, using an optional type hint
    1.58 +  already_AddRefed<nsMIMEInfoWin> GetByExtension(const nsAFlatString& aFileExt, const char *aTypeHint = nullptr);
    1.59 +  nsresult FindOSMimeInfoForType(const char * aMimeContentType, nsIURI * aURI, char ** aFileExtension, nsIMIMEInfo ** aMIMEInfo);
    1.60 +
    1.61 +  static nsresult GetMIMEInfoFromRegistry(const nsAFlatString& fileType, nsIMIMEInfo *pInfo);
    1.62 +  /// Looks up the type for the extension aExt and compares it to aType
    1.63 +  static bool typeFromExtEquals(const char16_t* aExt, const char *aType);
    1.64 +
    1.65 +private:
    1.66 +  IApplicationAssociationRegistration* mAppAssoc;
    1.67 +};
    1.68 +
    1.69 +#endif // nsOSHelperAppService_h__

mercurial