nsKeygenHandlerContent.cpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2. *
  3. * This Source Code Form is subject to the terms of the Mozilla Public
  4. * License, v. 2.0. If a copy of the MPL was not distributed with this
  5. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  6. #include "nsKeygenHandlerContent.h"
  7. #include "nsIFormProcessor.h"
  8. #include "nsString.h"
  9. #include "mozilla/dom/ContentChild.h"
  10. #include "mozilla/Unused.h"
  11. #include "keythi.h"
  12. #include "nss.h"
  13. #include "secmodt.h"
  14. #include "nsKeygenHandler.h"
  15. using mozilla::dom::ContentChild;
  16. using mozilla::Unused;
  17. NS_IMPL_ISUPPORTS(nsKeygenFormProcessorContent, nsIFormProcessor)
  18. nsKeygenFormProcessorContent::nsKeygenFormProcessorContent()
  19. {
  20. }
  21. nsKeygenFormProcessorContent::~nsKeygenFormProcessorContent()
  22. {
  23. }
  24. nsresult
  25. nsKeygenFormProcessorContent::ProcessValue(nsIDOMHTMLElement* aElement,
  26. const nsAString& aName,
  27. nsAString& aValue)
  28. {
  29. nsAutoString challengeValue;
  30. nsAutoString keyTypeValue;
  31. nsAutoString keyParamsValue;
  32. nsKeygenFormProcessor::ExtractParams(aElement, challengeValue, keyTypeValue, keyParamsValue);
  33. ContentChild* child = ContentChild::GetSingleton();
  34. nsString oldValue(aValue);
  35. nsString newValue;
  36. Unused << child->SendKeygenProcessValue(oldValue, challengeValue,
  37. keyTypeValue, keyParamsValue,
  38. &newValue);
  39. aValue.Assign(newValue);
  40. return NS_OK;
  41. }
  42. nsresult
  43. nsKeygenFormProcessorContent::ProcessValueIPC(const nsAString& aOldValue,
  44. const nsAString& aChallenge,
  45. const nsAString& aKeyType,
  46. const nsAString& aKeyParams,
  47. nsAString& aNewValue)
  48. {
  49. MOZ_ASSERT(false, "should never be called in the child process");
  50. return NS_ERROR_UNEXPECTED;
  51. }
  52. nsresult
  53. nsKeygenFormProcessorContent::ProvideContent(const nsAString& aFormType,
  54. nsTArray<nsString>& aContent,
  55. nsAString& aAttribute)
  56. {
  57. nsString attribute;
  58. Unused <<
  59. ContentChild::GetSingleton()->SendKeygenProvideContent(&attribute,
  60. &aContent);
  61. aAttribute.Assign(attribute);
  62. return NS_OK;
  63. }