Skip to content

Commit

Permalink
move WrapObject from Credential to PasswordCredential and FederatedCr…
Browse files Browse the repository at this point in the history
…edential
  • Loading branch information
AxelNennker committed Aug 16, 2015
1 parent 912b405 commit 770200e
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 46 deletions.
2 changes: 1 addition & 1 deletion Navigator.cpp.patch
Expand Up @@ -19,7 +19,7 @@ diff --git a/dom/base/Navigator.cpp b/dom/base/Navigator.cpp
#include "mozilla/dom/IccManager.h"
#include "mozilla/dom/InputPortManager.h"
#include "mozilla/dom/MobileMessageManager.h"
@@ -992,16 +993,27 @@ Navigator::GetDeviceStorageByNameAndType
@@ -1013,16 +1014,27 @@ Navigator::GetDeviceStorageByNameAndType
if (!storage) {
return nullptr;
}
Expand Down
32 changes: 0 additions & 32 deletions credentials/Credential.cpp
Expand Up @@ -41,38 +41,6 @@ Credential::Credential(nsIGlobalObject* aGlobal, const CredentialData& data)
}
}

#if 0
bool
Credential::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
{
if (mType.EqualsASCII("federated")) {
return FederatedCredentialBinding::Wrap(aCx, this, aGivenProto, aReflector);
} else {
if (mType.EqualsASCII("password")) {
return PasswordCredentialBinding::Wrap(aCx, this, aGivenProto, aReflector);
} else {
// FIXME throw?
return false;
}
}
}
#else
JSObject*
Credential::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
{
if (mType.EqualsASCII("federated")) {
return FederatedCredentialBinding::Wrap(aCx, this, aGivenProto);
} else {
if (mType.EqualsASCII("password")) {
return PasswordCredentialBinding::Wrap(aCx, this, aGivenProto);
} else {
// FIXME throw?
return NULL;
}
}
}
#endif

