uriloader/exthandler/win/nsMIMEInfoWin.h
author James Teh <jteh@mozilla.com>
Wed, 01 Feb 2023 05:02:01 +0000
changeset 651150 dd0fdd1daa69783be36acd5c50544f3694eaa8f9
parent 533828 1e4f8d9d96ce1ccb79c154416b119907f9479294
permissions -rw-r--r--
Bug 1813980: Check IsDoc before Parent in RemoteAccessibleBase::ApplyCrossDocOffset. r=morgan We call this function on every ancestor when calculating bounds. RemoteParent() currently requires a hash lookup, so it's more efficient to early return for !IsDoc() first. This is a micro-optimisation, but it might have some impact given that we call this on every ancestor, especially when hit testing, where we call Bounds() a lot. As a bit of drive-by cleanup, use RemoteParent() rather than calling Parent() and IsRemote/AsRemote(). Differential Revision: https://phabricator.services.mozilla.com/D168346

/* 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 nsMIMEInfoWin_h_
#define nsMIMEInfoWin_h_

#include "nsMIMEInfoImpl.h"
#include "nsIPropertyBag.h"
#include "nsIMutableArray.h"
#include "nsTArray.h"

class nsMIMEInfoWin : public nsMIMEInfoBase, public nsIPropertyBag {
  virtual ~nsMIMEInfoWin();

 public:
  explicit nsMIMEInfoWin(const char* aType = "") : nsMIMEInfoBase(aType) {}
  explicit nsMIMEInfoWin(const nsACString& aMIMEType)
      : nsMIMEInfoBase(aMIMEType) {}
  nsMIMEInfoWin(const nsACString& aType, HandlerClass aClass)
      : nsMIMEInfoBase(aType, aClass) {}

  NS_IMETHOD LaunchWithFile(nsIFile* aFile) override;
  NS_IMETHOD GetHasDefaultHandler(bool* _retval) override;
  NS_IMETHOD GetPossibleLocalHandlers(nsIArray** _retval) override;
  NS_IMETHOD IsCurrentAppOSDefault(bool* _retval) override;

  NS_DECL_ISUPPORTS_INHERITED
  NS_DECL_NSIPROPERTYBAG

  void SetDefaultApplicationHandler(nsIFile* aDefaultApplication) {
    mDefaultApplication = aDefaultApplication;
  }

 protected:
  virtual nsresult LoadUriInternal(nsIURI* aURI);
  virtual nsresult LaunchDefaultWithFile(nsIFile* aFile);

 private:
  nsCOMPtr<nsIFile> mDefaultApplication;

  // Given a path to a local handler, return its
  // nsILocalHandlerApp instance.
  bool GetLocalHandlerApp(const nsAString& aCommandHandler,
                          nsCOMPtr<nsILocalHandlerApp>& aApp);

  // Return the cleaned up file path associated
  // with a command verb located in root/Applications.
  bool GetAppsVerbCommandHandler(const nsAString& appExeName,
                                 nsAString& applicationPath, bool bEdit);

  // Return the cleaned up file path associated
  // with a progid command verb located in root.
  bool GetProgIDVerbCommandHandler(const nsAString& appProgIDName,
                                   nsAString& applicationPath, bool bEdit);

  // Lookup a rundll command handler and return
  // a populated command template for use with rundll32.exe.
  bool GetDllLaunchInfo(nsIFile* aDll, nsIFile* aFile, nsAString& args,
                        bool bEdit);

  // Helper routine used in tracking app lists
  void ProcessPath(nsCOMPtr<nsIMutableArray>& appList,
                   nsTArray<nsString>& trackList,
                   const nsAString& appFilesystemCommand);

  // Helper routine to call mozilla::ShellExecuteByExplorer
  nsresult ShellExecuteWithIFile(nsIFile* aExecutable, int aArgc,
                                 const wchar_t** aArgv);
};

#endif