2013-11-06 09:53:19 -08:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
|
|
|
/* 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/. */
|
|
|
|
|
|
|
|
/* Copyright © 2013 Deutsche Telekom, Inc. */
|
|
|
|
|
2014-01-28 16:20:17 -08:00
|
|
|
#ifndef mozilla_dom_MozNDEFRecord_h__
|
|
|
|
#define mozilla_dom_MozNDEFRecord_h__
|
2013-11-06 09:53:19 -08:00
|
|
|
|
|
|
|
#include "mozilla/Attributes.h"
|
|
|
|
#include "mozilla/ErrorResult.h"
|
|
|
|
#include "nsCycleCollectionParticipant.h"
|
|
|
|
#include "nsWrapperCache.h"
|
|
|
|
#include "jsapi.h"
|
|
|
|
|
2014-08-20 02:35:18 -07:00
|
|
|
#include "mozilla/dom/MozNDEFRecordBinding.h"
|
2013-11-08 15:10:23 -08:00
|
|
|
#include "mozilla/dom/TypedArray.h"
|
|
|
|
#include "jsfriendapi.h"
|
|
|
|
#include "js/GCAPI.h"
|
2014-08-18 07:44:50 -07:00
|
|
|
#include "nsPIDOMWindow.h"
|
2013-11-08 15:10:23 -08:00
|
|
|
|
2013-11-06 09:53:19 -08:00
|
|
|
struct JSContext;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2014-08-17 23:56:12 -07:00
|
|
|
class MozNDEFRecordOptions;
|
|
|
|
|
2014-01-28 16:20:17 -08:00
|
|
|
class MozNDEFRecord MOZ_FINAL : public nsISupports,
|
2013-11-06 09:53:19 -08:00
|
|
|
public nsWrapperCache
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
2014-01-28 16:20:17 -08:00
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(MozNDEFRecord)
|
2013-11-06 09:53:19 -08:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2014-08-17 23:56:12 -07:00
|
|
|
MozNDEFRecord(JSContext* aCx, nsPIDOMWindow* aWindow,
|
|
|
|
const MozNDEFRecordOptions& aOptions);
|
2013-11-06 09:53:19 -08:00
|
|
|
|
2014-01-28 16:20:17 -08:00
|
|
|
~MozNDEFRecord();
|
2013-11-06 09:53:19 -08:00
|
|
|
|
|
|
|
nsIDOMWindow* GetParentObject() const
|
|
|
|
{
|
|
|
|
return mWindow;
|
|
|
|
}
|
|
|
|
|
2014-04-08 15:27:18 -07:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
|
2013-11-06 09:53:19 -08:00
|
|
|
|
2014-01-28 16:20:17 -08:00
|
|
|
static already_AddRefed<MozNDEFRecord>
|
2014-08-17 23:56:12 -07:00
|
|
|
Constructor(const GlobalObject& aGlobal,
|
|
|
|
const MozNDEFRecordOptions& aOptions,
|
|
|
|
ErrorResult& aRv);
|
2013-11-06 09:53:19 -08:00
|
|
|
|
2014-08-20 02:35:18 -07:00
|
|
|
TNF Tnf() const
|
2013-11-06 09:53:19 -08:00
|
|
|
{
|
|
|
|
return mTnf;
|
|
|
|
}
|
|
|
|
|
2014-06-11 13:26:52 -07:00
|
|
|
void GetType(JSContext* cx, JS::MutableHandle<JSObject*> retval) const
|
2013-11-08 15:10:23 -08:00
|
|
|
{
|
2014-02-19 23:08:46 -08:00
|
|
|
if (mType) {
|
2014-06-11 13:26:52 -07:00
|
|
|
JS::ExposeObjectToActiveJS(mType);
|
2014-02-19 23:08:46 -08:00
|
|
|
}
|
2014-06-11 13:26:52 -07:00
|
|
|
retval.set(mType);
|
2013-11-06 09:53:19 -08:00
|
|
|
}
|
|
|
|
|
2014-06-11 13:26:52 -07:00
|
|
|
void GetId(JSContext* cx, JS::MutableHandle<JSObject*> retval) const
|
2013-11-06 09:53:19 -08:00
|
|
|
{
|
2014-02-19 23:08:46 -08:00
|
|
|
if (mId) {
|
2014-06-11 13:26:52 -07:00
|
|
|
JS::ExposeObjectToActiveJS(mId);
|
2014-02-19 23:08:46 -08:00
|
|
|
}
|
2014-06-11 13:26:52 -07:00
|
|
|
retval.set(mId);
|
2013-11-06 09:53:19 -08:00
|
|
|
}
|
|
|
|
|
2014-06-11 13:26:52 -07:00
|
|
|
void GetPayload(JSContext* cx, JS::MutableHandle<JSObject*> retval) const
|
2013-11-08 15:10:23 -08:00
|
|
|
{
|
2014-02-19 23:08:46 -08:00
|
|
|
if (mPayload) {
|
2014-06-11 13:26:52 -07:00
|
|
|
JS::ExposeObjectToActiveJS(mPayload);
|
2014-02-19 23:08:46 -08:00
|
|
|
}
|
2014-06-11 13:26:52 -07:00
|
|
|
retval.set(mPayload);
|
2013-11-06 09:53:19 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2014-01-28 16:20:17 -08:00
|
|
|
MozNDEFRecord() MOZ_DELETE;
|
2013-11-06 09:53:19 -08:00
|
|
|
nsRefPtr<nsPIDOMWindow> mWindow;
|
2013-11-08 15:10:23 -08:00
|
|
|
void HoldData();
|
|
|
|
void DropData();
|
2013-11-06 09:53:19 -08:00
|
|
|
|
2014-08-28 01:44:48 -07:00
|
|
|
static bool
|
|
|
|
ValidateTNF(const MozNDEFRecordOptions& aOptions, ErrorResult& aRv);
|
|
|
|
|
2014-08-20 02:35:18 -07:00
|
|
|
TNF mTnf;
|
2013-11-08 15:10:23 -08:00
|
|
|
JS::Heap<JSObject*> mType;
|
|
|
|
JS::Heap<JSObject*> mId;
|
|
|
|
JS::Heap<JSObject*> mPayload;
|
2013-11-06 09:53:19 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2014-01-28 16:20:17 -08:00
|
|
|
#endif // mozilla_dom_MozNDEFRecord_h__
|