OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/renderer/java/java_bridge_dispatcher.h" | 5 #include "content/renderer/java/java_bridge_dispatcher.h" |
6 | 6 |
7 #include "content/child/child_process.h" | 7 #include "content/child/child_process.h" |
8 #include "content/child/npapi/npobject_util.h" // For CreateNPVariant() | 8 #include "content/child/npapi/npobject_util.h" // For CreateNPVariant() |
9 #include "content/common/java_bridge_messages.h" | 9 #include "content/common/java_bridge_messages.h" |
10 #include "content/public/renderer/render_frame.h" | 10 #include "content/public/renderer/render_frame.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 IPC_END_MESSAGE_MAP() | 50 IPC_END_MESSAGE_MAP() |
51 return handled; | 51 return handled; |
52 } | 52 } |
53 | 53 |
54 void JavaBridgeDispatcher::DidClearWindowObject() { | 54 void JavaBridgeDispatcher::DidClearWindowObject() { |
55 // Note that we have to (re)bind all objects, as they will have been unbound | 55 // Note that we have to (re)bind all objects, as they will have been unbound |
56 // when the window object was cleared. | 56 // when the window object was cleared. |
57 for (ObjectMap::const_iterator iter = objects_.begin(); | 57 for (ObjectMap::const_iterator iter = objects_.begin(); |
58 iter != objects_.end(); | 58 iter != objects_.end(); |
59 ++iter) { | 59 ++iter) { |
| 60 NPObject* object = NPVARIANT_TO_OBJECT(iter->second); |
| 61 // De-associate from the existing V8 wrapper, so we don't pull any |
| 62 // of the wrapper's custom properties into the context of the page we |
| 63 // have navigated to. |
| 64 blink::WebBindings::dropV8WrapperForObject(object); |
60 // This refs the NPObject. This reference is dropped when either the window | 65 // This refs the NPObject. This reference is dropped when either the window |
61 // object is later cleared, or the object is GC'ed. So the object may be | 66 // object is later cleared, or the object is GC'ed. So the object may be |
62 // deleted at any time after OnRemoveNamedObject() is called. | 67 // deleted at any time after OnRemoveNamedObject() is called. |
63 render_frame()->GetWebFrame()->bindToWindowObject( | 68 render_frame()->GetWebFrame()->bindToWindowObject(iter->first, object); |
64 iter->first, NPVARIANT_TO_OBJECT(iter->second)); | |
65 } | 69 } |
66 } | 70 } |
67 | 71 |
68 void JavaBridgeDispatcher::OnAddNamedObject( | 72 void JavaBridgeDispatcher::OnAddNamedObject( |
69 const base::string16& name, | 73 const base::string16& name, |
70 const NPVariant_Param& variant_param) { | 74 const NPVariant_Param& variant_param) { |
71 DCHECK_EQ(variant_param.type, NPVARIANT_PARAM_SENDER_OBJECT_ROUTING_ID); | 75 DCHECK_EQ(variant_param.type, NPVARIANT_PARAM_SENDER_OBJECT_ROUTING_ID); |
72 | 76 |
73 EnsureChannelIsSetUp(); | 77 EnsureChannelIsSetUp(); |
74 if (!channel_.get()) { | 78 if (!channel_.get()) { |
(...skipping 30 matching lines...) Expand all Loading... |
105 // Removing an object does not unbind it from JavaScript until the window | 109 // Removing an object does not unbind it from JavaScript until the window |
106 // object is next cleared. Note that the browser checks that the named object | 110 // object is next cleared. Note that the browser checks that the named object |
107 // is present. | 111 // is present. |
108 ObjectMap::iterator iter = objects_.find(name); | 112 ObjectMap::iterator iter = objects_.find(name); |
109 DCHECK(iter != objects_.end()); | 113 DCHECK(iter != objects_.end()); |
110 blink::WebBindings::releaseObject(NPVARIANT_TO_OBJECT(iter->second)); | 114 blink::WebBindings::releaseObject(NPVARIANT_TO_OBJECT(iter->second)); |
111 objects_.erase(iter); | 115 objects_.erase(iter); |
112 } | 116 } |
113 | 117 |
114 } // namespace content | 118 } // namespace content |
OLD | NEW |