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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 // failure. |value| is always non-NULL. | 44 // failure. |value| is always non-NULL. |
45 virtual bool GetValue(CppVariant* value) = 0; | 45 virtual bool GetValue(CppVariant* value) = 0; |
46 | 46 |
47 // sets the property value to |value|. Returns false in case of failure. | 47 // sets the property value to |value|. Returns false in case of failure. |
48 virtual bool SetValue(const CppVariant& value) = 0; | 48 virtual bool SetValue(const CppVariant& value) = 0; |
49 }; | 49 }; |
50 | 50 |
51 // The constructor should call BindMethod, BindProperty, and | 51 // The constructor should call BindMethod, BindProperty, and |
52 // SetFallbackMethod as needed to set up the methods, properties, and | 52 // SetFallbackMethod as needed to set up the methods, properties, and |
53 // fallback method. | 53 // fallback method. |
54 CppBoundClass() : bound_to_frame_(false) { } | 54 CppBoundClass(); |
55 virtual ~CppBoundClass(); | 55 virtual ~CppBoundClass(); |
56 | 56 |
57 // Return a CppVariant representing this class, for use with BindProperty(). | 57 // Return a CppVariant representing this class, for use with BindProperty(). |
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 |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 CppVariant self_variant_; | 172 CppVariant self_variant_; |
173 | 173 |
174 // True if our np_object has been bound to a WebFrame, in which case it must | 174 // 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. | 175 // be unregistered with V8 when we delete it. |
176 bool bound_to_frame_; | 176 bool bound_to_frame_; |
177 | 177 |
178 DISALLOW_COPY_AND_ASSIGN(CppBoundClass); | 178 DISALLOW_COPY_AND_ASSIGN(CppBoundClass); |
179 }; | 179 }; |
180 | 180 |
181 #endif // CPP_BOUNDCLASS_H__ | 181 #endif // CPP_BOUNDCLASS_H__ |
OLD | NEW |