| 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 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 using WebKit::WebBindings; | 24 using WebKit::WebBindings; |
| 25 using WebKit::WebFrame; | 25 using WebKit::WebFrame; |
| 26 | 26 |
| 27 namespace webkit_glue { | 27 namespace webkit_glue { |
| 28 | 28 |
| 29 namespace { | 29 namespace { |
| 30 | 30 |
| 31 class CppVariantPropertyCallback : public CppBoundClass::PropertyCallback { | 31 class CppVariantPropertyCallback : public CppBoundClass::PropertyCallback { |
| 32 public: | 32 public: |
| 33 CppVariantPropertyCallback(CppVariant* value) : value_(value) { } | 33 explicit CppVariantPropertyCallback(CppVariant* value) : value_(value) { } |
| 34 | 34 |
| 35 virtual bool GetValue(CppVariant* value) { | 35 virtual bool GetValue(CppVariant* value) { |
| 36 value->Set(*value_); | 36 value->Set(*value_); |
| 37 return true; | 37 return true; |
| 38 } | 38 } |
| 39 virtual bool SetValue(const CppVariant& value) { | 39 virtual bool SetValue(const CppVariant& value) { |
| 40 value_->Set(value); | 40 value_->Set(value); |
| 41 return true; | 41 return true; |
| 42 } | 42 } |
| 43 | 43 |
| 44 private: | 44 private: |
| 45 CppVariant* value_; | 45 CppVariant* value_; |
| 46 }; | 46 }; |
| 47 | 47 |
| 48 class GetterPropertyCallback : public CppBoundClass::PropertyCallback { | 48 class GetterPropertyCallback : public CppBoundClass::PropertyCallback { |
| 49 public: | 49 public: |
| 50 GetterPropertyCallback(const CppBoundClass::GetterCallback& callback) | 50 explicit GetterPropertyCallback(const CppBoundClass::GetterCallback& callback) |
| 51 : callback_(callback) { } | 51 : callback_(callback) { } |
| 52 | 52 |
| 53 virtual bool GetValue(CppVariant* value) { | 53 virtual bool GetValue(CppVariant* value) { |
| 54 callback_.Run(value); | 54 callback_.Run(value); |
| 55 return true; | 55 return true; |
| 56 } | 56 } |
| 57 | 57 |
| 58 virtual bool SetValue(const CppVariant& value) { | 58 virtual bool SetValue(const CppVariant& value) { |
| 59 return false; | 59 return false; |
| 60 } | 60 } |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 | 321 |
| 322 // BindToWindowObject will take its own reference to the NPObject, and clean | 322 // BindToWindowObject will take its own reference to the NPObject, and clean |
| 323 // 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, |
| 324 // 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. |
| 325 frame->bindToWindowObject(ASCIIToUTF16(classname), | 325 frame->bindToWindowObject(ASCIIToUTF16(classname), |
| 326 NPVARIANT_TO_OBJECT(*GetAsCppVariant())); | 326 NPVARIANT_TO_OBJECT(*GetAsCppVariant())); |
| 327 bound_to_frame_ = true; | 327 bound_to_frame_ = true; |
| 328 } | 328 } |
| 329 | 329 |
| 330 } // namespace webkit_glue | 330 } // namespace webkit_glue |
| OLD | NEW |