summaryrefslogtreecommitdiffstats
path: root/remoting/host/plugin
diff options
context:
space:
mode:
Diffstat (limited to 'remoting/host/plugin')
-rw-r--r--remoting/host/plugin/constants.h25
-rw-r--r--remoting/host/plugin/host_plugin-Info.plist8
-rw-r--r--remoting/host/plugin/host_plugin-InfoPlist.strings.jinja23
-rw-r--r--remoting/host/plugin/host_plugin.cc57
-rw-r--r--remoting/host/plugin/host_script_object.cc39
-rw-r--r--remoting/host/plugin/host_script_object.h4
6 files changed, 65 insertions, 71 deletions
diff --git a/remoting/host/plugin/constants.h b/remoting/host/plugin/constants.h
deleted file mode 100644
index 780a2c9..0000000
--- a/remoting/host/plugin/constants.h
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef REMOTING_HOST_PLUGIN_CONSTANTS_H_
-#define REMOTING_HOST_PLUGIN_CONSTANTS_H_
-
-// Warning: If you modify any macro in this file, make sure to modify
-// the following files too:
-// - remoting/branding_Chrome
-// - remoting/branding_Chromium
-// - remoting/remoting.gyp
-// - remoting/host/plugin/host_plugin.ver
-
-#define HOST_PLUGIN_DESCRIPTION \
- "Allow another user to access your computer securely over the Internet."
-#define HOST_PLUGIN_MIME_TYPE "application/vnd.chromium.remoting-host"
-
-#if defined(GOOGLE_CHROME_BUILD)
-#define HOST_PLUGIN_NAME "Chrome Remote Desktop Host"
-#else
-#define HOST_PLUGIN_NAME "Chromoting Host"
-#endif // defined(GOOGLE_CHROME_BUILD)
-
-#endif // REMOTING_HOST_PLUGIN_CONSTANTS_H_
diff --git a/remoting/host/plugin/host_plugin-Info.plist b/remoting/host/plugin/host_plugin-Info.plist
index 42cecdd..a2ff900 100644
--- a/remoting/host/plugin/host_plugin-Info.plist
+++ b/remoting/host/plugin/host_plugin-Info.plist
@@ -13,21 +13,17 @@
<key>CFBundlePackageType</key>
<string>BRPL</string>
<key>CFBundleShortVersionString</key>
- <string>1.0.0.0</string>
+ <string>VERSION_SHORT</string>
<key>CFBundleVersion</key>
- <string>1.0.0.0</string>
+ <string>VERSION_FULL</string>
<key>CFBundleSignature</key>
<string>${CHROMIUM_CREATOR}</string>
<key>LSMinimumSystemVersion</key>
<string>10.5.0</string>
- <key>WebPluginName</key>
- <string>HOST_PLUGIN_NAME</string>
<key>WebPluginMIMETypes</key>
<dict>
<key>HOST_PLUGIN_MIME_TYPE</key>
<dict/>
</dict>
- <key>WebPluginDescription</key>
- <string>HOST_PLUGIN_DESCRIPTION</string>
</dict>
</plist>
diff --git a/remoting/host/plugin/host_plugin-InfoPlist.strings.jinja2 b/remoting/host/plugin/host_plugin-InfoPlist.strings.jinja2
new file mode 100644
index 0000000..4bec263
--- /dev/null
+++ b/remoting/host/plugin/host_plugin-InfoPlist.strings.jinja2
@@ -0,0 +1,3 @@
+NSHumanReadableCopyright = "{% trans %}COPYRIGHT{% endtrans %}";
+WebPluginDescription = "{% trans %}REMOTING_HOST_PLUGIN_NAME{% endtrans %}";
+WebPluginName = "{% trans %}REMOTING_HOST_PLUGIN_DESCRIPTION{% endtrans %}";
diff --git a/remoting/host/plugin/host_plugin.cc b/remoting/host/plugin/host_plugin.cc
index 80d7cce..a0a98549 100644
--- a/remoting/host/plugin/host_plugin.cc
+++ b/remoting/host/plugin/host_plugin.cc
@@ -15,7 +15,8 @@
#include "base/strings/stringize_macros.h"
#include "net/socket/ssl_server_socket.h"
#include "remoting/base/plugin_thread_task_runner.h"
-#include "remoting/host/plugin/constants.h"
+#include "remoting/base/resources.h"
+#include "remoting/base/string_resources.h"
#include "remoting/host/plugin/host_log_handler.h"
#include "remoting/host/plugin/host_plugin_utils.h"
#include "remoting/host/plugin/host_script_object.h"
@@ -25,6 +26,7 @@
#include "third_party/npapi/bindings/npapi.h"
#include "third_party/npapi/bindings/npfunctions.h"
#include "third_party/npapi/bindings/npruntime.h"
+#include "ui/base/l10n/l10n_util.h"
// Symbol export is handled with a separate def file on Windows.
#if defined (__GNUC__) && __GNUC__ >= 4
@@ -56,8 +58,14 @@ using remoting::StringFromNPIdentifier;
namespace {
+bool g_initialized = false;
+
base::AtExitManager* g_at_exit_manager = NULL;
+// The plugin name and description returned by GetValue().
+std::string* g_ui_name = NULL;
+std::string* g_ui_description = NULL;
+
// NPAPI plugin implementation for remoting host.
// Documentation for most of the calls in this class can be found here:
// https://developer.mozilla.org/en/Gecko_Plugin_API_Reference/Scripting_plugins
@@ -355,6 +363,36 @@ class HostNPPlugin : public remoting::PluginThreadTaskRunner::Delegate {
base::Lock timers_lock_;
};
+void InitializePlugin() {
+ if (g_initialized)
+ return;
+
+ g_initialized = true;
+ g_at_exit_manager = new base::AtExitManager;
+
+ // Init an empty command line for common objects that use it.
+ CommandLine::Init(0, NULL);
+
+ if (remoting::LoadResources("")) {
+ g_ui_name = new std::string(
+ l10n_util::GetStringUTF8(IDR_REMOTING_HOST_PLUGIN_NAME));
+ g_ui_description = new std::string(
+ l10n_util::GetStringUTF8(IDR_REMOTING_HOST_PLUGIN_DESCRIPTION));
+ } else {
+ g_ui_name = new std::string();
+ g_ui_description = new std::string();
+ }
+}
+
+void ShutdownPlugin() {
+ delete g_ui_name;
+ delete g_ui_description;
+
+ remoting::UnloadResources();
+
+ delete g_at_exit_manager;
+}
+
// Utility functions to map NPAPI Entry Points to C++ Objects.
HostNPPlugin* PluginFromInstance(NPP instance) {
return reinterpret_cast<HostNPPlugin*>(instance->pdata);
@@ -408,17 +446,20 @@ NPError DestroyPlugin(NPP instance,
}
NPError GetValue(NPP instance, NPPVariable variable, void* value) {
+ // NP_GetValue() can be called before NP_Initialize().
+ InitializePlugin();
+
switch(variable) {
default:
VLOG(2) << "GetValue - default " << variable;
return NPERR_GENERIC_ERROR;
case NPPVpluginNameString:
VLOG(2) << "GetValue - name string";
- *reinterpret_cast<const char**>(value) = HOST_PLUGIN_NAME;
+ *reinterpret_cast<const char**>(value) = g_ui_name->c_str();
break;
case NPPVpluginDescriptionString:
VLOG(2) << "GetValue - description string";
- *reinterpret_cast<const char**>(value) = HOST_PLUGIN_DESCRIPTION;
+ *reinterpret_cast<const char**>(value) = g_ui_description->c_str();
break;
case NPPVpluginNeedsXEmbed:
VLOG(2) << "GetValue - NeedsXEmbed";
@@ -490,8 +531,7 @@ EXPORT NPError API_CALL NP_Initialize(NPNetscapeFuncs* npnetscape_funcs
#endif
) {
VLOG(2) << "NP_Initialize";
- if (g_at_exit_manager)
- return NPERR_MODULE_LOAD_FAILED_ERROR;
+ InitializePlugin();
if(npnetscape_funcs == NULL)
return NPERR_INVALID_FUNCTABLE_ERROR;
@@ -499,13 +539,10 @@ EXPORT NPError API_CALL NP_Initialize(NPNetscapeFuncs* npnetscape_funcs
if(((npnetscape_funcs->version & 0xff00) >> 8) > NP_VERSION_MAJOR)
return NPERR_INCOMPATIBLE_VERSION_ERROR;
- g_at_exit_manager = new base::AtExitManager;
g_npnetscape_funcs = npnetscape_funcs;
#if defined(OS_POSIX) && !defined(OS_MACOSX)
NP_GetEntryPoints(nppfuncs);
#endif
- // Init an empty command line for common objects that use it.
- CommandLine::Init(0, NULL);
#if defined(OS_WIN)
ui::EnableHighDPISupport();
@@ -516,8 +553,8 @@ EXPORT NPError API_CALL NP_Initialize(NPNetscapeFuncs* npnetscape_funcs
EXPORT NPError API_CALL NP_Shutdown() {
VLOG(2) << "NP_Shutdown";
- delete g_at_exit_manager;
- g_at_exit_manager = NULL;
+ ShutdownPlugin();
+
return NPERR_NO_ERROR;
}
diff --git a/remoting/host/plugin/host_script_object.cc b/remoting/host/plugin/host_script_object.cc
index 9b78eb3..f9a8299 100644
--- a/remoting/host/plugin/host_script_object.cc
+++ b/remoting/host/plugin/host_script_object.cc
@@ -18,6 +18,7 @@
#include "net/base/net_util.h"
#include "remoting/base/auth_token_util.h"
#include "remoting/base/auto_thread.h"
+#include "remoting/base/resources.h"
#include "remoting/base/rsa_key_pair.h"
#include "remoting/host/chromoting_host.h"
#include "remoting/host/chromoting_host_context.h"
@@ -104,8 +105,7 @@ class HostNPScriptObject::It2MeImpl
// Creates It2Me host structures and starts the host.
void Connect(const std::string& uid,
const std::string& auth_token,
- const std::string& auth_service,
- const UiStrings& ui_strings);
+ const std::string& auth_service);
// Disconnects the host, ready for tear-down.
// Also called internally, from the network thread.
@@ -222,22 +222,19 @@ HostNPScriptObject::It2MeImpl::It2MeImpl(
void HostNPScriptObject::It2MeImpl::Connect(
const std::string& uid,
const std::string& auth_token,
- const std::string& auth_service,
- const UiStrings& ui_strings) {
+ const std::string& auth_service) {
if (!host_context_->ui_task_runner()->BelongsToCurrentThread()) {
DCHECK(plugin_task_runner_->BelongsToCurrentThread());
host_context_->ui_task_runner()->PostTask(
FROM_HERE,
- base::Bind(&It2MeImpl::Connect, this, uid, auth_token, auth_service,
- ui_strings));
+ base::Bind(&It2MeImpl::Connect, this, uid, auth_token, auth_service));
return;
}
desktop_environment_factory_.reset(new It2MeDesktopEnvironmentFactory(
host_context_->network_task_runner(),
host_context_->input_task_runner(),
- host_context_->ui_task_runner(),
- ui_strings));
+ host_context_->ui_task_runner()));
// Start monitoring configured policies.
policy_watcher_.reset(
@@ -1056,7 +1053,7 @@ bool HostNPScriptObject::Connect(const NPVariant* args,
it2me_impl_ = new It2MeImpl(
host_context.Pass(), plugin_task_runner_, weak_ptr_,
xmpp_server_config_, directory_bot_jid_);
- it2me_impl_->Connect(uid, auth_token, auth_service, ui_strings_);
+ it2me_impl_->Connect(uid, auth_token, auth_service);
return true;
}
@@ -1496,23 +1493,13 @@ void HostNPScriptObject::SetWindow(NPWindow* np_window) {
void HostNPScriptObject::LocalizeStrings(NPObject* localize_func) {
DCHECK(plugin_task_runner_->BelongsToCurrentThread());
- string16 direction;
- LocalizeString(localize_func, "@@bidi_dir", &direction);
- ui_strings_.direction = UTF16ToUTF8(direction) == "rtl" ?
- remoting::UiStrings::RTL : remoting::UiStrings::LTR;
- LocalizeString(localize_func, /*i18n-content*/"PRODUCT_NAME",
- &ui_strings_.product_name);
- LocalizeString(localize_func, /*i18n-content*/"DISCONNECT_OTHER_BUTTON",
- &ui_strings_.disconnect_button_text);
- LocalizeString(localize_func, /*i18n-content*/"CONTINUE_PROMPT",
- &ui_strings_.continue_prompt);
- LocalizeString(localize_func, /*i18n-content*/"CONTINUE_BUTTON",
- &ui_strings_.continue_button_text);
- LocalizeString(localize_func, /*i18n-content*/"STOP_SHARING_BUTTON",
- &ui_strings_.stop_sharing_button_text);
- LocalizeStringWithSubstitution(localize_func,
- /*i18n-content*/"MESSAGE_SHARED", "$1",
- &ui_strings_.disconnect_message);
+ // Reload resources for the current locale. The default UI locale is used on
+ // Windows.
+#if !defined(OS_WIN)
+ string16 ui_locale;
+ LocalizeString(localize_func, "@@ui_locale", &ui_locale);
+ remoting::LoadResources(UTF16ToUTF8(ui_locale));
+#endif // !defined(OS_WIN)
}
bool HostNPScriptObject::LocalizeString(NPObject* localize_func,
diff --git a/remoting/host/plugin/host_script_object.h b/remoting/host/plugin/host_script_object.h
index a3d5bcd..e1120ec 100644
--- a/remoting/host/plugin/host_script_object.h
+++ b/remoting/host/plugin/host_script_object.h
@@ -25,7 +25,6 @@
#include "remoting/host/log_to_server.h"
#include "remoting/host/plugin/host_plugin_utils.h"
#include "remoting/host/setup/daemon_controller.h"
-#include "remoting/host/ui_strings.h"
#include "remoting/jingle_glue/xmpp_signal_strategy.h"
#include "remoting/protocol/pairing_registry.h"
#include "third_party/npapi/bindings/npapi.h"
@@ -302,9 +301,6 @@ class HostNPScriptObject {
base::TimeDelta access_code_lifetime_;
std::string client_username_;
- // Localized strings for use by the |it2me_impl_| UI.
- UiStrings ui_strings_;
-
// IT2Me Talk server configuration used by |it2me_impl_| to connect.
XmppSignalStrategy::XmppServerConfig xmpp_server_config_;