summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorabarth@chromium.org <abarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-21 01:34:44 +0000
committerabarth@chromium.org <abarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-21 01:34:44 +0000
commit7753518221d970398c094e977ba2e266c25284f7 (patch)
treed33634ad5adf46ab9c7a4f6189b3e901631b0d41
parent3fdb88af96cfe039f666c05c71b160fa239b2d75 (diff)
downloadchromium_src-7753518221d970398c094e977ba2e266c25284f7.zip
chromium_src-7753518221d970398c094e977ba2e266c25284f7.tar.gz
chromium_src-7753518221d970398c094e977ba2e266c25284f7.tar.bz2
Hook up Context::GetCalling() to V8Proxy.
R=aa TEST=This will eventually be covered by layout tests once I change the upstream code to use this API. Review URL: http://codereview.chromium.org/113672 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16564 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--webkit/port/bindings/v8/v8_proxy.cpp9
-rw-r--r--webkit/port/bindings/v8/v8_proxy.h17
2 files changed, 23 insertions, 3 deletions
diff --git a/webkit/port/bindings/v8/v8_proxy.cpp b/webkit/port/bindings/v8/v8_proxy.cpp
index 03c657d..3f6aa21 100644
--- a/webkit/port/bindings/v8/v8_proxy.cpp
+++ b/webkit/port/bindings/v8/v8_proxy.cpp
@@ -1653,6 +1653,15 @@ Frame* V8Proxy::retrieveFrameForCurrentContext()
}
+Frame* V8Proxy::retrieveFrameForCallingContext()
+{
+ v8::Handle<v8::Context> context = v8::Context::GetCalling();
+ if (context.IsEmpty())
+ return 0;
+ return retrieveFrame(context);
+}
+
+
Frame* V8Proxy::retrieveFrame()
{
DOMWindow* window = retrieveWindow();
diff --git a/webkit/port/bindings/v8/v8_proxy.h b/webkit/port/bindings/v8/v8_proxy.h
index 4cb6892..c2bb66f 100644
--- a/webkit/port/bindings/v8/v8_proxy.h
+++ b/webkit/port/bindings/v8/v8_proxy.h
@@ -285,9 +285,9 @@ class V8Proxy {
static Frame* retrieveFrame(v8::Handle<v8::Context> context);
- // The two functions below retrieve WebFrame instances relating the currently
- // executing JavaScript. Since JavaScript can make function calls across
- // frames, though, we need to be more precise.
+ // The three functions below retrieve WebFrame instances relating the
+ // currently executing JavaScript. Since JavaScript can make function calls
+ // across frames, though, we need to be more precise.
//
// For example, imagine that a JS function in frame A calls a function in
// frame B, which calls native code, which wants to know what the 'active'
@@ -296,15 +296,26 @@ class V8Proxy {
// The 'entered context' is the context where execution first entered the
// script engine; the context that is at the bottom of the JS function stack.
// RetrieveFrameForEnteredContext() would return Frame A in our example.
+ // This frame is often referred to as the "dynamic global object."
//
// The 'current context' is the context the JS engine is currently inside of;
// the context that is at the top of the JS function stack.
// RetrieveFrameForCurrentContext() would return Frame B in our example.
+ // This frame is often referred to as the "lexical global object."
+ //
+ // Finally, the 'calling context' is the context one below the current
+ // context on the JS function stack. For example, if function f calls
+ // function g, then the calling context will be the context associated with
+ // f. This context is commonly used by DOM security checks because they want
+ // to know who called them.
+ //
+ // If you are unsure which of these functions to use, ask abarth.
//
// NOTE: These cannot be declared as inline function, because VS complains at
// linking time.
static Frame* retrieveFrameForEnteredContext();
static Frame* retrieveFrameForCurrentContext();
+ static Frame* retrieveFrameForCallingContext();
// Returns V8 Context of a frame. If none exists, creates
// a new context. It is potentially slow and consumes memory.