| 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 // This file contains definitions for CppBoundClass | 5 // This file contains definitions for CppBoundClass |
| 6 | 6 |
| 7 // Here's the control flow of a JS method getting forwarded to a class. | 7 // Here's the control flow of a JS method getting forwarded to a class. |
| 8 // - Something calls our NPObject with a function like "Invoke". | 8 // - Something calls our NPObject with a function like "Invoke". |
| 9 // - CppNPObject's static invoke() function forwards it to its attached | 9 // - CppNPObject's static invoke() function forwards it to its attached |
| 10 // CppBoundClass's Invoke() method. | 10 // CppBoundClass's Invoke() method. |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 obj->bound_class = this; | 307 obj->bound_class = this; |
| 308 self_variant_.Set(np_obj); | 308 self_variant_.Set(np_obj); |
| 309 WebBindings::releaseObject(np_obj); // CppVariant takes the reference. | 309 WebBindings::releaseObject(np_obj); // CppVariant takes the reference. |
| 310 } | 310 } |
| 311 DCHECK(self_variant_.isObject()); | 311 DCHECK(self_variant_.isObject()); |
| 312 return &self_variant_; | 312 return &self_variant_; |
| 313 } | 313 } |
| 314 | 314 |
| 315 void CppBoundClass::BindToJavascript(WebFrame* frame, | 315 void CppBoundClass::BindToJavascript(WebFrame* frame, |
| 316 const std::string& classname) { | 316 const std::string& classname) { |
| 317 #if WEBKIT_USING_JSC | |
| 318 #error "This is not going to work anymore...but it's not clear what the solution
is...or if it's still necessary." | |
| 319 JSC::JSLock lock(false); | |
| 320 #endif | |
| 321 | |
| 322 // BindToWindowObject will take its own reference to the NPObject, and clean | 317 // BindToWindowObject will take its own reference to the NPObject, and clean |
| 323 // up after itself. It will also (indirectly) register the object with V8, | 318 // up after itself. It will also (indirectly) register the object with V8, |
| 324 // so we must remember this so we can unregister it when we're destroyed. | 319 // so we must remember this so we can unregister it when we're destroyed. |
| 325 frame->bindToWindowObject(ASCIIToUTF16(classname), | 320 frame->bindToWindowObject(ASCIIToUTF16(classname), |
| 326 NPVARIANT_TO_OBJECT(*GetAsCppVariant())); | 321 NPVARIANT_TO_OBJECT(*GetAsCppVariant())); |
| 327 bound_to_frame_ = true; | 322 bound_to_frame_ = true; |
| 328 } | 323 } |
| 329 | 324 |
| 330 } // namespace webkit_glue | 325 } // namespace webkit_glue |
| OLD | NEW |