OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 /* | 5 /* |
6 CppBoundClass class: | 6 CppBoundClass class: |
7 This base class serves as a parent for C++ classes designed to be bound to | 7 This base class serves as a parent for C++ classes designed to be bound to |
8 JavaScript objects. | 8 JavaScript objects. |
9 | 9 |
10 Subclasses should define the constructor to build the property and method | 10 Subclasses should define the constructor to build the property and method |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 // The variant type is guaranteed to be NPVariantType_Object. | 58 // The variant type is guaranteed to be NPVariantType_Object. |
59 CppVariant* GetAsCppVariant(); | 59 CppVariant* GetAsCppVariant(); |
60 | 60 |
61 // Given a WebFrame, BindToJavascript builds the NPObject that will represent | 61 // Given a WebFrame, BindToJavascript builds the NPObject that will represent |
62 // the class and binds it to the frame's window under the given name. This | 62 // the class and binds it to the frame's window under the given name. This |
63 // should generally be called from the WebView delegate's | 63 // should generally be called from the WebView delegate's |
64 // WindowObjectCleared(). A class so bound will be accessible to JavaScript | 64 // WindowObjectCleared(). A class so bound will be accessible to JavaScript |
65 // as window.<classname>. The owner of the CppBoundObject is responsible for | 65 // as window.<classname>. The owner of the CppBoundObject is responsible for |
66 // keeping the object around while the frame is alive, and for destroying it | 66 // keeping the object around while the frame is alive, and for destroying it |
67 // afterwards. | 67 // afterwards. |
68 void BindToJavascript( | 68 void BindToJavascript(WebKit::WebFrame* frame, const std::string& classname); |
69 WebKit::WebFrame* frame, const std::wstring& classname); | |
70 | 69 |
71 // The type of callbacks. | 70 // The type of callbacks. |
72 typedef Callback2<const CppArgumentList&, CppVariant*>::Type Callback; | 71 typedef Callback2<const CppArgumentList&, CppVariant*>::Type Callback; |
73 typedef Callback1<CppVariant*>::Type GetterCallback; | 72 typedef Callback1<CppVariant*>::Type GetterCallback; |
74 | 73 |
75 // Used by a test. Returns true if a method with name |name| exists, | 74 // Used by a test. Returns true if a method with name |name| exists, |
76 // regardless of whether a fallback is registered. | 75 // regardless of whether a fallback is registered. |
77 bool IsMethodRegistered(const std::string& name) const; | 76 bool IsMethodRegistered(const std::string& name) const; |
78 | 77 |
79 protected: | 78 protected: |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 CppVariant self_variant_; | 171 CppVariant self_variant_; |
173 | 172 |
174 // True if our np_object has been bound to a WebFrame, in which case it must | 173 // True if our np_object has been bound to a WebFrame, in which case it must |
175 // be unregistered with V8 when we delete it. | 174 // be unregistered with V8 when we delete it. |
176 bool bound_to_frame_; | 175 bool bound_to_frame_; |
177 | 176 |
178 DISALLOW_COPY_AND_ASSIGN(CppBoundClass); | 177 DISALLOW_COPY_AND_ASSIGN(CppBoundClass); |
179 }; | 178 }; |
180 | 179 |
181 #endif // CPP_BOUNDCLASS_H__ | 180 #endif // CPP_BOUNDCLASS_H__ |
OLD | NEW |