diff options
Diffstat (limited to 'chrome/renderer/extensions/event_bindings.cc')
-rw-r--r-- | chrome/renderer/extensions/event_bindings.cc | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/chrome/renderer/extensions/event_bindings.cc b/chrome/renderer/extensions/event_bindings.cc index 863ebbf..81924cb 100644 --- a/chrome/renderer/extensions/event_bindings.cc +++ b/chrome/renderer/extensions/event_bindings.cc @@ -129,8 +129,7 @@ static void DeferredUnload(v8::Persistent<v8::Context> context) { context.Clear(); } -static void HandleContextDestroyed(ContextList::iterator context_iter, - bool in_gc) { +static void UnregisterContext(ContextList::iterator context_iter, bool in_gc) { // Notify the bindings that they're going away. if (in_gc) { // We shouldn't call back into javascript during a garbage collect. Do it @@ -154,14 +153,6 @@ static void HandleContextDestroyed(ContextList::iterator context_iter, } } - // Unload any content script contexts for this frame. - for (ContextList::iterator it = GetContexts().begin(); - it != GetContexts().end(); ) { - ContextList::iterator current = it++; - if ((*current)->parent_context == (*context_iter)->context) - HandleContextDestroyed(current, in_gc); - } - if (!(*context_iter)->parent_context.IsEmpty()) { (*context_iter)->parent_context.Dispose(); (*context_iter)->parent_context.Clear(); @@ -179,10 +170,11 @@ static void HandleContextDestroyed(ContextList::iterator context_iter, static void ContextWeakReferenceCallback(v8::Persistent<v8::Value> context, void*) { + // This should only get called for content script contexts. for (ContextList::iterator it = GetContexts().begin(); it != GetContexts().end(); ++it) { if ((*it)->context == context) { - HandleContextDestroyed(it, true); + UnregisterContext(it, true); return; } } @@ -258,7 +250,16 @@ void EventBindings::HandleContextDestroyed(WebFrame* frame) { ContextList::iterator context_iter = bindings_utils::FindContext(context); if (context_iter != GetContexts().end()) - ::HandleContextDestroyed(context_iter, false); + UnregisterContext(context_iter, false); + + // Unload any content script contexts for this frame. Note that the frame + // itself might not be registered, but can still be a parent context. + for (ContextList::iterator it = GetContexts().begin(); + it != GetContexts().end(); ) { + ContextList::iterator current = it++; + if ((*current)->parent_context == context) + UnregisterContext(current, false); + } } // static |