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/bind.h" | 7 #include "base/bind.h" |
8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
861 } | 861 } |
862 | 862 |
863 bool HostNPScriptObject::SetProperty(const std::string& property_name, | 863 bool HostNPScriptObject::SetProperty(const std::string& property_name, |
864 const NPVariant* value) { | 864 const NPVariant* value) { |
865 VLOG(2) << "SetProperty " << property_name; | 865 VLOG(2) << "SetProperty " << property_name; |
866 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); | 866 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); |
867 | 867 |
868 if (property_name == kAttrNameOnNatTraversalPolicyChanged) { | 868 if (property_name == kAttrNameOnNatTraversalPolicyChanged) { |
869 if (NPVARIANT_IS_OBJECT(*value)) { | 869 if (NPVARIANT_IS_OBJECT(*value)) { |
870 on_nat_traversal_policy_changed_func_ = NPVARIANT_TO_OBJECT(*value); | 870 on_nat_traversal_policy_changed_func_ = NPVARIANT_TO_OBJECT(*value); |
871 if (it2me_impl_) { | 871 if (it2me_impl_.get()) { |
872 // Ask the It2Me implementation to notify the web-app of the policy. | 872 // Ask the It2Me implementation to notify the web-app of the policy. |
873 it2me_impl_->RequestNatPolicy(); | 873 it2me_impl_->RequestNatPolicy(); |
874 } | 874 } |
875 return true; | 875 return true; |
876 } else { | 876 } else { |
877 SetException("SetProperty: unexpected type for property " + | 877 SetException("SetProperty: unexpected type for property " + |
878 property_name); | 878 property_name); |
879 } | 879 } |
880 return false; | 880 return false; |
881 } | 881 } |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
997 NPVariant* result) { | 997 NPVariant* result) { |
998 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); | 998 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); |
999 | 999 |
1000 LOG(INFO) << "Connecting..."; | 1000 LOG(INFO) << "Connecting..."; |
1001 | 1001 |
1002 if (arg_count != 2) { | 1002 if (arg_count != 2) { |
1003 SetException("connect: bad number of arguments"); | 1003 SetException("connect: bad number of arguments"); |
1004 return false; | 1004 return false; |
1005 } | 1005 } |
1006 | 1006 |
1007 if (it2me_impl_) { | 1007 if (it2me_impl_.get()) { |
1008 SetException("connect: can be called only when disconnected"); | 1008 SetException("connect: can be called only when disconnected"); |
1009 return false; | 1009 return false; |
1010 } | 1010 } |
1011 | 1011 |
1012 std::string uid = StringFromNPVariant(args[0]); | 1012 std::string uid = StringFromNPVariant(args[0]); |
1013 if (uid.empty()) { | 1013 if (uid.empty()) { |
1014 SetException("connect: bad uid argument"); | 1014 SetException("connect: bad uid argument"); |
1015 return false; | 1015 return false; |
1016 } | 1016 } |
1017 | 1017 |
(...skipping 26 matching lines...) Expand all Loading... |
1044 | 1044 |
1045 bool HostNPScriptObject::Disconnect(const NPVariant* args, | 1045 bool HostNPScriptObject::Disconnect(const NPVariant* args, |
1046 uint32_t arg_count, | 1046 uint32_t arg_count, |
1047 NPVariant* result) { | 1047 NPVariant* result) { |
1048 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); | 1048 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); |
1049 if (arg_count != 0) { | 1049 if (arg_count != 0) { |
1050 SetException("disconnect: bad number of arguments"); | 1050 SetException("disconnect: bad number of arguments"); |
1051 return false; | 1051 return false; |
1052 } | 1052 } |
1053 | 1053 |
1054 if (it2me_impl_) { | 1054 if (it2me_impl_.get()) { |
1055 it2me_impl_->Disconnect(); | 1055 it2me_impl_->Disconnect(); |
1056 it2me_impl_ = NULL; | 1056 it2me_impl_ = NULL; |
1057 } | 1057 } |
1058 | 1058 |
1059 return true; | 1059 return true; |
1060 } | 1060 } |
1061 | 1061 |
1062 bool HostNPScriptObject::Localize(const NPVariant* args, | 1062 bool HostNPScriptObject::Localize(const NPVariant* args, |
1063 uint32_t arg_count, | 1063 uint32_t arg_count, |
1064 NPVariant* result) { | 1064 NPVariant* result) { |
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1582 } | 1582 } |
1583 | 1583 |
1584 void HostNPScriptObject::SetException(const std::string& exception_string) { | 1584 void HostNPScriptObject::SetException(const std::string& exception_string) { |
1585 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); | 1585 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); |
1586 | 1586 |
1587 g_npnetscape_funcs->setexception(parent_, exception_string.c_str()); | 1587 g_npnetscape_funcs->setexception(parent_, exception_string.c_str()); |
1588 LOG(INFO) << exception_string; | 1588 LOG(INFO) << exception_string; |
1589 } | 1589 } |
1590 | 1590 |
1591 } // namespace remoting | 1591 } // namespace remoting |
OLD | NEW |