Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Side by Side Diff: remoting/host/plugin/host_script_object.cc

Issue 10661058: Move responsibility for l10n parameters to the caller. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reviewer comments. Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/host/plugin/host_script_object.h ('k') | remoting/webapp/host_session.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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",
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,
1069 const char* tag,
1070 const char* substitution,
1071 string16* result) {
1072 int argc = substitution ? 2 : 1;
1073 scoped_array<NPVariant> args(new NPVariant[argc]);
1064 STRINGZ_TO_NPVARIANT(tag, args[0]); 1074 STRINGZ_TO_NPVARIANT(tag, args[0]);
1075 if (substitution) {
1076 STRINGZ_TO_NPVARIANT(substitution, args[1]);
1077 }
1065 NPVariant np_result; 1078 NPVariant np_result;
1066 bool is_good = g_npnetscape_funcs->invokeDefault( 1079 bool is_good = g_npnetscape_funcs->invokeDefault(
1067 plugin_, localize_func, &args[0], 1, &np_result); 1080 plugin_, localize_func, args.get(), argc, &np_result);
1068 if (!is_good) { 1081 if (!is_good) {
1069 LOG(ERROR) << "Localization failed for " << tag; 1082 LOG(ERROR) << "Localization failed for " << tag;
1070 return false; 1083 return false;
1071 } 1084 }
1072 std::string translation = StringFromNPVariant(np_result); 1085 std::string translation = StringFromNPVariant(np_result);
1073 g_npnetscape_funcs->releasevariantvalue(&np_result); 1086 g_npnetscape_funcs->releasevariantvalue(&np_result);
1074 if (translation.empty()) { 1087 if (translation.empty()) {
1075 LOG(ERROR) << "Missing translation for " << tag; 1088 LOG(ERROR) << "Missing translation for " << tag;
1076 return false; 1089 return false;
1077 } 1090 }
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
1226 return is_good; 1239 return is_good;
1227 } 1240 }
1228 1241
1229 void HostNPScriptObject::SetException(const std::string& exception_string) { 1242 void HostNPScriptObject::SetException(const std::string& exception_string) {
1230 DCHECK(plugin_message_loop_proxy_->BelongsToCurrentThread()); 1243 DCHECK(plugin_message_loop_proxy_->BelongsToCurrentThread());
1231 g_npnetscape_funcs->setexception(parent_, exception_string.c_str()); 1244 g_npnetscape_funcs->setexception(parent_, exception_string.c_str());
1232 LOG(INFO) << exception_string; 1245 LOG(INFO) << exception_string;
1233 } 1246 }
1234 1247
1235 } // namespace remoting 1248 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/plugin/host_script_object.h ('k') | remoting/webapp/host_session.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698