diff options
author | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-12 00:48:58 +0000 |
---|---|---|
committer | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-12 00:48:58 +0000 |
commit | 9a7b22e6fb1d115a694616fd5a12bfe6e491664b (patch) | |
tree | 505bc1a11530c975bf45588b19aa6c3cfbc36c13 /webkit/glue | |
parent | 08da43b40e557c42b93fe490e91ab44a73d7e0dd (diff) | |
download | chromium_src-9a7b22e6fb1d115a694616fd5a12bfe6e491664b.zip chromium_src-9a7b22e6fb1d115a694616fd5a12bfe6e491664b.tar.gz chromium_src-9a7b22e6fb1d115a694616fd5a12bfe6e491664b.tar.bz2 |
Split V8Proxy::retrieveActiveFrame() into two methods.
We now have RetrieveFrameForCurrentContext() and
RetrieveFrameForEnteredContext().
These terms means the same thing they do in V8::Context --
'current' is the top of the js stack and 'entered' is the
bottom.
I needed 'entered' to fix a bug in extensions where if you
call an extension API through the web inspector we get
confused and think the web inspector's view is the one who
called.
Review URL: http://codereview.chromium.org/113085
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15828 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue')
-rw-r--r-- | webkit/glue/devtools/debugger_agent_manager.cc | 2 | ||||
-rw-r--r-- | webkit/glue/webdevtoolsclient_impl.cc | 4 | ||||
-rw-r--r-- | webkit/glue/webframe.h | 18 | ||||
-rw-r--r-- | webkit/glue/webframe_impl.cc | 15 |
4 files changed, 33 insertions, 6 deletions
diff --git a/webkit/glue/devtools/debugger_agent_manager.cc b/webkit/glue/devtools/debugger_agent_manager.cc index aa692aa..41461c8 100644 --- a/webkit/glue/devtools/debugger_agent_manager.cc +++ b/webkit/glue/devtools/debugger_agent_manager.cc @@ -235,7 +235,7 @@ DebuggerAgentImpl* DebuggerAgentManager::FindAgentForCurrentV8Context() { } DCHECK(!attached_agents_->isEmpty()); - WebCore::Frame* frame = WebCore::V8Proxy::retrieveActiveFrame(); + WebCore::Frame* frame = WebCore::V8Proxy::retrieveFrameForEnteredContext(); if (!frame) { return NULL; } diff --git a/webkit/glue/webdevtoolsclient_impl.cc b/webkit/glue/webdevtoolsclient_impl.cc index d887022..7de27db 100644 --- a/webkit/glue/webdevtoolsclient_impl.cc +++ b/webkit/glue/webdevtoolsclient_impl.cc @@ -197,7 +197,7 @@ v8::Handle<v8::Value> WebDevToolsClientImpl::JsAddSourceToFrame( return v8::Undefined(); } - Page* page = V8Proxy::retrieveActiveFrame()->page(); + Page* page = V8Proxy::retrieveFrameForEnteredContext()->page(); InspectorController* inspectorController = page->inspectorController(); return WebCore::v8Boolean(inspectorController-> addSourceToFrame(mime_type, source_string, node)); @@ -211,7 +211,7 @@ v8::Handle<v8::Value> WebDevToolsClientImpl::JsLoaded( client->loaded_ = true; // Grant the devtools page the ability to have source view iframes. - Page* page = V8Proxy::retrieveActiveFrame()->page(); + Page* page = V8Proxy::retrieveFrameForEnteredContext()->page(); SecurityOrigin* origin = page->mainFrame()->domWindow()->securityOrigin(); origin->grantUniversalAccess(); diff --git a/webkit/glue/webframe.h b/webkit/glue/webframe.h index e1495fa..77d3b27 100644 --- a/webkit/glue/webframe.h +++ b/webkit/glue/webframe.h @@ -32,7 +32,23 @@ class WebFrame { public: WebFrame() {} - static WebFrame* RetrieveActiveFrame(); + // 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. + // + // 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' + // frame is. + // + // 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. + // + // 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. + static WebFrame* RetrieveFrameForEnteredContext(); + static WebFrame* RetrieveFrameForCurrentContext(); // Binds a C++ class to a JavaScript property of the window object. This // should generally be used via CppBoundClass::BindToJavascript() instead of diff --git a/webkit/glue/webframe_impl.cc b/webkit/glue/webframe_impl.cc index 466fe5f..db177aa 100644 --- a/webkit/glue/webframe_impl.cc +++ b/webkit/glue/webframe_impl.cc @@ -341,8 +341,19 @@ class ChromePrintContext : public WebCore::PrintContext { int WebFrameImpl::live_object_count_ = 0; // static -WebFrame* WebFrame::RetrieveActiveFrame() { - WebCore::Frame* frame = WebCore::ScriptController::retrieveActiveFrame(); +WebFrame* WebFrame::RetrieveFrameForEnteredContext() { + WebCore::Frame* frame = + WebCore::ScriptController::retrieveFrameForEnteredContext(); + if (frame) + return WebFrameImpl::FromFrame(frame); + else + return NULL; +} + +// static +WebFrame* WebFrame::RetrieveFrameForCurrentContext() { + WebCore::Frame* frame = + WebCore::ScriptController::retrieveFrameForCurrentContext(); if (frame) return WebFrameImpl::FromFrame(frame); else |