static bool isInherentlyInsecure(nsIDOMLocation* aLocation)
{
DOMString protocol;
Expand Down
8 changes: 0 additions & 8 deletions credentials/Credential.h
Expand Up @@ -10,8 +10,6 @@
#include "nsIGlobalObject.h"
#include "mozilla/dom/Promise.h"

#include "nsWrapperCache.h"

namespace mozilla {
class ErrorResult;
namespace dom {
Expand All @@ -33,7 +31,6 @@ namespace mozilla {
namespace dom {

class Credential : public nsISupports /* or NonRefcountedDOMObject if this is a non-refcounted object */
, public nsWrapperCache
{
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
Expand All @@ -50,11 +47,6 @@ class Credential : public nsISupports /* or NonRefcountedDOMObject if this is a
nsString mType;
public:
nsIGlobalObject* GetParentObject() const { return mGlobal; }
#if 0
virtual bool WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) override;
#else
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto);
#endif

static already_AddRefed<Credential> Constructor(const GlobalObject& global, const CredentialData& data, ErrorResult& aRv);

Expand Down
19 changes: 18 additions & 1 deletion credentials/FederatedCredential.cpp
Expand Up @@ -4,10 +4,13 @@
* 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/. */

#include "mozilla/dom/CredentialContainerBinding.h"
#include "mozilla/dom/FederatedCredential.h"

#include "mozilla/dom/CredentialContainerBinding.h"
#include "mozilla/dom/LocallyStoredCredential.h"

#include "nsWrapperCache.h"

namespace mozilla {
namespace dom {

Expand All @@ -17,6 +20,20 @@ NS_IMPL_RELEASE_INHERITED(FederatedCredential, LocallyStoredCredential)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(FederatedCredential)
NS_INTERFACE_MAP_END_INHERITING(LocallyStoredCredential)

#if 0
bool
FederatedCredential::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
{
return FederatedCredentialBinding::Wrap(aCx, this, aGivenProto, aReflector);
}
#else
JSObject*
FederatedCredential::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
{
return FederatedCredentialBinding::Wrap(aCx, this, aGivenProto);
}
#endif

FederatedCredential::FederatedCredential()
{
// Add |MOZ_COUNT_CTOR(FederatedCredential);| for a non-refcounted object.
Expand Down
7 changes: 7 additions & 0 deletions credentials/FederatedCredential.h
Expand Up @@ -19,6 +19,7 @@ namespace mozilla {
namespace dom {

class FederatedCredential : public LocallyStoredCredential
, public nsWrapperCache
{
public:
NS_DECL_ISUPPORTS_INHERITED
Expand All @@ -33,6 +34,12 @@ class FederatedCredential : public LocallyStoredCredential
nsString mProtocol;

public:
#if 0
virtual bool WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) override;
#else
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto);
#endif

static already_AddRefed<FederatedCredential> Constructor(const GlobalObject& global, const FederatedCredentialData& data, ErrorResult& aRv);

void GetProvider(nsString& aRetVal) const { aRetVal = mProvider; }
Expand Down
18 changes: 17 additions & 1 deletion credentials/PasswordCredential.cpp
@@ -1,5 +1,7 @@
#include "PasswordCredential.h"

#include "nsWrapperCache.h"

#include "mozilla/dom/CredentialContainerBinding.h"
#include "mozilla/dom/FetchBinding.h"
#include "mozilla/dom/RequestBinding.h"
Expand Down Expand Up @@ -38,6 +40,20 @@ PasswordCredential::PasswordCredential(nsIGlobalObject* aGlobal, const PasswordC
}
}

#if 0
bool
PasswordCredential::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
{
return PasswordCredentialBinding::Wrap(aCx, this, aGivenProto, aReflector);
}
#else
JSObject*
PasswordCredential::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
{
return PasswordCredentialBinding::Wrap(aCx, this, aGivenProto);
}
#endif

/*
bool isInherentlyInsecure(nsIDOMLocation* aLocation)
{
Expand Down Expand Up @@ -69,7 +85,7 @@ PasswordCredential::Constructor(const GlobalObject& aGlobal,
nsIDOMLocation* location;
nsresult rv = window->GetLocation(&location);
NS_ENSURE_SUCCESS(rv, nullptr);
if (Credential::isInherentlyInsecure(location)) {
if (isInherentlyInsecure(location)) {
NS_WARNING("Do not use PasswordCredential on inherently insecure pages");
}
nsRefPtr<PasswordCredential> ret = new PasswordCredential(global, data);
Expand Down
7 changes: 7 additions & 0 deletions credentials/PasswordCredential.h
Expand Up @@ -32,6 +32,7 @@ namespace mozilla {
namespace dom {

class PasswordCredential final : public LocallyStoredCredential
, public nsWrapperCache
{
public:
NS_DECL_ISUPPORTS_INHERITED
Expand All @@ -43,6 +44,12 @@ class PasswordCredential final : public LocallyStoredCredential
~PasswordCredential();
nsString mPassword;
public:
#if 0
virtual bool WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) override;
#else
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto);
#endif

static already_AddRefed<PasswordCredential> Constructor(const GlobalObject& global, const PasswordCredentialData& data, ErrorResult& aRv);

void GetPassword(nsString& aRetVal) const { aRetVal = mPassword; }
Expand Down
6 changes: 3 additions & 3 deletions webidl-moz.build.patch
@@ -1,21 +1,21 @@
diff --git a/dom/webidl/moz.build b/dom/webidl/moz.build
--- a/dom/webidl/moz.build
+++ b/dom/webidl/moz.build
@@ -83,16 +83,17 @@ WEBIDL_FILES = [
'Comment.webidl',
@@ -84,16 +84,17 @@ WEBIDL_FILES = [
'CompositionEvent.webidl',
'Console.webidl',
'Constraints.webidl',
'Contacts.webidl',
'ContainerBoxObject.webidl',
'ConvolverNode.webidl',
'Coordinates.webidl',
+ 'CredentialContainer.webidl',
'CreateOfferRequest.webidl',
+ 'CredentialContainer.webidl',
'Crypto.webidl',
'CSPDictionaries.webidl',
'CSPReport.webidl',
'CSS.webidl',
'CSSAnimation.webidl',
'CSSLexer.webidl',
'CSSPrimitiveValue.webidl',
'CSSRuleList.webidl',

0 comments on commit 770200e

Please sign in to comment.