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/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
932 } | 932 } |
933 | 933 |
934 void HostNPScriptObject::LocalizeStrings(NPObject* localize_func) { | 934 void HostNPScriptObject::LocalizeStrings(NPObject* localize_func) { |
935 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); | 935 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); |
936 | 936 |
937 // Reload resources for the current locale. The default UI locale is used on | 937 // Reload resources for the current locale. The default UI locale is used on |
938 // Windows. | 938 // Windows. |
939 #if !defined(OS_WIN) | 939 #if !defined(OS_WIN) |
940 base::string16 ui_locale; | 940 base::string16 ui_locale; |
941 LocalizeString(localize_func, "@@ui_locale", &ui_locale); | 941 LocalizeString(localize_func, "@@ui_locale", &ui_locale); |
942 remoting::LoadResources(UTF16ToUTF8(ui_locale)); | 942 remoting::LoadResources(base::UTF16ToUTF8(ui_locale)); |
943 #endif // !defined(OS_WIN) | 943 #endif // !defined(OS_WIN) |
944 } | 944 } |
945 | 945 |
946 bool HostNPScriptObject::LocalizeString(NPObject* localize_func, | 946 bool HostNPScriptObject::LocalizeString(NPObject* localize_func, |
947 const char* tag, | 947 const char* tag, |
948 base::string16* result) { | 948 base::string16* result) { |
949 return LocalizeStringWithSubstitution(localize_func, tag, NULL, result); | 949 return LocalizeStringWithSubstitution(localize_func, tag, NULL, result); |
950 } | 950 } |
951 | 951 |
952 bool HostNPScriptObject::LocalizeStringWithSubstitution( | 952 bool HostNPScriptObject::LocalizeStringWithSubstitution( |
(...skipping 13 matching lines...) Expand all Loading... |
966 if (!is_good) { | 966 if (!is_good) { |
967 LOG(ERROR) << "Localization failed for " << tag; | 967 LOG(ERROR) << "Localization failed for " << tag; |
968 return false; | 968 return false; |
969 } | 969 } |
970 std::string translation = StringFromNPVariant(np_result); | 970 std::string translation = StringFromNPVariant(np_result); |
971 g_npnetscape_funcs->releasevariantvalue(&np_result); | 971 g_npnetscape_funcs->releasevariantvalue(&np_result); |
972 if (translation.empty()) { | 972 if (translation.empty()) { |
973 LOG(ERROR) << "Missing translation for " << tag; | 973 LOG(ERROR) << "Missing translation for " << tag; |
974 return false; | 974 return false; |
975 } | 975 } |
976 *result = UTF8ToUTF16(translation); | 976 *result = base::UTF8ToUTF16(translation); |
977 return true; | 977 return true; |
978 } | 978 } |
979 | 979 |
980 // static | 980 // static |
981 void HostNPScriptObject::DoGenerateKeyPair( | 981 void HostNPScriptObject::DoGenerateKeyPair( |
982 const scoped_refptr<AutoThreadTaskRunner>& plugin_task_runner, | 982 const scoped_refptr<AutoThreadTaskRunner>& plugin_task_runner, |
983 const base::Callback<void (const std::string&, | 983 const base::Callback<void (const std::string&, |
984 const std::string&)>& callback) { | 984 const std::string&)>& callback) { |
985 scoped_refptr<RsaKeyPair> key_pair = RsaKeyPair::Generate(); | 985 scoped_refptr<RsaKeyPair> key_pair = RsaKeyPair::Generate(); |
986 plugin_task_runner->PostTask(FROM_HERE, | 986 plugin_task_runner->PostTask(FROM_HERE, |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1107 } | 1107 } |
1108 | 1108 |
1109 void HostNPScriptObject::SetException(const std::string& exception_string) { | 1109 void HostNPScriptObject::SetException(const std::string& exception_string) { |
1110 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); | 1110 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); |
1111 | 1111 |
1112 g_npnetscape_funcs->setexception(parent_, exception_string.c_str()); | 1112 g_npnetscape_funcs->setexception(parent_, exception_string.c_str()); |
1113 HOST_LOG << exception_string; | 1113 HOST_LOG << exception_string; |
1114 } | 1114 } |
1115 | 1115 |
1116 } // namespace remoting | 1116 } // namespace remoting |
OLD | NEW |