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 <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 } // namespace | 645 } // namespace |
646 | 646 |
647 // Var ------------------------------------------------------------------------- | 647 // Var ------------------------------------------------------------------------- |
648 | 648 |
649 Var::Var(PluginModule* module) : Resource(module) { | 649 Var::Var(PluginModule* module) : Resource(module) { |
650 } | 650 } |
651 | 651 |
652 Var::~Var() { | 652 Var::~Var() { |
653 } | 653 } |
654 | 654 |
| 655 Var* Var::AsVar() { |
| 656 return this; |
| 657 } |
| 658 |
655 // static | 659 // static |
656 PP_Var Var::NPVariantToPPVar(PluginModule* module, const NPVariant* variant) { | 660 PP_Var Var::NPVariantToPPVar(PluginModule* module, const NPVariant* variant) { |
657 switch (variant->type) { | 661 switch (variant->type) { |
658 case NPVariantType_Void: | 662 case NPVariantType_Void: |
659 return PP_MakeUndefined(); | 663 return PP_MakeUndefined(); |
660 case NPVariantType_Null: | 664 case NPVariantType_Null: |
661 return PP_MakeNull(); | 665 return PP_MakeNull(); |
662 case NPVariantType_Bool: | 666 case NPVariantType_Bool: |
663 return BoolToPPVar(NPVARIANT_TO_BOOLEAN(*variant)); | 667 return BoolToPPVar(NPVARIANT_TO_BOOLEAN(*variant)); |
664 case NPVariantType_Int32: | 668 case NPVariantType_Int32: |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
737 // StringVar ------------------------------------------------------------------- | 741 // StringVar ------------------------------------------------------------------- |
738 | 742 |
739 StringVar::StringVar(PluginModule* module, const char* str, uint32 len) | 743 StringVar::StringVar(PluginModule* module, const char* str, uint32 len) |
740 : Var(module), | 744 : Var(module), |
741 value_(str, len) { | 745 value_(str, len) { |
742 } | 746 } |
743 | 747 |
744 StringVar::~StringVar() { | 748 StringVar::~StringVar() { |
745 } | 749 } |
746 | 750 |
| 751 StringVar* StringVar::AsStringVar() { |
| 752 return this; |
| 753 } |
| 754 |
747 // static | 755 // static |
748 PP_Var StringVar::StringToPPVar(PluginModule* module, const std::string& var) { | 756 PP_Var StringVar::StringToPPVar(PluginModule* module, const std::string& var) { |
749 return StringToPPVar(module, var.c_str(), var.size()); | 757 return StringToPPVar(module, var.c_str(), var.size()); |
750 } | 758 } |
751 | 759 |
752 // static | 760 // static |
753 PP_Var StringVar::StringToPPVar(PluginModule* module, | 761 PP_Var StringVar::StringToPPVar(PluginModule* module, |
754 const char* data, uint32 len) { | 762 const char* data, uint32 len) { |
755 scoped_refptr<StringVar> str(new StringVar(module, data, len)); | 763 scoped_refptr<StringVar> str(new StringVar(module, data, len)); |
756 if (!str || !IsStringUTF8(str->value())) | 764 if (!str || !IsStringUTF8(str->value())) |
(...skipping 21 matching lines...) Expand all Loading... |
778 np_object_(np_object) { | 786 np_object_(np_object) { |
779 WebBindings::retainObject(np_object_); | 787 WebBindings::retainObject(np_object_); |
780 module->AddNPObjectVar(this); | 788 module->AddNPObjectVar(this); |
781 } | 789 } |
782 | 790 |
783 ObjectVar::~ObjectVar() { | 791 ObjectVar::~ObjectVar() { |
784 module()->RemoveNPObjectVar(this); | 792 module()->RemoveNPObjectVar(this); |
785 WebBindings::releaseObject(np_object_); | 793 WebBindings::releaseObject(np_object_); |
786 } | 794 } |
787 | 795 |
| 796 ObjectVar* ObjectVar::AsObjectVar() { |
| 797 return this; |
| 798 } |
| 799 |
788 // static | 800 // static |
789 PP_Var ObjectVar::NPObjectToPPVar(PluginModule* module, NPObject* object) { | 801 PP_Var ObjectVar::NPObjectToPPVar(PluginModule* module, NPObject* object) { |
790 scoped_refptr<ObjectVar> object_var(module->ObjectVarForNPObject(object)); | 802 scoped_refptr<ObjectVar> object_var(module->ObjectVarForNPObject(object)); |
791 if (!object_var) // No object for this module yet, make a new one. | 803 if (!object_var) // No object for this module yet, make a new one. |
792 object_var = new ObjectVar(module, object); | 804 object_var = new ObjectVar(module, object); |
793 | 805 |
794 if (!object_var) | 806 if (!object_var) |
795 return PP_MakeUndefined(); | 807 return PP_MakeUndefined(); |
796 | 808 |
797 // Convert to a PP_Var, GetReference will AddRef for us. | 809 // Convert to a PP_Var, GetReference will AddRef for us. |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
844 *exception_ = PP_MakeInt32(1); | 856 *exception_ = PP_MakeInt32(1); |
845 } | 857 } |
846 } | 858 } |
847 | 859 |
848 // static | 860 // static |
849 void TryCatch::Catch(void* self, const char* message) { | 861 void TryCatch::Catch(void* self, const char* message) { |
850 static_cast<TryCatch*>(self)->SetException(message); | 862 static_cast<TryCatch*>(self)->SetException(message); |
851 } | 863 } |
852 | 864 |
853 } // namespace pepper | 865 } // namespace pepper |
OLD | NEW |