| 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 #include "webkit/glue/plugins/pepper_var.h" | 5 #include "webkit/glue/plugins/pepper_var.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/scoped_ptr.h" | 8 #include "base/scoped_ptr.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "third_party/ppapi/c/pp_var.h" | 10 #include "third_party/ppapi/c/pp_var.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 const char kUnableToCallMethodException[] = "Error: Unable to call method"; | 66 const char kUnableToCallMethodException[] = "Error: Unable to call method"; |
| 67 const char kUnableToConstructException[] = "Error: Unable to construct"; | 67 const char kUnableToConstructException[] = "Error: Unable to construct"; |
| 68 | 68 |
| 69 // --------------------------------------------------------------------------- | 69 // --------------------------------------------------------------------------- |
| 70 // Utilities | 70 // Utilities |
| 71 | 71 |
| 72 String* GetStringUnchecked(PP_Var var) { | 72 String* GetStringUnchecked(PP_Var var) { |
| 73 return reinterpret_cast<String*>(var.value.as_id); | 73 return reinterpret_cast<String*>(var.value.as_id); |
| 74 } | 74 } |
| 75 | 75 |
| 76 String* GetString(PP_Var var) { | |
| 77 if (var.type != PP_VarType_String) | |
| 78 return NULL; | |
| 79 return GetStringUnchecked(var); | |
| 80 } | |
| 81 | |
| 82 NPObject* GetNPObjectUnchecked(PP_Var var) { | 76 NPObject* GetNPObjectUnchecked(PP_Var var) { |
| 83 return reinterpret_cast<NPObject*>(var.value.as_id); | 77 return reinterpret_cast<NPObject*>(var.value.as_id); |
| 84 } | 78 } |
| 85 | 79 |
| 86 // Returns a PP_Var that corresponds to the given NPVariant. The contents of | 80 // Returns a PP_Var that corresponds to the given NPVariant. The contents of |
| 87 // the NPVariant will be copied unless the NPVariant corresponds to an object. | 81 // the NPVariant will be copied unless the NPVariant corresponds to an object. |
| 88 PP_Var NPVariantToPPVar(const NPVariant* variant) { | 82 PP_Var NPVariantToPPVar(const NPVariant* variant) { |
| 89 switch (variant->type) { | 83 switch (variant->type) { |
| 90 case NPVariantType_Void: | 84 case NPVariantType_Void: |
| 91 return PP_MakeVoid(); | 85 return PP_MakeVoid(); |
| (...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 838 WebBindings::retainObject(object); | 832 WebBindings::retainObject(object); |
| 839 return ret; | 833 return ret; |
| 840 } | 834 } |
| 841 | 835 |
| 842 NPObject* GetNPObject(PP_Var var) { | 836 NPObject* GetNPObject(PP_Var var) { |
| 843 if (var.type != PP_VarType_Object) | 837 if (var.type != PP_VarType_Object) |
| 844 return NULL; | 838 return NULL; |
| 845 return GetNPObjectUnchecked(var); | 839 return GetNPObjectUnchecked(var); |
| 846 } | 840 } |
| 847 | 841 |
| 842 String* GetString(PP_Var var) { |
| 843 if (var.type != PP_VarType_String) |
| 844 return NULL; |
| 845 return GetStringUnchecked(var); |
| 846 } |
| 847 |
| 848 } // namespace pepper | 848 } // namespace pepper |
| OLD | NEW |