Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
michael@0 | 3 | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | #ifndef mozilla_dom_Crypto_h |
michael@0 | 5 | #define mozilla_dom_Crypto_h |
michael@0 | 6 | |
michael@0 | 7 | #ifdef MOZ_DISABLE_CRYPTOLEGACY |
michael@0 | 8 | #include "nsIDOMCrypto.h" |
michael@0 | 9 | #else |
michael@0 | 10 | #include "nsIDOMCryptoLegacy.h" |
michael@0 | 11 | namespace mozilla { |
michael@0 | 12 | namespace dom { |
michael@0 | 13 | class CRMFObject; |
michael@0 | 14 | } |
michael@0 | 15 | } |
michael@0 | 16 | #endif |
michael@0 | 17 | |
michael@0 | 18 | #include "nsPIDOMWindow.h" |
michael@0 | 19 | |
michael@0 | 20 | #include "nsWrapperCache.h" |
michael@0 | 21 | #include "mozilla/dom/TypedArray.h" |
michael@0 | 22 | #define NS_DOMCRYPTO_CID \ |
michael@0 | 23 | {0x929d9320, 0x251e, 0x11d4, { 0x8a, 0x7c, 0x00, 0x60, 0x08, 0xc8, 0x44, 0xc3} } |
michael@0 | 24 | |
michael@0 | 25 | namespace mozilla { |
michael@0 | 26 | |
michael@0 | 27 | class ErrorResult; |
michael@0 | 28 | |
michael@0 | 29 | namespace dom { |
michael@0 | 30 | |
michael@0 | 31 | class Crypto : public nsIDOMCrypto, |
michael@0 | 32 | public nsWrapperCache |
michael@0 | 33 | { |
michael@0 | 34 | public: |
michael@0 | 35 | Crypto(); |
michael@0 | 36 | virtual ~Crypto(); |
michael@0 | 37 | |
michael@0 | 38 | NS_DECL_NSIDOMCRYPTO |
michael@0 | 39 | |
michael@0 | 40 | NS_DECL_CYCLE_COLLECTING_ISUPPORTS |
michael@0 | 41 | NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Crypto) |
michael@0 | 42 | |
michael@0 | 43 | void |
michael@0 | 44 | GetRandomValues(JSContext* aCx, const ArrayBufferView& aArray, |
michael@0 | 45 | JS::MutableHandle<JSObject*> aRetval, |
michael@0 | 46 | ErrorResult& aRv); |
michael@0 | 47 | |
michael@0 | 48 | #ifndef MOZ_DISABLE_CRYPTOLEGACY |
michael@0 | 49 | virtual bool EnableSmartCardEvents(); |
michael@0 | 50 | virtual void SetEnableSmartCardEvents(bool aEnable, ErrorResult& aRv); |
michael@0 | 51 | |
michael@0 | 52 | virtual void GetVersion(nsString& aVersion); |
michael@0 | 53 | |
michael@0 | 54 | virtual mozilla::dom::CRMFObject* |
michael@0 | 55 | GenerateCRMFRequest(JSContext* aContext, |
michael@0 | 56 | const nsCString& aReqDN, |
michael@0 | 57 | const nsCString& aRegToken, |
michael@0 | 58 | const nsCString& aAuthenticator, |
michael@0 | 59 | const nsCString& aEaCert, |
michael@0 | 60 | const nsCString& aJsCallback, |
michael@0 | 61 | const Sequence<JS::Value>& aArgs, |
michael@0 | 62 | ErrorResult& aRv); |
michael@0 | 63 | |
michael@0 | 64 | virtual void ImportUserCertificates(const nsAString& aNickname, |
michael@0 | 65 | const nsAString& aCmmfResponse, |
michael@0 | 66 | bool aDoForcedBackup, |
michael@0 | 67 | nsAString& aReturn, |
michael@0 | 68 | ErrorResult& aRv); |
michael@0 | 69 | |
michael@0 | 70 | virtual void SignText(JSContext* aContext, |
michael@0 | 71 | const nsAString& aStringToSign, |
michael@0 | 72 | const nsAString& aCaOption, |
michael@0 | 73 | const Sequence<nsCString>& aArgs, |
michael@0 | 74 | nsAString& aReturn); |
michael@0 | 75 | |
michael@0 | 76 | virtual void Logout(ErrorResult& aRv); |
michael@0 | 77 | |
michael@0 | 78 | #endif |
michael@0 | 79 | |
michael@0 | 80 | // WebIDL |
michael@0 | 81 | |
michael@0 | 82 | nsPIDOMWindow* |
michael@0 | 83 | GetParentObject() const |
michael@0 | 84 | { |
michael@0 | 85 | return mWindow; |
michael@0 | 86 | } |
michael@0 | 87 | |
michael@0 | 88 | virtual JSObject* |
michael@0 | 89 | WrapObject(JSContext* aCx) MOZ_OVERRIDE; |
michael@0 | 90 | |
michael@0 | 91 | static uint8_t* |
michael@0 | 92 | GetRandomValues(uint32_t aLength); |
michael@0 | 93 | |
michael@0 | 94 | private: |
michael@0 | 95 | nsCOMPtr<nsPIDOMWindow> mWindow; |
michael@0 | 96 | }; |
michael@0 | 97 | |
michael@0 | 98 | } // namespace dom |
michael@0 | 99 | } // namespace mozilla |
michael@0 | 100 | |
michael@0 | 101 | #endif // mozilla_dom_Crypto_h |