| OLD | NEW |
| 1 // Copyright (c) 2011 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. |
| 11 // - CppBoundClass has then overridden Invoke() to look up the function | 11 // - CppBoundClass has then overridden Invoke() to look up the function |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 virtual bool SetValue(const CppVariant& value) { | 56 virtual bool SetValue(const CppVariant& value) { |
| 57 return false; | 57 return false; |
| 58 } | 58 } |
| 59 | 59 |
| 60 private: | 60 private: |
| 61 CppBoundClass::GetterCallback callback_; | 61 CppBoundClass::GetterCallback callback_; |
| 62 }; | 62 }; |
| 63 | 63 |
| 64 } | 64 } |
| 65 | 65 |
| 66 namespace webkit_glue { |
| 67 |
| 66 // Our special NPObject type. We extend an NPObject with a pointer to a | 68 // Our special NPObject type. We extend an NPObject with a pointer to a |
| 67 // CppBoundClass, which is just a C++ interface that we forward all NPObject | 69 // CppBoundClass, which is just a C++ interface that we forward all NPObject |
| 68 // callbacks to. | 70 // callbacks to. |
| 69 struct CppNPObject { | 71 struct CppNPObject { |
| 70 NPObject parent; // This must be the first field in the struct. | 72 NPObject parent; // This must be the first field in the struct. |
| 71 CppBoundClass* bound_class; | 73 CppBoundClass* bound_class; |
| 72 | 74 |
| 73 // | 75 // |
| 74 // All following objects and functions are static, and just used to interface | 76 // All following objects and functions are static, and just used to interface |
| 75 // with NPObject/NPClass. | 77 // with NPObject/NPClass. |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 JSC::JSLock lock(false); | 319 JSC::JSLock lock(false); |
| 318 #endif | 320 #endif |
| 319 | 321 |
| 320 // BindToWindowObject will take its own reference to the NPObject, and clean | 322 // BindToWindowObject will take its own reference to the NPObject, and clean |
| 321 // up after itself. It will also (indirectly) register the object with V8, | 323 // up after itself. It will also (indirectly) register the object with V8, |
| 322 // so we must remember this so we can unregister it when we're destroyed. | 324 // so we must remember this so we can unregister it when we're destroyed. |
| 323 frame->bindToWindowObject(ASCIIToUTF16(classname), | 325 frame->bindToWindowObject(ASCIIToUTF16(classname), |
| 324 NPVARIANT_TO_OBJECT(*GetAsCppVariant())); | 326 NPVARIANT_TO_OBJECT(*GetAsCppVariant())); |
| 325 bound_to_frame_ = true; | 327 bound_to_frame_ = true; |
| 326 } | 328 } |
| 329 |
| 330 } // namespace webkit_glue |
| OLD | NEW |