toolkit/mozapps/extensions/AddonPathService.h
author Daniel Holbert <dholbert@cs.stanford.edu>
Fri, 27 May 2016 16:34:16 -0700
changeset 299394 4224b7714822e13b16c0c6508f3d1b6090bb38a7
parent 234863 ac4464790ec4896a5188fa50cfc69ae0ffeddc08
child 388267 3feb5338f65c83d2af52fb8a53f866155e88dc15
permissions -rw-r--r--
Bug 1261964 part 4: Bump fuzzy threshold for new reftest, to accommodate extra fuzziness on WinXP. DONTBUILD MozReview-Commit-ID: 2RrNqbXU0hN

//* -*- Mode: C++; tab-width: 8; 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 AddonPathService_h
#define AddonPathService_h

#include "amIAddonPathService.h"
#include "nsString.h"
#include "nsTArray.h"

class nsIURI;
class JSAddonId;

namespace mozilla {

JSAddonId*
MapURIToAddonID(nsIURI* aURI);

class AddonPathService final : public amIAddonPathService
{
public:
  AddonPathService();

  static AddonPathService* GetInstance();

  JSAddonId* Find(const nsAString& path);
  static JSAddonId* FindAddonId(const nsAString& path);

  NS_DECL_ISUPPORTS
  NS_DECL_AMIADDONPATHSERVICE

  struct PathEntry
  {
    nsString mPath;
    JSAddonId* mAddonId;

    PathEntry(const nsAString& aPath, JSAddonId* aAddonId)
     : mPath(aPath), mAddonId(aAddonId)
    {}
  };

private:
  virtual ~AddonPathService();

  // Paths are stored sorted in order of their mPath.
  nsTArray<PathEntry> mPaths;

  static AddonPathService* sInstance;
};

} // namespace mozilla

#endif