зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1218454 - part 3 - move nsILoadContext::GetOriginAttributes out-of-line; r=bz
This commit is contained in:
Родитель
3071ec2419
Коммит
1c2e83fc5a
|
@ -7,7 +7,34 @@
|
|||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/LoadContext.h"
|
||||
#include "mozilla/dom/ScriptSettings.h" // for AutoJSAPI
|
||||
#include "nsContentUtils.h"
|
||||
#include "xpcpublic.h"
|
||||
|
||||
bool
|
||||
nsILoadContext::GetOriginAttributes(mozilla::DocShellOriginAttributes& aAttrs)
|
||||
{
|
||||
mozilla::dom::AutoJSAPI jsapi;
|
||||
bool ok = jsapi.Init(xpc::PrivilegedJunkScope());
|
||||
NS_ENSURE_TRUE(ok, false);
|
||||
JS::Rooted<JS::Value> v(jsapi.cx());
|
||||
nsresult rv = GetOriginAttributes(&v);
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
NS_ENSURE_TRUE(v.isObject(), false);
|
||||
JS::Rooted<JSObject*> obj(jsapi.cx(), &v.toObject());
|
||||
|
||||
// If we're JS-implemented, the object will be left in a different (System-Principaled)
|
||||
// scope, so we may need to enter its compartment.
|
||||
MOZ_ASSERT(nsContentUtils::IsSystemPrincipal(nsContentUtils::ObjectPrincipal(obj)));
|
||||
JSAutoCompartment ac(jsapi.cx(), obj);
|
||||
|
||||
mozilla::DocShellOriginAttributes attrs;
|
||||
ok = attrs.Init(jsapi.cx(), v);
|
||||
NS_ENSURE_TRUE(ok, false);
|
||||
aAttrs = attrs;
|
||||
return true;
|
||||
}
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
NS_IMPL_ISUPPORTS(LoadContext, nsILoadContext, nsIInterfaceRequestor)
|
||||
|
|
|
@ -12,9 +12,6 @@ interface nsIDOMElement;
|
|||
%{C++
|
||||
#ifdef MOZILLA_INTERNAL_API
|
||||
#include "mozilla/BasePrincipal.h" // for DocShellOriginAttributes
|
||||
#include "mozilla/dom/ScriptSettings.h" // for AutoJSAPI
|
||||
#include "xpcpublic.h" // for PrivilegedJunkScope
|
||||
#include "nsContentUtils.h" // for IsSystemPrincipal
|
||||
#endif
|
||||
%}
|
||||
|
||||
|
@ -23,7 +20,7 @@ interface nsIDOMElement;
|
|||
* can be queried for various information about where the load is
|
||||
* happening.
|
||||
*/
|
||||
[scriptable, uuid(96014778-d30b-4fee-8902-a3481788907b)]
|
||||
[scriptable, uuid(c71ef717-8fb9-425e-98ef-aef5894890f8)]
|
||||
interface nsILoadContext : nsISupports
|
||||
{
|
||||
/**
|
||||
|
@ -139,30 +136,10 @@ interface nsILoadContext : nsISupports
|
|||
#ifdef MOZILLA_INTERNAL_API
|
||||
/**
|
||||
* The C++ getter for origin attributes.
|
||||
*
|
||||
* Defined in LoadContext.cpp
|
||||
*/
|
||||
bool GetOriginAttributes(mozilla::DocShellOriginAttributes& aAttrs)
|
||||
{
|
||||
mozilla::dom::AutoJSAPI jsapi;
|
||||
bool ok = jsapi.Init(xpc::PrivilegedJunkScope());
|
||||
NS_ENSURE_TRUE(ok, false);
|
||||
JS::Rooted<JS::Value> v(jsapi.cx());
|
||||
nsresult rv = GetOriginAttributes(&v);
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
NS_ENSURE_TRUE(v.isObject(), false);
|
||||
JS::Rooted<JSObject*> obj(jsapi.cx(), &v.toObject());
|
||||
|
||||
// If we're JS-implemented, the object will be left in a different (System-Principaled)
|
||||
// scope, so we may need to enter its compartment.
|
||||
MOZ_ASSERT(nsContentUtils::IsSystemPrincipal(nsContentUtils::ObjectPrincipal(obj)));
|
||||
JSAutoCompartment ac(jsapi.cx(), obj);
|
||||
|
||||
mozilla::DocShellOriginAttributes attrs;
|
||||
ok = attrs.Init(jsapi.cx(), v);
|
||||
NS_ENSURE_TRUE(ok, false);
|
||||
aAttrs = attrs;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GetOriginAttributes(mozilla::DocShellOriginAttributes& aAttrs);
|
||||
#endif
|
||||
%}
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче