| Index: remoting/host/plugin/host_script_object.cc
|
| diff --git a/remoting/host/plugin/host_script_object.cc b/remoting/host/plugin/host_script_object.cc
|
| index 9f6bbfcea19ab54ac2c91674ea90493202dc53c7..77bdb08ba3de3622e530150b7e76c59aec84fd02 100644
|
| --- a/remoting/host/plugin/host_script_object.cc
|
| +++ b/remoting/host/plugin/host_script_object.cc
|
| @@ -7,7 +7,9 @@
|
| #include "base/bind.h"
|
| #include "base/message_loop.h"
|
| #include "base/message_loop_proxy.h"
|
| +#include "base/sys_string_conversions.h"
|
| #include "base/threading/platform_thread.h"
|
| +#include "base/utf_string_conversions.h"
|
| #include "remoting/base/auth_token_util.h"
|
| #include "remoting/base/util.h"
|
| #include "remoting/host/chromoting_host.h"
|
| @@ -350,7 +352,6 @@ void HostNPScriptObject::OnClientAuthenticated(
|
| if (pos != std::string::npos)
|
| client_username_.replace(pos, std::string::npos, "");
|
| LOG(INFO) << "Client " << client_username_ << " connected.";
|
| - LocalizeStrings();
|
| OnStateChanged(kConnected);
|
| }
|
|
|
| @@ -482,6 +483,8 @@ void HostNPScriptObject::FinishConnect(
|
| host_->AddStatusObserver(register_request_.get());
|
| host_->set_it2me(true);
|
|
|
| + LocalizeStrings();
|
| +
|
| // Start the Host.
|
| host_->Start();
|
|
|
| @@ -642,14 +645,13 @@ void HostNPScriptObject::SetException(const std::string& exception_string) {
|
| }
|
|
|
| void HostNPScriptObject::LocalizeStrings() {
|
| - UiStrings* ui_strings = host_->ui_strings();
|
| - std::string direction;
|
| - LocalizeString("@@bidi_dir", NULL, &direction);
|
| - ui_strings->direction =
|
| - direction == "rtl" ? remoting::UiStrings::RTL
|
| - : remoting::UiStrings::LTR;
|
| - LocalizeString("productName", NULL, &ui_strings->product_name);
|
| - LocalizeString("disconnectButton", NULL, &ui_strings->disconnect_button_text);
|
| + UiStrings ui_strings;
|
| + string16 direction;
|
| + LocalizeString("@@bidi_dir", &direction);
|
| + ui_strings.direction = UTF16ToUTF8(direction) == "rtl" ?
|
| + remoting::UiStrings::RTL : remoting::UiStrings::LTR;
|
| + LocalizeString("productName", &ui_strings.product_name);
|
| + LocalizeString("disconnectButton", &ui_strings.disconnect_button_text);
|
| LocalizeString(
|
| #if defined(OS_WIN)
|
| "disconnectButtonPlusShortcutWindows",
|
| @@ -658,28 +660,22 @@ void HostNPScriptObject::LocalizeStrings() {
|
| #else
|
| "disconnectButtonPlusShortcutLinux",
|
| #endif
|
| - NULL, &ui_strings->disconnect_button_text_plus_shortcut);
|
| - LocalizeString("continuePrompt", NULL, &ui_strings->continue_prompt);
|
| - LocalizeString("continueButton", NULL, &ui_strings->continue_button_text);
|
| - LocalizeString("stopSharingButton", NULL,
|
| - &ui_strings->stop_sharing_button_text);
|
| - LocalizeString("messageShared", client_username_.c_str(),
|
| - &ui_strings->disconnect_message);
|
| -}
|
| -
|
| -bool HostNPScriptObject::LocalizeString(const char* tag,
|
| - const char* substitution,
|
| - std::string* result) {
|
| + &ui_strings.disconnect_button_text_plus_shortcut);
|
| + LocalizeString("continuePrompt", &ui_strings.continue_prompt);
|
| + LocalizeString("continueButton", &ui_strings.continue_button_text);
|
| + LocalizeString("stopSharingButton",
|
| + &ui_strings.stop_sharing_button_text);
|
| + LocalizeString("messageShared", &ui_strings.disconnect_message);
|
| +
|
| + host_->SetUiStrings(ui_strings);
|
| +}
|
| +
|
| +bool HostNPScriptObject::LocalizeString(const char* tag, string16* result) {
|
| NPVariant args[2];
|
| STRINGZ_TO_NPVARIANT(tag, args[0]);
|
| - int arg_count = 1;
|
| - if (substitution) {
|
| - STRINGZ_TO_NPVARIANT(substitution, args[1]);
|
| - ++arg_count;
|
| - }
|
| NPVariant np_result;
|
| bool is_good = g_npnetscape_funcs->invokeDefault(
|
| - plugin_, localize_func_.get(), &args[0], arg_count, &np_result);
|
| + plugin_, localize_func_.get(), &args[0], 1, &np_result);
|
| if (!is_good) {
|
| LOG(ERROR) << "Localization failed for " << tag;
|
| return false;
|
| @@ -690,7 +686,7 @@ bool HostNPScriptObject::LocalizeString(const char* tag,
|
| LOG(ERROR) << "Missing translation for " << tag;
|
| return false;
|
| }
|
| - *result = translation;
|
| + *result = UTF8ToUTF16(translation);
|
| return true;
|
| }
|
|
|
|
|