OLD | NEW |
1 // Copyright (c) 2012 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 #include "remoting/host/plugin/host_script_object.h" | 5 #include "remoting/host/plugin/host_script_object.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
671 | 671 |
672 bool HostNPScriptObject::UpdateDaemonConfig(const NPVariant* args, | 672 bool HostNPScriptObject::UpdateDaemonConfig(const NPVariant* args, |
673 uint32_t arg_count, | 673 uint32_t arg_count, |
674 NPVariant* result) { | 674 NPVariant* result) { |
675 if (arg_count != 2) { | 675 if (arg_count != 2) { |
676 SetException("updateDaemonConfig: bad number of arguments"); | 676 SetException("updateDaemonConfig: bad number of arguments"); |
677 return false; | 677 return false; |
678 } | 678 } |
679 | 679 |
680 std::string config_str = StringFromNPVariant(args[0]); | 680 std::string config_str = StringFromNPVariant(args[0]); |
681 scoped_ptr<base::Value> config(base::JSONReader::Read(config_str, true)); | 681 scoped_ptr<base::Value> config( |
| 682 base::JSONReader::Read(config_str, base::JSON_ALLOW_TRAILING_COMMAS)); |
682 if (config_str.empty() || !config.get() || | 683 if (config_str.empty() || !config.get() || |
683 !config->IsType(base::Value::TYPE_DICTIONARY)) { | 684 !config->IsType(base::Value::TYPE_DICTIONARY)) { |
684 SetException("updateDaemonConfig: bad config parameter"); | 685 SetException("updateDaemonConfig: bad config parameter"); |
685 return false; | 686 return false; |
686 } | 687 } |
687 scoped_ptr<base::DictionaryValue> config_dict( | 688 scoped_ptr<base::DictionaryValue> config_dict( |
688 reinterpret_cast<base::DictionaryValue*>(config.release())); | 689 reinterpret_cast<base::DictionaryValue*>(config.release())); |
689 | 690 |
690 ScopedRefNPObject callback_obj(ObjectFromNPVariant(args[1])); | 691 ScopedRefNPObject callback_obj(ObjectFromNPVariant(args[1])); |
691 if (callback_obj.get()) { | 692 if (callback_obj.get()) { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
732 | 733 |
733 bool HostNPScriptObject::StartDaemon(const NPVariant* args, | 734 bool HostNPScriptObject::StartDaemon(const NPVariant* args, |
734 uint32_t arg_count, | 735 uint32_t arg_count, |
735 NPVariant* result) { | 736 NPVariant* result) { |
736 if (arg_count != 2) { | 737 if (arg_count != 2) { |
737 SetException("startDaemon: bad number of arguments"); | 738 SetException("startDaemon: bad number of arguments"); |
738 return false; | 739 return false; |
739 } | 740 } |
740 | 741 |
741 std::string config_str = StringFromNPVariant(args[0]); | 742 std::string config_str = StringFromNPVariant(args[0]); |
742 scoped_ptr<base::Value> config(base::JSONReader::Read(config_str, true)); | 743 scoped_ptr<base::Value> config( |
| 744 base::JSONReader::Read(config_str, base::JSON_ALLOW_TRAILING_COMMAS)); |
743 if (config_str.empty() || !config.get() || | 745 if (config_str.empty() || !config.get() || |
744 !config->IsType(base::Value::TYPE_DICTIONARY)) { | 746 !config->IsType(base::Value::TYPE_DICTIONARY)) { |
745 SetException("updateDaemonConfig: bad config parameter"); | 747 SetException("updateDaemonConfig: bad config parameter"); |
746 return false; | 748 return false; |
747 } | 749 } |
748 scoped_ptr<base::DictionaryValue> config_dict( | 750 scoped_ptr<base::DictionaryValue> config_dict( |
749 reinterpret_cast<base::DictionaryValue*>(config.release())); | 751 reinterpret_cast<base::DictionaryValue*>(config.release())); |
750 | 752 |
751 ScopedRefNPObject callback_obj(ObjectFromNPVariant(args[1])); | 753 ScopedRefNPObject callback_obj(ObjectFromNPVariant(args[1])); |
752 if (!callback_obj.get()) { | 754 if (!callback_obj.get()) { |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1117 return is_good; | 1119 return is_good; |
1118 } | 1120 } |
1119 | 1121 |
1120 void HostNPScriptObject::SetException(const std::string& exception_string) { | 1122 void HostNPScriptObject::SetException(const std::string& exception_string) { |
1121 DCHECK(plugin_message_loop_proxy_->BelongsToCurrentThread()); | 1123 DCHECK(plugin_message_loop_proxy_->BelongsToCurrentThread()); |
1122 g_npnetscape_funcs->setexception(parent_, exception_string.c_str()); | 1124 g_npnetscape_funcs->setexception(parent_, exception_string.c_str()); |
1123 LOG(INFO) << exception_string; | 1125 LOG(INFO) << exception_string; |
1124 } | 1126 } |
1125 | 1127 |
1126 } // namespace remoting | 1128 } // namespace remoting |
OLD | NEW |