nsDocShellTransferableHooks.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #include "nsDocShellTransferableHooks.h"
  6. #include "nsIClipboardDragDropHooks.h"
  7. #include "nsIClipboardDragDropHookList.h"
  8. #include "nsArrayEnumerator.h"
  9. nsTransferableHookData::nsTransferableHookData()
  10. {
  11. }
  12. nsTransferableHookData::~nsTransferableHookData()
  13. {
  14. }
  15. NS_IMPL_ISUPPORTS(nsTransferableHookData, nsIClipboardDragDropHookList)
  16. NS_IMETHODIMP
  17. nsTransferableHookData::AddClipboardDragDropHooks(
  18. nsIClipboardDragDropHooks* aOverrides)
  19. {
  20. NS_ENSURE_ARG(aOverrides);
  21. // don't let a hook be added more than once
  22. if (mHookList.IndexOfObject(aOverrides) == -1) {
  23. if (!mHookList.AppendObject(aOverrides)) {
  24. return NS_ERROR_FAILURE;
  25. }
  26. }
  27. return NS_OK;
  28. }
  29. NS_IMETHODIMP
  30. nsTransferableHookData::RemoveClipboardDragDropHooks(
  31. nsIClipboardDragDropHooks* aOverrides)
  32. {
  33. NS_ENSURE_ARG(aOverrides);
  34. if (!mHookList.RemoveObject(aOverrides)) {
  35. return NS_ERROR_FAILURE;
  36. }
  37. return NS_OK;
  38. }
  39. NS_IMETHODIMP
  40. nsTransferableHookData::GetHookEnumerator(nsISimpleEnumerator** aResult)
  41. {
  42. return NS_NewArrayEnumerator(aResult, mHookList);
  43. }