Chromium Code Reviews| 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 |
| 12 // name in its internal map of methods, and then calls the appropriate | 12 // name in its internal map of methods, and then calls the appropriate |
| 13 // method. | 13 // method. |
| 14 | 14 |
| 15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
| 16 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/stl_util.h" | 17 #include "base/stl_util.h" |
| 18 #include "base/utf_string_conversions.h" | 18 #include "base/utf_string_conversions.h" |
| 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" | 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" |
| 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
| 21 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" | 21 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
| 22 #include "webkit/glue/cpp_bound_class.h" | 22 #include "webkit/glue/cpp_bound_class.h" |
| 23 | 23 |
| 24 using WebKit::WebBindings; | 24 using WebKit::WebBindings; |
| 25 using WebKit::WebFrame; | 25 using WebKit::WebFrame; |
| 26 | 26 |
| 27 namespace webkit_glue { | |
|
tony
2012/05/08 20:52:26
Nit: Please move this after the anonymous namespac
| |
| 28 | |
| 27 namespace { | 29 namespace { |
| 28 | 30 |
| 29 class CppVariantPropertyCallback : public CppBoundClass::PropertyCallback { | 31 class CppVariantPropertyCallback : public CppBoundClass::PropertyCallback { |
| 30 public: | 32 public: |
| 31 CppVariantPropertyCallback(CppVariant* value) : value_(value) { } | 33 CppVariantPropertyCallback(CppVariant* value) : value_(value) { } |
| 32 | 34 |
| 33 virtual bool GetValue(CppVariant* value) { | 35 virtual bool GetValue(CppVariant* value) { |
| 34 value->Set(*value_); | 36 value->Set(*value_); |
| 35 return true; | 37 return true; |
| 36 } | 38 } |
| (...skipping 280 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 |