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 1033 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1044 #else | 1044 #else |
1045 /*i18n-content*/"DISCONNECT_BUTTON_PLUS_SHORTCUT_LINUX", | 1045 /*i18n-content*/"DISCONNECT_BUTTON_PLUS_SHORTCUT_LINUX", |
1046 #endif | 1046 #endif |
1047 &ui_strings.disconnect_button_text_plus_shortcut); | 1047 &ui_strings.disconnect_button_text_plus_shortcut); |
1048 LocalizeString(localize_func, /*i18n-content*/"CONTINUE_PROMPT", | 1048 LocalizeString(localize_func, /*i18n-content*/"CONTINUE_PROMPT", |
1049 &ui_strings.continue_prompt); | 1049 &ui_strings.continue_prompt); |
1050 LocalizeString(localize_func, /*i18n-content*/"CONTINUE_BUTTON", | 1050 LocalizeString(localize_func, /*i18n-content*/"CONTINUE_BUTTON", |
1051 &ui_strings.continue_button_text); | 1051 &ui_strings.continue_button_text); |
1052 LocalizeString(localize_func, /*i18n-content*/"STOP_SHARING_BUTTON", | 1052 LocalizeString(localize_func, /*i18n-content*/"STOP_SHARING_BUTTON", |
1053 &ui_strings.stop_sharing_button_text); | 1053 &ui_strings.stop_sharing_button_text); |
1054 LocalizeString(localize_func, /*i18n-content*/"MESSAGE_SHARED", | 1054 LocalizeStringWithSubstitution(localize_func, |
1055 &ui_strings.disconnect_message); | 1055 /*i18n-content*/"MESSAGE_SHARED", "$1", |
Sergey Ulanov
2012/06/29 20:11:38
nit: incorrect indentation.
Jamie
2012/06/29 20:22:20
Done.
| |
1056 &ui_strings.disconnect_message); | |
1056 | 1057 |
1057 base::AutoLock auto_lock(ui_strings_lock_); | 1058 base::AutoLock auto_lock(ui_strings_lock_); |
1058 ui_strings_ = ui_strings; | 1059 ui_strings_ = ui_strings; |
1059 } | 1060 } |
1060 | 1061 |
1061 bool HostNPScriptObject::LocalizeString(NPObject* localize_func, | 1062 bool HostNPScriptObject::LocalizeString(NPObject* localize_func, |
1062 const char* tag, string16* result) { | 1063 const char* tag, string16* result) { |
1063 NPVariant args[2]; | 1064 return LocalizeStringWithSubstitution(localize_func, tag, NULL, result); |
1065 } | |
1066 | |
1067 bool HostNPScriptObject::LocalizeStringWithSubstitution( | |
1068 NPObject* localize_func, const char* tag, const char* substitution, | |
Sergey Ulanov
2012/06/29 20:11:38
nit: move each argument to a separate line
Jamie
2012/06/29 20:22:20
Done.
| |
1069 string16* result) { | |
1070 int argc = substitution ? 2 : 1; | |
1071 scoped_array<NPVariant> args(new NPVariant[argc]); | |
1064 STRINGZ_TO_NPVARIANT(tag, args[0]); | 1072 STRINGZ_TO_NPVARIANT(tag, args[0]); |
1073 if (substitution) { | |
Sergey Ulanov
2012/06/29 20:11:38
nit: don't need {} here
Jamie
2012/06/29 20:22:20
We're inconsistent wrt this, even within this file
| |
1074 STRINGZ_TO_NPVARIANT(substitution, args[1]); | |
1075 } | |
1065 NPVariant np_result; | 1076 NPVariant np_result; |
1066 bool is_good = g_npnetscape_funcs->invokeDefault( | 1077 bool is_good = g_npnetscape_funcs->invokeDefault( |
1067 plugin_, localize_func, &args[0], 1, &np_result); | 1078 plugin_, localize_func, args.get(), argc, &np_result); |
1068 if (!is_good) { | 1079 if (!is_good) { |
1069 LOG(ERROR) << "Localization failed for " << tag; | 1080 LOG(ERROR) << "Localization failed for " << tag; |
1070 return false; | 1081 return false; |
1071 } | 1082 } |
1072 std::string translation = StringFromNPVariant(np_result); | 1083 std::string translation = StringFromNPVariant(np_result); |
1073 g_npnetscape_funcs->releasevariantvalue(&np_result); | 1084 g_npnetscape_funcs->releasevariantvalue(&np_result); |
1074 if (translation.empty()) { | 1085 if (translation.empty()) { |
1075 LOG(ERROR) << "Missing translation for " << tag; | 1086 LOG(ERROR) << "Missing translation for " << tag; |
1076 return false; | 1087 return false; |
1077 } | 1088 } |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1226 return is_good; | 1237 return is_good; |
1227 } | 1238 } |
1228 | 1239 |
1229 void HostNPScriptObject::SetException(const std::string& exception_string) { | 1240 void HostNPScriptObject::SetException(const std::string& exception_string) { |
1230 DCHECK(plugin_message_loop_proxy_->BelongsToCurrentThread()); | 1241 DCHECK(plugin_message_loop_proxy_->BelongsToCurrentThread()); |
1231 g_npnetscape_funcs->setexception(parent_, exception_string.c_str()); | 1242 g_npnetscape_funcs->setexception(parent_, exception_string.c_str()); |
1232 LOG(INFO) << exception_string; | 1243 LOG(INFO) << exception_string; |
1233 } | 1244 } |
1234 | 1245 |
1235 } // namespace remoting | 1246 } // namespace remoting |
OLD | NEW |