summaryrefslogtreecommitdiffstats
path: root/remoting
diff options
context:
space:
mode:
Diffstat (limited to 'remoting')
-rw-r--r--remoting/base/constants.cc2
-rw-r--r--remoting/base/constants.h2
-rw-r--r--remoting/host/heartbeat_sender.cc8
-rw-r--r--remoting/host/heartbeat_sender.h4
-rw-r--r--remoting/host/heartbeat_sender_unittest.cc7
-rw-r--r--remoting/host/host_change_notification_listener.cc6
-rw-r--r--remoting/host/host_change_notification_listener.h4
-rw-r--r--remoting/host/host_change_notification_listener_unittest.cc11
-rw-r--r--remoting/host/log_to_server.cc8
-rw-r--r--remoting/host/log_to_server.h5
-rw-r--r--remoting/host/log_to_server_unittest.cc4
-rw-r--r--remoting/host/plugin/host_plugin.cc3
-rw-r--r--remoting/host/plugin/host_script_object.cc98
-rw-r--r--remoting/host/plugin/host_script_object.h7
-rw-r--r--remoting/host/register_support_host_request.cc4
-rw-r--r--remoting/host/register_support_host_request.h2
-rw-r--r--remoting/host/register_support_host_request_unittest.cc6
-rw-r--r--remoting/host/remoting_me2me_host.cc25
-rw-r--r--remoting/host/service_client.cc19
-rw-r--r--remoting/host/service_client.h3
-rw-r--r--remoting/host/service_urls.cc86
-rw-r--r--remoting/host/service_urls.h51
-rw-r--r--remoting/host/setup/host_starter.cc9
-rw-r--r--remoting/host/setup/host_starter.h2
-rw-r--r--remoting/host/setup/start_host.cc7
-rw-r--r--remoting/host/setup/win/start_host_window.cc7
-rw-r--r--remoting/host/signaling_connector.cc6
-rw-r--r--remoting/jingle_glue/xmpp_signal_strategy.cc29
-rw-r--r--remoting/jingle_glue/xmpp_signal_strategy.h11
-rw-r--r--remoting/remoting.gyp2
-rwxr-xr-xremoting/webapp/build-webapp.py92
-rw-r--r--remoting/webapp/client_screen.js2
-rw-r--r--remoting/webapp/format_iq.js9
-rw-r--r--remoting/webapp/host_controller.js2
-rw-r--r--remoting/webapp/host_list.js6
-rw-r--r--remoting/webapp/host_plugin_proto.js4
-rw-r--r--remoting/webapp/host_session.js5
-rw-r--r--remoting/webapp/log_to_server.js3
-rw-r--r--remoting/webapp/manifest.json9
-rw-r--r--remoting/webapp/oauth2.js80
-rw-r--r--remoting/webapp/oauth2_callback.js3
-rw-r--r--remoting/webapp/plugin_settings.js53
-rw-r--r--remoting/webapp/remoting.js1
-rw-r--r--remoting/webapp/wcs_loader.js18
-rw-r--r--remoting/webapp/wcs_sandbox.html1
-rw-r--r--remoting/webapp/wcs_sandbox_content.js1
46 files changed, 578 insertions, 149 deletions
diff --git a/remoting/base/constants.cc b/remoting/base/constants.cc
index a93f0f4..0099570 100644
--- a/remoting/base/constants.cc
+++ b/remoting/base/constants.cc
@@ -6,8 +6,6 @@
namespace remoting {
-const char kChromotingBotJid[] = "remoting@bot.talk.google.com";
-
const char kChromotingTokenDefaultServiceName[] = "chromiumsync";
const char kChromotingXmlNamespace[] = "google:remoting";
diff --git a/remoting/base/constants.h b/remoting/base/constants.h
index f5ea537..80c5572 100644
--- a/remoting/base/constants.h
+++ b/remoting/base/constants.h
@@ -7,8 +7,6 @@
namespace remoting {
-extern const char kChromotingBotJid[];
-
// Service name used for authentication.
// TODO(ajwong): Remove this once we've killed off XmppToken usage.
// BUG:83897
diff --git a/remoting/host/heartbeat_sender.cc b/remoting/host/heartbeat_sender.cc
index 167b5e1..0a5a181 100644
--- a/remoting/host/heartbeat_sender.cc
+++ b/remoting/host/heartbeat_sender.cc
@@ -49,11 +49,13 @@ HeartbeatSender::HeartbeatSender(
Listener* listener,
const std::string& host_id,
SignalStrategy* signal_strategy,
- HostKeyPair* key_pair)
+ HostKeyPair* key_pair,
+ const std::string& directory_bot_jid)
: listener_(listener),
host_id_(host_id),
signal_strategy_(signal_strategy),
key_pair_(key_pair),
+ directory_bot_jid_(directory_bot_jid),
interval_ms_(kDefaultHeartbeatIntervalMs),
sequence_id_(0),
sequence_id_was_set_(false),
@@ -107,9 +109,9 @@ void HeartbeatSender::ResendStanza() {
}
void HeartbeatSender::DoSendStanza() {
- VLOG(1) << "Sending heartbeat stanza to " << kChromotingBotJid;
+ VLOG(1) << "Sending heartbeat stanza to " << directory_bot_jid_;
request_ = iq_sender_->SendIq(
- buzz::STR_SET, kChromotingBotJid, CreateHeartbeatMessage(),
+ buzz::STR_SET, directory_bot_jid_, CreateHeartbeatMessage(),
base::Bind(&HeartbeatSender::ProcessResponse,
base::Unretained(this)));
++sequence_id_;
diff --git a/remoting/host/heartbeat_sender.h b/remoting/host/heartbeat_sender.h
index 2fb2dae..2d0986d 100644
--- a/remoting/host/heartbeat_sender.h
+++ b/remoting/host/heartbeat_sender.h
@@ -92,7 +92,8 @@ class HeartbeatSender : public SignalStrategy::Listener {
HeartbeatSender(Listener* listener,
const std::string& host_id,
SignalStrategy* signal_strategy,
- HostKeyPair* key_pair);
+ HostKeyPair* key_pair,
+ const std::string& directory_bot_jid);
virtual ~HeartbeatSender();
// SignalStrategy::Listener interface.
@@ -125,6 +126,7 @@ class HeartbeatSender : public SignalStrategy::Listener {
std::string host_id_;
SignalStrategy* signal_strategy_;
HostKeyPair* key_pair_;
+ std::string directory_bot_jid_;
scoped_ptr<IqSender> iq_sender_;
scoped_ptr<IqRequest> request_;
int interval_ms_;
diff --git a/remoting/host/heartbeat_sender_unittest.cc b/remoting/host/heartbeat_sender_unittest.cc
index 4d050d7d..0947937 100644
--- a/remoting/host/heartbeat_sender_unittest.cc
+++ b/remoting/host/heartbeat_sender_unittest.cc
@@ -34,6 +34,7 @@ using testing::SaveArg;
namespace remoting {
namespace {
+const char kTestBotJid[] = "remotingunittest@bot.talk.google.com";
const char kHostId[] = "0";
const char kTestJid[] = "user@gmail.com/chromoting123";
const char kStanzaId[] = "123";
@@ -68,8 +69,8 @@ class HeartbeatSenderTest
EXPECT_CALL(signal_strategy_, GetLocalJid())
.WillRepeatedly(Return(kTestJid));
- heartbeat_sender_.reset(
- new HeartbeatSender(this, kHostId, &signal_strategy_, &key_pair_));
+ heartbeat_sender_.reset(new HeartbeatSender(
+ this, kHostId, &signal_strategy_, &key_pair_, kTestBotJid));
}
virtual void TearDown() OVERRIDE {
@@ -220,7 +221,7 @@ TEST_F(HeartbeatSenderTest, ProcessResponseSetInterval) {
void HeartbeatSenderTest::ValidateHeartbeatStanza(
XmlElement* stanza, const char* expectedSequenceId) {
EXPECT_EQ(stanza->Attr(buzz::QName("", "to")),
- std::string(kChromotingBotJid));
+ std::string(kTestBotJid));
EXPECT_EQ(stanza->Attr(buzz::QName("", "type")), "set");
XmlElement* heartbeat_stanza =
stanza->FirstNamed(QName(kChromotingXmlNamespace, "heartbeat"));
diff --git a/remoting/host/host_change_notification_listener.cc b/remoting/host/host_change_notification_listener.cc
index 995928b..4805ec3 100644
--- a/remoting/host/host_change_notification_listener.cc
+++ b/remoting/host/host_change_notification_listener.cc
@@ -23,10 +23,12 @@ namespace remoting {
HostChangeNotificationListener::HostChangeNotificationListener(
Listener* listener,
const std::string& host_id,
- SignalStrategy* signal_strategy)
+ SignalStrategy* signal_strategy,
+ const std::string& directory_bot_jid)
: listener_(listener),
host_id_(host_id),
signal_strategy_(signal_strategy),
+ directory_bot_jid_(directory_bot_jid),
ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
DCHECK(signal_strategy_);
@@ -55,7 +57,7 @@ bool HostChangeNotificationListener::OnSignalStrategyIncomingStanza(
host_changed_element->Attr(QName(kChromotingXmlNamespace, "hostid"));
const std::string& from = stanza->Attr(buzz::QN_FROM);
const std::string& to = stanza->Attr(buzz::QN_TO);
- if (host_id == host_id_ && from == kChromotingBotJid &&
+ if (host_id == host_id_ && from == directory_bot_jid_ &&
to == signal_strategy_->GetLocalJid()) {
const std::string& operation =
host_changed_element->Attr(QName(kChromotingXmlNamespace, "operation"));
diff --git a/remoting/host/host_change_notification_listener.h b/remoting/host/host_change_notification_listener.h
index 19ee106..ae1ba0e 100644
--- a/remoting/host/host_change_notification_listener.h
+++ b/remoting/host/host_change_notification_listener.h
@@ -35,7 +35,8 @@ class HostChangeNotificationListener : public SignalStrategy::Listener {
// Both listener and signal_strategy are expected to outlive this object.
HostChangeNotificationListener(Listener* listener,
const std::string& host_id,
- SignalStrategy* signal_strategy);
+ SignalStrategy* signal_strategy,
+ const std::string& directory_bot_jid);
virtual ~HostChangeNotificationListener();
// SignalStrategy::Listener interface.
@@ -50,6 +51,7 @@ class HostChangeNotificationListener : public SignalStrategy::Listener {
Listener* listener_;
std::string host_id_;
SignalStrategy* signal_strategy_;
+ std::string directory_bot_jid_;
base::WeakPtrFactory<HostChangeNotificationListener> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(HostChangeNotificationListener);
};
diff --git a/remoting/host/host_change_notification_listener_unittest.cc b/remoting/host/host_change_notification_listener_unittest.cc
index a0f124f..1f9305e 100644
--- a/remoting/host/host_change_notification_listener_unittest.cc
+++ b/remoting/host/host_change_notification_listener_unittest.cc
@@ -28,6 +28,7 @@ namespace remoting {
namespace {
const char kHostId[] = "0";
const char kTestJid[] = "user@gmail.com/chromoting123";
+const char kTestBotJid[] = "remotingunittest@bot.talk.google.com";
} // namespace
ACTION_P(AddListener, list) {
@@ -56,7 +57,7 @@ class HostChangeNotificationListenerTest : public testing::Test {
.WillRepeatedly(Return(kTestJid));
host_change_notification_listener_.reset(new HostChangeNotificationListener(
- &mock_listener_, kHostId, &signal_strategy_));
+ &mock_listener_, kHostId, &signal_strategy_, kTestBotJid));
}
virtual void TearDown() OVERRIDE {
@@ -91,7 +92,7 @@ TEST_F(HostChangeNotificationListenerTest, ReceiveValidNotification) {
EXPECT_CALL(mock_listener_, OnHostDeleted())
.WillOnce(Return());
scoped_ptr<XmlElement> stanza = GetNotificationStanza(
- "delete", kHostId, kChromotingBotJid);
+ "delete", kHostId, kTestBotJid);
host_change_notification_listener_->OnSignalStrategyIncomingStanza(
stanza.get());
message_loop_.PostTask(FROM_HERE, base::Bind(MessageLoop::QuitClosure()));
@@ -102,7 +103,7 @@ TEST_F(HostChangeNotificationListenerTest, ReceiveNotificationBeforeDelete) {
EXPECT_CALL(mock_listener_, OnHostDeleted())
.Times(0);
scoped_ptr<XmlElement> stanza = GetNotificationStanza(
- "delete", kHostId, kChromotingBotJid);
+ "delete", kHostId, kTestBotJid);
host_change_notification_listener_->OnSignalStrategyIncomingStanza(
stanza.get());
host_change_notification_listener_.reset();
@@ -115,7 +116,7 @@ TEST_F(HostChangeNotificationListenerTest, ReceiveInvalidHostIdNotification) {
EXPECT_CALL(mock_listener_, OnHostDeleted())
.Times(0);
scoped_ptr<XmlElement> stanza = GetNotificationStanza(
- "delete", "1", kChromotingBotJid);
+ "delete", "1", kTestBotJid);
host_change_notification_listener_->OnSignalStrategyIncomingStanza(
stanza.get());
message_loop_.PostTask(FROM_HERE, base::Bind(MessageLoop::QuitClosure()));
@@ -137,7 +138,7 @@ TEST_F(HostChangeNotificationListenerTest, ReceiveNonDeleteNotification) {
EXPECT_CALL(mock_listener_, OnHostDeleted())
.Times(0);
scoped_ptr<XmlElement> stanza = GetNotificationStanza(
- "update", kHostId, kChromotingBotJid);
+ "update", kHostId, kTestBotJid);
host_change_notification_listener_->OnSignalStrategyIncomingStanza(
stanza.get());
message_loop_.PostTask(FROM_HERE, base::Bind(MessageLoop::QuitClosure()));
diff --git a/remoting/host/log_to_server.cc b/remoting/host/log_to_server.cc
index a184de0..f4830f6 100644
--- a/remoting/host/log_to_server.cc
+++ b/remoting/host/log_to_server.cc
@@ -22,10 +22,12 @@ namespace remoting {
LogToServer::LogToServer(ChromotingHost* host,
ServerLogEntry::Mode mode,
- SignalStrategy* signal_strategy)
+ SignalStrategy* signal_strategy,
+ const std::string& directory_bot_jid)
: host_(host),
mode_(mode),
- signal_strategy_(signal_strategy) {
+ signal_strategy_(signal_strategy),
+ directory_bot_jid_(directory_bot_jid) {
signal_strategy_->AddListener(this);
// |host| may be NULL in tests.
@@ -113,7 +115,7 @@ void LogToServer::SendPendingEntries() {
}
// Send the stanza to the server.
scoped_ptr<IqRequest> req = iq_sender_->SendIq(
- buzz::STR_SET, kChromotingBotJid, stanza.Pass(),
+ buzz::STR_SET, directory_bot_jid_, stanza.Pass(),
IqSender::ReplyCallback());
// We ignore any response, so let the IqRequest be destroyed.
return;
diff --git a/remoting/host/log_to_server.h b/remoting/host/log_to_server.h
index c1f844a..e65adae 100644
--- a/remoting/host/log_to_server.h
+++ b/remoting/host/log_to_server.h
@@ -39,7 +39,8 @@ class LogToServer : public base::NonThreadSafe,
public:
explicit LogToServer(ChromotingHost* host,
ServerLogEntry::Mode mode,
- SignalStrategy* signal_strategy);
+ SignalStrategy* signal_strategy,
+ const std::string& directory_bot_jid);
virtual ~LogToServer();
// Logs a session state change. Currently, this is either
@@ -68,6 +69,8 @@ class LogToServer : public base::NonThreadSafe,
ServerLogEntry::Mode mode_;
SignalStrategy* signal_strategy_;
scoped_ptr<IqSender> iq_sender_;
+ std::string directory_bot_jid_;
+
// A map from client JID to the route type of that client's connection to
// this host.
std::map<std::string, protocol::TransportRoute::RouteType>
diff --git a/remoting/host/log_to_server_unittest.cc b/remoting/host/log_to_server_unittest.cc
index 54674fa..4277e49 100644
--- a/remoting/host/log_to_server_unittest.cc
+++ b/remoting/host/log_to_server_unittest.cc
@@ -28,6 +28,7 @@ ACTION_P(QuitMainMessageLoop, message_loop) {
const char kJabberClientNamespace[] = "jabber:client";
const char kChromotingNamespace[] = "google:remoting";
+const char kTestBotJid[] = "remotingunittest@bot.talk.google.com";
const char kClientJid1[] = "client@domain.com/1234";
const char kClientJid2[] = "client@domain.com/5678";
const char kHostJid[] = "host@domain.com/1234";
@@ -125,7 +126,8 @@ class LogToServerTest : public testing::Test {
message_loop_proxy_ = base::MessageLoopProxy::current();
EXPECT_CALL(signal_strategy_, AddListener(_));
log_to_server_.reset(
- new LogToServer(NULL, ServerLogEntry::ME2ME, &signal_strategy_));
+ new LogToServer(NULL, ServerLogEntry::ME2ME, &signal_strategy_,
+ kTestBotJid));
EXPECT_CALL(signal_strategy_, RemoveListener(_));
}
diff --git a/remoting/host/plugin/host_plugin.cc b/remoting/host/plugin/host_plugin.cc
index 4b9c714..247dd06 100644
--- a/remoting/host/plugin/host_plugin.cc
+++ b/remoting/host/plugin/host_plugin.cc
@@ -10,6 +10,7 @@
#include "base/at_exit.h"
#include "base/basictypes.h"
+#include "base/command_line.h"
#include "base/logging.h"
#include "base/strings/stringize_macros.h"
#include "net/socket/ssl_server_socket.h"
@@ -500,6 +501,8 @@ EXPORT NPError API_CALL NP_Initialize(NPNetscapeFuncs* 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);
return NPERR_NO_ERROR;
}
diff --git a/remoting/host/plugin/host_script_object.cc b/remoting/host/plugin/host_script_object.cc
index 0c14151..82c991d 100644
--- a/remoting/host/plugin/host_script_object.cc
+++ b/remoting/host/plugin/host_script_object.cc
@@ -10,6 +10,7 @@
#include "base/message_loop.h"
#include "base/message_loop_proxy.h"
#include "base/string_util.h"
+#include "base/stringprintf.h"
#include "base/sys_string_conversions.h"
#include "base/threading/platform_thread.h"
#include "base/utf_string_conversions.h"
@@ -31,9 +32,11 @@
#include "remoting/host/plugin/host_log_handler.h"
#include "remoting/host/policy_hack/policy_watcher.h"
#include "remoting/host/register_support_host_request.h"
+#include "remoting/host/service_urls.h"
#include "remoting/host/session_manager_factory.h"
#include "remoting/jingle_glue/xmpp_signal_strategy.h"
#include "remoting/protocol/it2me_host_authenticator_factory.h"
+#include "third_party/npapi/bindings/npruntime.h"
namespace remoting {
@@ -51,6 +54,9 @@ const char* kAttrNameLogDebugInfo = "logDebugInfo";
const char* kAttrNameOnNatTraversalPolicyChanged =
"onNatTraversalPolicyChanged";
const char* kAttrNameOnStateChanged = "onStateChanged";
+const char* kAttrNameXmppServerAddress = "xmppServerAddress";
+const char* kAttrNameXmppServerUseTls = "xmppServerUseTls";
+const char* kAttrNameDirectoryBotJid = "directoryBotJid";
const char* kFuncNameConnect = "connect";
const char* kFuncNameDisconnect = "disconnect";
const char* kFuncNameLocalize = "localize";
@@ -86,7 +92,9 @@ class HostNPScriptObject::It2MeImpl
It2MeImpl(
scoped_ptr<ChromotingHostContext> context,
scoped_refptr<base::SingleThreadTaskRunner> plugin_task_runner,
- base::WeakPtr<HostNPScriptObject> script_object);
+ base::WeakPtr<HostNPScriptObject> script_object,
+ const XmppSignalStrategy::XmppServerConfig& xmpp_server_config,
+ const std::string& directory_bot_jid);
// Methods called by the script object, from the plugin thread.
@@ -145,9 +153,12 @@ class HostNPScriptObject::It2MeImpl
void UpdateNatPolicy(bool nat_traversal_enabled);
void UpdateHostDomainPolicy(const std::string& host_domain);
+ // Caller supplied fields.
scoped_ptr<ChromotingHostContext> host_context_;
scoped_refptr<base::SingleThreadTaskRunner> plugin_task_runner_;
base::WeakPtr<HostNPScriptObject> script_object_;
+ XmppSignalStrategy::XmppServerConfig xmpp_server_config_;
+ std::string directory_bot_jid_;
State state_;
@@ -187,10 +198,14 @@ class HostNPScriptObject::It2MeImpl
HostNPScriptObject::It2MeImpl::It2MeImpl(
scoped_ptr<ChromotingHostContext> host_context,
scoped_refptr<base::SingleThreadTaskRunner> plugin_task_runner,
- base::WeakPtr<HostNPScriptObject> script_object)
+ base::WeakPtr<HostNPScriptObject> script_object,
+ const XmppSignalStrategy::XmppServerConfig& xmpp_server_config,
+ const std::string& directory_bot_jid)
: host_context_(host_context.Pass()),
plugin_task_runner_(plugin_task_runner),
script_object_(script_object),
+ xmpp_server_config_(xmpp_server_config),
+ directory_bot_jid_(directory_bot_jid),
state_(kDisconnected),
failed_login_attempts_(0),
nat_traversal_enabled_(false),
@@ -334,12 +349,13 @@ void HostNPScriptObject::It2MeImpl::FinishConnect(
// Create XMPP connection.
scoped_ptr<SignalStrategy> signal_strategy(
new XmppSignalStrategy(host_context_->url_request_context_getter(),
- uid, auth_token, auth_service));
+ uid, auth_token, auth_service,
+ xmpp_server_config_));
// Request registration of the host for support.
scoped_ptr<RegisterSupportHostRequest> register_request(
new RegisterSupportHostRequest(
- signal_strategy.get(), &host_key_pair_,
+ signal_strategy.get(), &host_key_pair_, directory_bot_jid_,
base::Bind(&It2MeImpl::OnReceivedSupportID,
base::Unretained(this))));
@@ -372,7 +388,8 @@ void HostNPScriptObject::It2MeImpl::FinishConnect(
host_context_->ui_task_runner());
host_->AddStatusObserver(this);
log_to_server_.reset(
- new LogToServer(host_, ServerLogEntry::IT2ME, signal_strategy_.get()));
+ new LogToServer(host_, ServerLogEntry::IT2ME, signal_strategy_.get(),
+ directory_bot_jid_));
// Disable audio by default.
// TODO(sergeyu): Add UI to enable it.
@@ -658,6 +675,14 @@ HostNPScriptObject::HostNPScriptObject(
ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)),
weak_ptr_(weak_factory_.GetWeakPtr()) {
DCHECK(plugin_task_runner_->BelongsToCurrentThread());
+ ServiceUrls* service_urls = ServiceUrls::GetInstance();
+ bool xmpp_server_valid = net::ParseHostAndPort(
+ service_urls->xmpp_server_address(),
+ &xmpp_server_config_.host, &xmpp_server_config_.port);
+ // For the plugin, this is always the default address, which must be valid.
+ DCHECK(xmpp_server_valid);
+ xmpp_server_config_.use_tls = service_urls->xmpp_server_use_tls();
+ directory_bot_jid_ = service_urls->directory_bot_jid();
// Create worker thread for encryption key generation.
worker_thread_ = AutoThread::Create("ChromotingWorkerThread",
@@ -755,7 +780,10 @@ bool HostNPScriptObject::HasProperty(const std::string& property_name) {
property_name == kAttrNameReceivedAccessCode ||
property_name == kAttrNameConnected ||
property_name == kAttrNameDisconnecting ||
- property_name == kAttrNameError);
+ property_name == kAttrNameError ||
+ property_name == kAttrNameXmppServerAddress ||
+ property_name == kAttrNameXmppServerUseTls ||
+ property_name == kAttrNameDirectoryBotJid);
}
bool HostNPScriptObject::GetProperty(const std::string& property_name,
@@ -815,6 +843,16 @@ bool HostNPScriptObject::GetProperty(const std::string& property_name,
} else if (property_name == kAttrNameInvalidDomainError) {
INT32_TO_NPVARIANT(kInvalidDomainError, *result);
return true;
+ } else if (property_name == kAttrNameXmppServerAddress) {
+ *result = NPVariantFromString(base::StringPrintf(
+ "%s:%u", xmpp_server_config_.host.c_str(), xmpp_server_config_.port));
+ return true;
+ } else if (property_name == kAttrNameXmppServerUseTls) {
+ BOOLEAN_TO_NPVARIANT(xmpp_server_config_.use_tls, *result);
+ return true;
+ } else if (property_name == kAttrNameDirectoryBotJid) {
+ *result = NPVariantFromString(directory_bot_jid_);
+ return true;
} else {
SetException("GetProperty: unsupported property " + property_name);
return false;
@@ -864,6 +902,48 @@ bool HostNPScriptObject::SetProperty(const std::string& property_name,
return false;
}
+#if !defined(NDEBUG)
+ if (property_name == kAttrNameXmppServerAddress) {
+ if (NPVARIANT_IS_STRING(*value)) {
+ std::string address = StringFromNPVariant(*value);
+ bool xmpp_server_valid = net::ParseHostAndPort(
+ address, &xmpp_server_config_.host, &xmpp_server_config_.port);
+ if (xmpp_server_valid) {
+ return true;
+ } else {
+ SetException("SetProperty: invalid value for property " +
+ property_name);
+ }
+ } else {
+ SetException("SetProperty: unexpected type for property " +
+ property_name);
+ }
+ return false;
+ }
+
+ if (property_name == kAttrNameXmppServerUseTls) {
+ if (NPVARIANT_IS_BOOLEAN(*value)) {
+ xmpp_server_config_.use_tls = NPVARIANT_TO_BOOLEAN(*value);
+ return true;
+ } else {
+ SetException("SetProperty: unexpected type for property " +
+ property_name);
+ }
+ return false;
+ }
+
+ if (property_name == kAttrNameDirectoryBotJid) {
+ if (NPVARIANT_IS_STRING(*value)) {
+ directory_bot_jid_ = StringFromNPVariant(*value);
+ return true;
+ } else {
+ SetException("SetProperty: unexpected type for property " +
+ property_name);
+ }
+ return false;
+ }
+#endif // !defined(NDEBUG)
+
return false;
}
@@ -888,6 +968,9 @@ bool HostNPScriptObject::Enumerate(std::vector<std::string>* values) {
kAttrNameConnected,
kAttrNameDisconnecting,
kAttrNameError,
+ kAttrNameXmppServerAddress,
+ kAttrNameXmppServerUseTls,
+ kAttrNameDirectoryBotJid,
kFuncNameConnect,
kFuncNameDisconnect,
kFuncNameLocalize,
@@ -951,7 +1034,8 @@ bool HostNPScriptObject::Connect(const NPVariant* args,
// Create the It2Me host implementation and start connecting.
it2me_impl_ = new It2MeImpl(
- host_context.Pass(), plugin_task_runner_, weak_ptr_);
+ host_context.Pass(), plugin_task_runner_, weak_ptr_,
+ xmpp_server_config_, directory_bot_jid_);
it2me_impl_->Connect(uid, auth_token, auth_service, ui_strings_);
return true;
diff --git a/remoting/host/plugin/host_script_object.h b/remoting/host/plugin/host_script_object.h
index 22baee5..ffa1b1d 100644
--- a/remoting/host/plugin/host_script_object.h
+++ b/remoting/host/plugin/host_script_object.h
@@ -26,6 +26,7 @@
#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 "third_party/npapi/bindings/npapi.h"
#include "third_party/npapi/bindings/npfunctions.h"
#include "third_party/npapi/bindings/npruntime.h"
@@ -274,6 +275,12 @@ class HostNPScriptObject {
// 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_;
+
+ // Chromoting Bot JID used by |it2me_impl_| to register the host.
+ std::string directory_bot_jid_;
+
// Callbacks to notify in response to |it2me_impl_| events.
ScopedRefNPObject on_nat_traversal_policy_changed_func_;
ScopedRefNPObject on_state_changed_func_;
diff --git a/remoting/host/register_support_host_request.cc b/remoting/host/register_support_host_request.cc
index 1272c07..b149851 100644
--- a/remoting/host/register_support_host_request.cc
+++ b/remoting/host/register_support_host_request.cc
@@ -37,9 +37,11 @@ const char kSupportIdLifetimeTag[] = "support-id-lifetime";
RegisterSupportHostRequest::RegisterSupportHostRequest(
SignalStrategy* signal_strategy,
HostKeyPair* key_pair,
+ const std::string& directory_bot_jid,
const RegisterCallback& callback)
: signal_strategy_(signal_strategy),
key_pair_(key_pair),
+ directory_bot_jid_(directory_bot_jid),
callback_(callback) {
DCHECK(signal_strategy_);
DCHECK(key_pair_);
@@ -58,7 +60,7 @@ void RegisterSupportHostRequest::OnSignalStrategyStateChange(
DCHECK(!callback_.is_null());
request_ = iq_sender_->SendIq(
- buzz::STR_SET, kChromotingBotJid,
+ buzz::STR_SET, directory_bot_jid_,
CreateRegistrationRequest(signal_strategy_->GetLocalJid()).Pass(),
base::Bind(&RegisterSupportHostRequest::ProcessResponse,
base::Unretained(this)));
diff --git a/remoting/host/register_support_host_request.h b/remoting/host/register_support_host_request.h
index 8532534..fd9758c85 100644
--- a/remoting/host/register_support_host_request.h
+++ b/remoting/host/register_support_host_request.h
@@ -50,6 +50,7 @@ class RegisterSupportHostRequest : public SignalStrategy::Listener {
// response.
RegisterSupportHostRequest(SignalStrategy* signal_strategy,
HostKeyPair* key_pair,
+ const std::string& directory_bot_jid,
const RegisterCallback& callback);
virtual ~RegisterSupportHostRequest();
@@ -75,6 +76,7 @@ class RegisterSupportHostRequest : public SignalStrategy::Listener {
SignalStrategy* signal_strategy_;
HostKeyPair* key_pair_;
+ std::string directory_bot_jid_;
RegisterCallback callback_;
scoped_ptr<IqSender> iq_sender_;
diff --git a/remoting/host/register_support_host_request_unittest.cc b/remoting/host/register_support_host_request_unittest.cc
index 0eb1c5f..81b5c42 100644
--- a/remoting/host/register_support_host_request_unittest.cc
+++ b/remoting/host/register_support_host_request_unittest.cc
@@ -32,6 +32,7 @@ using testing::SaveArg;
namespace remoting {
namespace {
+const char kTestBotJid[] = "remotingunittest@bot.talk.google.com";
const char kTestJid[] = "user@gmail.com/chromoting123";
const int64 kTestTime = 123123123;
const char kSupportId[] = "AB4RF3";
@@ -80,6 +81,7 @@ TEST_F(RegisterSupportHostRequestTest, Send) {
scoped_ptr<RegisterSupportHostRequest> request(
new RegisterSupportHostRequest(&signal_strategy_, &key_pair_,
+ kTestBotJid,
base::Bind(&MockCallback::OnResponse,
base::Unretained(&callback_))));
@@ -97,7 +99,7 @@ TEST_F(RegisterSupportHostRequestTest, Send) {
ASSERT_TRUE(stanza != NULL);
EXPECT_EQ(stanza->Attr(buzz::QName("", "to")),
- std::string(kChromotingBotJid));
+ std::string(kTestBotJid));
EXPECT_EQ(stanza->Attr(buzz::QName("", "type")), "set");
EXPECT_EQ(QName(kChromotingXmlNamespace, "register-support-host"),
@@ -127,7 +129,7 @@ TEST_F(RegisterSupportHostRequestTest, Send) {
base::TimeDelta::FromSeconds(300)));
scoped_ptr<XmlElement> response(new XmlElement(buzz::QN_IQ));
- response->AddAttr(QName("", "from"), kChromotingBotJid);
+ response->AddAttr(QName("", "from"), kTestBotJid);
response->AddAttr(QName("", "type"), "result");
response->AddAttr(QName("", "id"), kStanzaId);
diff --git a/remoting/host/remoting_me2me_host.cc b/remoting/host/remoting_me2me_host.cc
index 1aa1f9c..b4a35bd 100644
--- a/remoting/host/remoting_me2me_host.cc
+++ b/remoting/host/remoting_me2me_host.cc
@@ -63,6 +63,7 @@
#include "remoting/host/network_settings.h"
#include "remoting/host/policy_hack/policy_watcher.h"
#include "remoting/host/resizing_host_observer.h"
+#include "remoting/host/service_urls.h"
#include "remoting/host/session_manager_factory.h"
#include "remoting/host/signaling_connector.h"
#include "remoting/host/ui_strings.h"
@@ -275,6 +276,10 @@ class HostProcess
// Accessed on the UI thread.
scoped_ptr<IPC::ChannelProxy> daemon_channel_;
+ // XMPP server/remoting bot configuration (initialized from the command line).
+ XmppSignalStrategy::XmppServerConfig xmpp_server_config_;
+ std::string directory_bot_jid_;
+
// Created on the UI thread but used from the network thread.
base::FilePath host_config_path_;
scoped_ptr<DesktopEnvironmentFactory> desktop_environment_factory_;
@@ -412,6 +417,17 @@ bool HostProcess::InitWithCommandLine(const CommandLine* cmd_line) {
}
#endif // !defined(REMOTING_MULTI_PROCESS)
+ ServiceUrls* service_urls = ServiceUrls::GetInstance();
+ bool xmpp_server_valid = net::ParseHostAndPort(
+ service_urls->xmpp_server_address(),
+ &xmpp_server_config_.host, &xmpp_server_config_.port);
+ if (!xmpp_server_valid) {
+ LOG(ERROR) << "Invalid XMPP server: " <<
+ service_urls->xmpp_server_address();
+ return false;
+ }
+ xmpp_server_config_.use_tls = service_urls->xmpp_server_use_tls();
+ directory_bot_jid_ = service_urls->directory_bot_jid();
return true;
}
@@ -867,7 +883,7 @@ void HostProcess::StartHost() {
signal_strategy_.reset(
new XmppSignalStrategy(context_->url_request_context_getter(),
xmpp_login_, xmpp_auth_token_,
- xmpp_auth_service_));
+ xmpp_auth_service_, xmpp_server_config_));
scoped_ptr<DnsBlackholeChecker> dns_blackhole_checker(
new DnsBlackholeChecker(context_->url_request_context_getter(),
@@ -913,13 +929,14 @@ void HostProcess::StartHost() {
#endif
heartbeat_sender_.reset(new HeartbeatSender(
- this, host_id_, signal_strategy_.get(), &key_pair_));
+ this, host_id_, signal_strategy_.get(), &key_pair_, directory_bot_jid_));
host_change_notification_listener_.reset(new HostChangeNotificationListener(
- this, host_id_, signal_strategy_.get()));
+ this, host_id_, signal_strategy_.get(), directory_bot_jid_));
log_to_server_.reset(
- new LogToServer(host_, ServerLogEntry::ME2ME, signal_strategy_.get()));
+ new LogToServer(host_, ServerLogEntry::ME2ME, signal_strategy_.get(),
+ directory_bot_jid_));
host_event_logger_ = HostEventLogger::Create(host_, kApplicationName);
resizing_host_observer_.reset(
diff --git a/remoting/host/service_client.cc b/remoting/host/service_client.cc
index 26e4eef..6db1c6e 100644
--- a/remoting/host/service_client.cc
+++ b/remoting/host/service_client.cc
@@ -13,21 +13,18 @@
#include "net/url_request/url_fetcher_delegate.h"
#include "net/url_request/url_request_context_getter.h"
-namespace {
-const char kServiceUrl[] =
- "https://www.googleapis.com/chromoting/v1/@me/hosts/";
-} // namespace
-
namespace remoting {
class ServiceClient::Core
: public base::RefCountedThreadSafe<ServiceClient::Core>,
public net::URLFetcherDelegate {
public:
- Core(net::URLRequestContextGetter* request_context_getter)
+ Core(const std::string& chromoting_hosts_url,
+ net::URLRequestContextGetter* request_context_getter)
: request_context_getter_(request_context_getter),
delegate_(NULL),
- pending_request_type_(PENDING_REQUEST_NONE) {
+ pending_request_type_(PENDING_REQUEST_NONE),
+ chromoting_hosts_url_(chromoting_hosts_url) {
}
void RegisterHost(const std::string& host_id,
@@ -64,6 +61,7 @@ class ServiceClient::Core
ServiceClient::Delegate* delegate_;
scoped_ptr<net::URLFetcher> request_;
PendingRequestType pending_request_type_;
+ std::string chromoting_hosts_url_;
};
void ServiceClient::Core::RegisterHost(
@@ -102,7 +100,7 @@ void ServiceClient::Core::MakeGaiaRequest(
ServiceClient::Delegate* delegate) {
delegate_ = delegate;
request_.reset(net::URLFetcher::Create(
- 0, GURL(kServiceUrl + url_suffix), request_type, this));
+ 0, GURL(chromoting_hosts_url_ + url_suffix), request_type, this));
request_->SetRequestContext(request_context_getter_);
request_->SetUploadData("application/json; charset=UTF-8", request_body);
request_->AddExtraRequestHeader("Authorization: OAuth " + oauth_access_token);
@@ -140,8 +138,9 @@ void ServiceClient::Core::HandleResponse(const net::URLFetcher* source) {
delegate_->OnNetworkError(source->GetResponseCode());
}
-ServiceClient::ServiceClient(net::URLRequestContextGetter* context_getter) {
- core_ = new Core(context_getter);
+ServiceClient::ServiceClient(const std::string& chromoting_hosts_url,
+ net::URLRequestContextGetter* context_getter) {
+ core_ = new Core(chromoting_hosts_url, context_getter);
}
ServiceClient::~ServiceClient() {
diff --git a/remoting/host/service_client.h b/remoting/host/service_client.h
index cb878d8..9085680 100644
--- a/remoting/host/service_client.h
+++ b/remoting/host/service_client.h
@@ -34,7 +34,8 @@ class ServiceClient {
protected:
virtual ~Delegate() {}
};
- ServiceClient(net::URLRequestContextGetter* context_getter);
+ ServiceClient(const std::string& chromoting_hosts_url,
+ net::URLRequestContextGetter* context_getter);
~ServiceClient();
// Register a host.
diff --git a/remoting/host/service_urls.cc b/remoting/host/service_urls.cc
new file mode 100644
index 0000000..ea1d448
--- /dev/null
+++ b/remoting/host/service_urls.cc
@@ -0,0 +1,86 @@
+// 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.
+
+#include "remoting/host/service_urls.h"
+
+#include "base/command_line.h"
+#include "base/logging.h"
+
+namespace {
+
+// Configurable service data.
+const char kDirectoryBaseUrl[] = "https://www.googleapis.com/chromoting/v1";
+const char kXmppServerAddress[] = "talk.google.com:5222";
+const bool kXmppServerUseTls = true;
+const char kDirectoryBotJid[] = "remoting@bot.talk.google.com";
+
+// Command line switches.
+const char kDirectoryBaseUrlSwitch[] = "directory-base-url";
+const char kXmppServerAddressSwitch[] = "xmpp-server-address";
+const char kXmppServerDisableTlsSwitch[] = "disable-xmpp-server-tls";
+const char kDirectoryBotJidSwitch[] = "directory-bot-jid";
+
+// Non-configurable service paths.
+const char kDirectoryHostsSuffix[] = "/@me/hosts/";
+
+} // namespace
+
+namespace remoting {
+
+ServiceUrls::ServiceUrls()
+ : directory_base_url_(kDirectoryBaseUrl),
+ xmpp_server_address_(kXmppServerAddress),
+ xmpp_server_use_tls_(kXmppServerUseTls),
+ directory_bot_jid_(kDirectoryBotJid) {
+#if !defined(NDEBUG)
+ // Allow debug builds to override urls via command line.
+ CommandLine* command_line = CommandLine::ForCurrentProcess();
+ CHECK(command_line);
+ if (command_line->HasSwitch(kDirectoryBaseUrlSwitch)) {
+ directory_base_url_ = command_line->GetSwitchValueASCII(
+ kDirectoryBaseUrlSwitch);
+ }
+ directory_hosts_url_ = directory_base_url_ + kDirectoryHostsSuffix;
+ if (command_line->HasSwitch(kXmppServerAddressSwitch)) {
+ xmpp_server_address_ = command_line->GetSwitchValueASCII(
+ kXmppServerAddressSwitch);
+ }
+ if (command_line->HasSwitch(kXmppServerDisableTlsSwitch)) {
+ xmpp_server_use_tls_ = false;
+ }
+ if (command_line->HasSwitch(kDirectoryBotJidSwitch)) {
+ directory_bot_jid_ = command_line->GetSwitchValueASCII(
+ kDirectoryBotJidSwitch);
+ }
+#endif // !defined(NDEBUG)
+}
+
+ServiceUrls::~ServiceUrls() {
+}
+
+ServiceUrls* remoting::ServiceUrls::GetInstance() {
+ return Singleton<ServiceUrls>::get();
+}
+
+const std::string& ServiceUrls::directory_base_url() const {
+ return directory_base_url_;
+}
+
+const std::string& ServiceUrls::directory_hosts_url() const {
+ return directory_hosts_url_;
+}
+
+const std::string& ServiceUrls::xmpp_server_address() const {
+ return xmpp_server_address_;
+}
+
+bool ServiceUrls::xmpp_server_use_tls() const {
+ return xmpp_server_use_tls_;
+}
+
+const std::string& ServiceUrls::directory_bot_jid() const {
+ return directory_bot_jid_;
+}
+
+} // namespace remoting
diff --git a/remoting/host/service_urls.h b/remoting/host/service_urls.h
new file mode 100644
index 0000000..ed377a5
--- /dev/null
+++ b/remoting/host/service_urls.h
@@ -0,0 +1,51 @@
+// 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_SERVICE_URLS_H_
+#define REMOTING_HOST_SERVICE_URLS_H_
+
+#include <string>
+
+#include "base/basictypes.h"
+#include "base/memory/singleton.h"
+
+namespace remoting {
+
+// This class contains the URLs to the services used by the host (except for
+// Gaia, which has its own GaiaUrls class. In debug builds, it allows these URLs
+// to be overriden by command line switches, allowing the host process to be
+// pointed at alternate/test servers.
+class ServiceUrls {
+ public:
+ static ServiceUrls* GetInstance();
+
+ // Remoting directory REST API URLs.
+ const std::string& directory_base_url() const;
+ const std::string& directory_hosts_url() const;
+
+ // XMPP Server configuration.
+ const std::string& xmpp_server_address() const;
+ bool xmpp_server_use_tls() const;
+
+ // Remoting directory bot JID (for registering hosts, logging, heartbeats).
+ const std::string& directory_bot_jid() const;
+
+ private:
+ friend struct DefaultSingletonTraits<ServiceUrls>;
+
+ ServiceUrls();
+ virtual ~ServiceUrls();
+
+ std::string directory_base_url_;
+ std::string directory_hosts_url_;
+ std::string xmpp_server_address_;
+ bool xmpp_server_use_tls_;
+ std::string directory_bot_jid_;
+
+ DISALLOW_COPY_AND_ASSIGN(ServiceUrls);
+};
+
+} // namespace remoting
+
+#endif // REMOTING_HOST_SERVICE_URLS_H_
diff --git a/remoting/host/setup/host_starter.cc b/remoting/host/setup/host_starter.cc
index 4021ccb..13cb685 100644
--- a/remoting/host/setup/host_starter.cc
+++ b/remoting/host/setup/host_starter.cc
@@ -34,12 +34,15 @@ HostStarter::~HostStarter() {
}
scoped_ptr<HostStarter> HostStarter::Create(
+ const std::string& oauth2_token_url,
+ const std::string& chromoting_hosts_url,
net::URLRequestContextGetter* url_request_context_getter) {
scoped_ptr<gaia::GaiaOAuthClient> oauth_client(
- new gaia::GaiaOAuthClient(gaia::kGaiaOAuth2Url,
- url_request_context_getter));
+ new gaia::GaiaOAuthClient(
+ oauth2_token_url, url_request_context_getter));
scoped_ptr<remoting::ServiceClient> service_client(
- new remoting::ServiceClient(url_request_context_getter));
+ new remoting::ServiceClient(
+ chromoting_hosts_url, url_request_context_getter));
scoped_ptr<remoting::DaemonController> daemon_controller(
remoting::DaemonController::Create());
return scoped_ptr<HostStarter>(
diff --git a/remoting/host/setup/host_starter.h b/remoting/host/setup/host_starter.h
index b15e874..9d83e4c 100644
--- a/remoting/host/setup/host_starter.h
+++ b/remoting/host/setup/host_starter.h
@@ -33,6 +33,8 @@ class HostStarter : public gaia::GaiaOAuthClient::Delegate,
// Creates a HostStarter.
static scoped_ptr<HostStarter> Create(
+ const std::string& oauth2_token_url,
+ const std::string& chromoting_hosts_url,
net::URLRequestContextGetter* url_request_context_getter);
// Registers a new host with the Chromoting service, and starts it.
diff --git a/remoting/host/setup/start_host.cc b/remoting/host/setup/start_host.cc
index a089942..5257517 100644
--- a/remoting/host/setup/start_host.cc
+++ b/remoting/host/setup/start_host.cc
@@ -10,7 +10,9 @@
#include "base/run_loop.h"
#include "base/stringprintf.h"
#include "base/threading/thread.h"
+#include "google_apis/gaia/gaia_urls.h"
#include "net/url_request/url_request_context_getter.h"
+#include "remoting/host/service_urls.h"
#include "remoting/host/setup/host_starter.h"
#include "remoting/host/setup/oauth_helper.h"
#include "remoting/host/setup/pin_validator.h"
@@ -153,7 +155,10 @@ int main(int argc, char** argv) {
// Start the host.
scoped_ptr<HostStarter> host_starter(
- HostStarter::Create(url_request_context_getter));
+ HostStarter::Create(
+ GaiaUrls::GetInstance()->oauth2_token_url(),
+ remoting::ServiceUrls::GetInstance()->directory_hosts_url(),
+ url_request_context_getter));
if (redirect_url.empty()) {
redirect_url = remoting::GetDefaultOauthRedirectUrl();
}
diff --git a/remoting/host/setup/win/start_host_window.cc b/remoting/host/setup/win/start_host_window.cc
index 0a0bc17..2ae6a2f 100644
--- a/remoting/host/setup/win/start_host_window.cc
+++ b/remoting/host/setup/win/start_host_window.cc
@@ -11,6 +11,8 @@
#include "base/memory/scoped_ptr.h"
#include "base/string16.h"
#include "base/utf_string_conversions.h"
+#include "google_apis/gaia/gaia_urls.h"
+#include "remoting/host/service_urls.h"
#include "remoting/host/setup/oauth_helper.h"
#include "remoting/host/setup/pin_validator.h"
#include "remoting/host/setup/win/load_string_from_resource.h"
@@ -19,7 +21,10 @@ namespace remoting {
StartHostWindow::StartHostWindow(
scoped_refptr<net::URLRequestContextGetter> url_request_context_getter)
- : host_starter_(remoting::HostStarter::Create(url_request_context_getter)),
+ : host_starter_(remoting::HostStarter::Create(
+ GaiaUrls::GetInstance()->oauth2_token_url(),
+ remoting::ServiceUrls::GetInstance()->directory_hosts_url(),
+ url_request_context_getter)),
consent_to_collect_data_(true),
mem_mgr_(GetProcessHeap()),
string_mgr_(&mem_mgr_),
diff --git a/remoting/host/signaling_connector.cc b/remoting/host/signaling_connector.cc
index 97d0eb1..eff6221 100644
--- a/remoting/host/signaling_connector.cc
+++ b/remoting/host/signaling_connector.cc
@@ -6,6 +6,7 @@
#include "base/bind.h"
#include "base/callback.h"
+#include "google_apis/gaia/gaia_urls.h"
#include "google_apis/google_api_keys.h"
#include "net/url_request/url_fetcher.h"
#include "net/url_request/url_request_context_getter.h"
@@ -59,8 +60,9 @@ SignalingConnector::~SignalingConnector() {
void SignalingConnector::EnableOAuth(
scoped_ptr<OAuthCredentials> oauth_credentials) {
oauth_credentials_ = oauth_credentials.Pass();
- gaia_oauth_client_.reset(new gaia::GaiaOAuthClient(
- gaia::kGaiaOAuth2Url, url_request_context_getter_));
+ gaia_oauth_client_.reset(
+ new gaia::GaiaOAuthClient(GaiaUrls::GetInstance()->oauth2_token_url(),
+ url_request_context_getter_));
}
void SignalingConnector::OnSignalStrategyStateChange(
diff --git a/remoting/jingle_glue/xmpp_signal_strategy.cc b/remoting/jingle_glue/xmpp_signal_strategy.cc
index 03adcb8..51bbade 100644
--- a/remoting/jingle_glue/xmpp_signal_strategy.cc
+++ b/remoting/jingle_glue/xmpp_signal_strategy.cc
@@ -38,15 +38,20 @@ XmppSignalStrategy::XmppSignalStrategy(
scoped_refptr<net::URLRequestContextGetter> request_context_getter,
const std::string& username,
const std::string& auth_token,
- const std::string& auth_token_service)
- : request_context_getter_(request_context_getter),
- username_(username),
- auth_token_(auth_token),
- auth_token_service_(auth_token_service),
- resource_name_(kDefaultResourceName),
- xmpp_client_(NULL),
- state_(DISCONNECTED),
- error_(OK) {
+ const std::string& auth_token_service,
+ const XmppSignalStrategy::XmppServerConfig& xmpp_server_config)
+ : request_context_getter_(request_context_getter),
+ username_(username),
+ auth_token_(auth_token),
+ auth_token_service_(auth_token_service),
+ resource_name_(kDefaultResourceName),
+ xmpp_client_(NULL),
+ xmpp_server_config_(xmpp_server_config),
+ state_(DISCONNECTED),
+ error_(OK) {
+#if defined(NDEBUG)
+ CHECK(xmpp_server_config_.use_tls);
+#endif
}
XmppSignalStrategy::~XmppSignalStrategy() {
@@ -70,10 +75,12 @@ void XmppSignalStrategy::Connect() {
settings.set_user(login_jid.node());
settings.set_host(login_jid.domain());
settings.set_resource(resource_name_);
- settings.set_use_tls(buzz::TLS_ENABLED);
settings.set_token_service(auth_token_service_);
settings.set_auth_token(buzz::AUTH_MECHANISM_GOOGLE_TOKEN, auth_token_);
- settings.set_server(talk_base::SocketAddress("talk.google.com", 5222));
+ settings.set_server(talk_base::SocketAddress(
+ xmpp_server_config_.host, xmpp_server_config_.port));
+ settings.set_use_tls(
+ xmpp_server_config_.use_tls ? buzz::TLS_ENABLED : buzz::TLS_DISABLED);
scoped_ptr<jingle_glue::XmppClientSocketFactory> socket_factory(
new jingle_glue::XmppClientSocketFactory(
diff --git a/remoting/jingle_glue/xmpp_signal_strategy.h b/remoting/jingle_glue/xmpp_signal_strategy.h
index e18019e..88dcf5d 100644
--- a/remoting/jingle_glue/xmpp_signal_strategy.h
+++ b/remoting/jingle_glue/xmpp_signal_strategy.h
@@ -38,11 +38,19 @@ class XmppSignalStrategy : public base::NonThreadSafe,
public buzz::XmppStanzaHandler,
public sigslot::has_slots<> {
public:
+ // XMPP Server configuration for XmppSignalStrategy.
+ struct XmppServerConfig {
+ std::string host;
+ int port;
+ bool use_tls;
+ };
+
XmppSignalStrategy(
scoped_refptr<net::URLRequestContextGetter> request_context_getter,
const std::string& username,
const std::string& auth_token,
- const std::string& auth_token_service);
+ const std::string& auth_token_service,
+ const XmppServerConfig& xmpp_server_config);
virtual ~XmppSignalStrategy();
// SignalStrategy interface.
@@ -86,6 +94,7 @@ class XmppSignalStrategy : public base::NonThreadSafe,
std::string resource_name_;
scoped_ptr<talk_base::TaskRunner> task_runner_;
buzz::XmppClient* xmpp_client_;
+ XmppServerConfig xmpp_server_config_;
State state_;
Error error_;
diff --git a/remoting/remoting.gyp b/remoting/remoting.gyp
index b5b817c..2e52e44 100644
--- a/remoting/remoting.gyp
+++ b/remoting/remoting.gyp
@@ -392,6 +392,8 @@
'host/server_log_entry.h',
'host/service_client.cc',
'host/service_client.h',
+ 'host/service_urls.cc',
+ 'host/service_urls.h',
'host/session_manager_factory.cc',
'host/session_manager_factory.h',
'host/signaling_connector.cc',
diff --git a/remoting/webapp/build-webapp.py b/remoting/webapp/build-webapp.py
index 966ddb5..a59177f 100755
--- a/remoting/webapp/build-webapp.py
+++ b/remoting/webapp/build-webapp.py
@@ -55,6 +55,14 @@ def createZip(zip_path, directory):
zip.close()
+def replaceUrl(destination, url_name, url_value):
+ """Updates a URL in both plugin_settings.json and manifest.js."""
+ findAndReplace(os.path.join(destination, 'plugin_settings.js'),
+ "'" + url_name + "'", "'" + url_value + "'")
+ findAndReplace(os.path.join(destination, 'manifest.json'),
+ url_name, url_value)
+
+
def buildWebApp(buildtype, version, mimetype, destination, zip_path, plugin,
files, locales, patches):
"""Does the main work of building the webapp directory and zipfile.
@@ -183,26 +191,82 @@ def buildWebApp(buildtype, version, mimetype, destination, zip_path, plugin,
'HOST_PLUGIN_MIMETYPE',
mimetype)
+ # Allow host names for google services/apis to be overriden via env vars.
+ oauth2AccountsHost = os.environ.get(
+ 'OAUTH2_ACCOUNTS_HOST', 'https://accounts.google.com')
+ oauth2ApiHost = os.environ.get(
+ 'OAUTH2_API_HOST', 'https://www.googleapis.com')
+ directoryApiHost = os.environ.get(
+ 'DIRECTORY_API_HOST', 'https://www.googleapis.com')
+ oauth2BaseUrl = oauth2AccountsHost + '/o/oauth2'
+ oauth2ApiBaseUrl = oauth2ApiHost + '/oauth2'
+ directoryApiBaseUrl = directoryApiHost + '/chromoting/v1'
+ replaceUrl(destination, 'OAUTH2_BASE_URL', oauth2BaseUrl)
+ replaceUrl(destination, 'OAUTH2_API_BASE_URL', oauth2ApiBaseUrl)
+ replaceUrl(destination, 'DIRECTORY_API_BASE_URL', directoryApiBaseUrl)
+ # Substitute hosts in the manifest's CSP list.
+ findAndReplace(os.path.join(destination, 'manifest.json'),
+ 'OAUTH2_ACCOUNTS_HOST', oauth2AccountsHost)
+ # Ensure we list the API host only once if it's the same for multiple APIs.
+ googleApiHosts = ' '.join(set([oauth2ApiHost, directoryApiHost]))
+ findAndReplace(os.path.join(destination, 'manifest.json'),
+ 'GOOGLE_API_HOSTS', googleApiHosts)
+
+ # WCS and the OAuth trampoline are both hosted on talkgadget. Split them into
+ # separate suffix/prefix variables to allow for wildcards in manifest.json.
+ talkGadgetHostSuffix = os.environ.get(
+ 'TALK_GADGET_HOST_SUFFIX', 'talkgadget.google.com')
+ talkGadgetHostPrefix = os.environ.get(
+ 'TALK_GADGET_HOST_PREFIX', 'https://chromoting-client.')
+ oauth2RedirectHostPrefix = os.environ.get(
+ 'OAUTH2_REDIRECT_HOST_PREFIX', 'https://chromoting-oauth.')
+
+ # Use a wildcard in the manifest.json host specs if the prefixes differ.
+ talkGadgetHostJs = talkGadgetHostPrefix + talkGadgetHostSuffix
+ talkGadgetBaseUrl = talkGadgetHostJs + '/talkgadget/'
+ if talkGadgetHostPrefix == oauth2RedirectHostPrefix:
+ talkGadgetHostJson = talkGadgetHostJs
+ else:
+ talkGadgetHostJson = 'https://*.' + talkGadgetHostSuffix
+
# Set the correct OAuth2 redirect URL.
- scheme = 'https://'
- urlSuffix = '.talkgadget.google.com/talkgadget/oauth/chrome-remote-desktop'
- url = scheme + 'chromoting-oauth' + urlSuffix
- urlPattern = scheme + '*' + urlSuffix
- if (buildtype == 'Official'):
- oauth2RedirectUrlJs = (
- "'" + url + "/rel/' + chrome.i18n.getMessage('@@extension_id')")
- oauth2RedirectUrlJson = urlPattern + '/rel/*'
+ oauth2RedirectHostJs = oauth2RedirectHostPrefix + talkGadgetHostSuffix
+ oauth2RedirectHostJson = talkGadgetHostJson
+ oauth2RedirectPath = '/talkgadget/oauth/chrome-remote-desktop'
+ oauth2RedirectBaseUrlJs = oauth2RedirectHostJs + oauth2RedirectPath
+ oauth2RedirectBaseUrlJson = oauth2RedirectHostJson + oauth2RedirectPath
+ if buildtype == 'Official':
+ oauth2RedirectUrlJs = ("'" + oauth2RedirectBaseUrlJs +
+ "/rel/' + chrome.i18n.getMessage('@@extension_id')")
+ oauth2RedirectUrlJson = oauth2RedirectBaseUrlJson + '/rel/*'
else:
- oauth2RedirectUrlJs = "'" + url + "/dev'"
- oauth2RedirectUrlJson = urlPattern + '/dev*'
+ oauth2RedirectUrlJs = "'" + oauth2RedirectBaseUrlJs + "/dev'"
+ oauth2RedirectUrlJson = oauth2RedirectBaseUrlJson + '/dev*'
findAndReplace(os.path.join(destination, 'plugin_settings.js'),
- "'OAUTH2_REDIRECT_URL'",
- oauth2RedirectUrlJs)
+ "'TALK_GADGET_URL'", "'" + talkGadgetBaseUrl + "'")
+ findAndReplace(os.path.join(destination, 'plugin_settings.js'),
+ "'OAUTH2_REDIRECT_URL'", oauth2RedirectUrlJs)
+ findAndReplace(os.path.join(destination, 'manifest.json'),
+ 'TALK_GADGET_HOST', talkGadgetHostJson)
findAndReplace(os.path.join(destination, 'manifest.json'),
- "OAUTH2_REDIRECT_URL",
- oauth2RedirectUrlJson)
+ 'OAUTH2_REDIRECT_URL', oauth2RedirectUrlJson)
+
+ # Configure xmpp server and directory bot settings in the plugin.
+ xmppServerAddress = os.environ.get(
+ 'XMPP_SERVER_ADDRESS', 'talk.google.com:5222')
+ xmppServerUseTls = os.environ.get('XMPP_SERVER_USE_TLS', 'true')
+ directoryBotJid = os.environ.get(
+ 'DIRECTORY_BOT_JID', 'remoting@bot.talk.google.com')
+
+ findAndReplace(os.path.join(destination, 'plugin_settings.js'),
+ "'XMPP_SERVER_ADDRESS'", "'" + xmppServerAddress + "'")
+ findAndReplace(os.path.join(destination, 'plugin_settings.js'),
+ "Boolean('XMPP_SERVER_USE_TLS')", xmppServerUseTls)
+ findAndReplace(os.path.join(destination, 'plugin_settings.js'),
+ "'DIRECTORY_BOT_JID'", "'" + directoryBotJid + "'")
# Set the correct API keys.
+ # For overriding the client ID/secret via env vars, see google_api_keys.py.
apiClientId = google_api_keys.GetClientID('REMOTING')
apiClientSecret = google_api_keys.GetClientSecret('REMOTING')
diff --git a/remoting/webapp/client_screen.js b/remoting/webapp/client_screen.js
index 97bf94e..e9fd315 100644
--- a/remoting/webapp/client_screen.js
+++ b/remoting/webapp/client_screen.js
@@ -437,7 +437,7 @@ function resolveSupportId(clientJid, supportId, token) {
};
remoting.supportHostsXhr_ = remoting.xhr.get(
- 'https://www.googleapis.com/chromoting/v1/support-hosts/' +
+ remoting.settings.DIRECTORY_API_BASE_URL + '/support-hosts/' +
encodeURIComponent(supportId),
parseServerResponse_.bind(null, clientJid),
'',
diff --git a/remoting/webapp/format_iq.js b/remoting/webapp/format_iq.js
index 8690718..6fb8e55 100644
--- a/remoting/webapp/format_iq.js
+++ b/remoting/webapp/format_iq.js
@@ -21,13 +21,6 @@ remoting.FormatIq = function() {
};
/**
- * JID for the remoting bot which is used to bridge communication between
- * the Talk network and the Remoting directory service.
- */
-remoting.FormatIq.prototype.REMOTING_DIRECTORY_SERVICE_BOT =
- 'remoting@bot.talk.google.com';
-
-/**
* Verify that the only attributes on the given |node| are those specified
* in the |attrs| string.
*
@@ -628,7 +621,7 @@ remoting.FormatIq.prototype.prettyIq = function(send, message) {
var to = iq.getAttribute('to');
var from = iq.getAttribute('from');
var action = '';
- var bot = remoting.FormatIq.prototype.REMOTING_DIRECTORY_SERVICE_BOT;
+ var bot = remoting.settings.DIRECTORY_BOT_JID;
if (send) {
if (to && to != this.hostJid && to != bot) {
console.warn('FormatIq: bad to: ' + to);
diff --git a/remoting/webapp/host_controller.js b/remoting/webapp/host_controller.js
index 5f04bce..4612ee6 100644
--- a/remoting/webapp/host_controller.js
+++ b/remoting/webapp/host_controller.js
@@ -180,7 +180,7 @@ remoting.HostController.prototype.start = function(hostPin, consent, callback) {
publicKey: publicKey
} };
remoting.xhr.post(
- 'https://www.googleapis.com/chromoting/v1/@me/hosts/',
+ remoting.settings.DIRECTORY_API_BASE_URL + '/@me/hosts/',
/** @param {XMLHttpRequest} xhr */
function (xhr) { onRegistered(publicKey, privateKey, xhr); },
JSON.stringify(newHostDetails),
diff --git a/remoting/webapp/host_list.js b/remoting/webapp/host_list.js
index 4c4c065..3f38363 100644
--- a/remoting/webapp/host_list.js
+++ b/remoting/webapp/host_list.js
@@ -133,7 +133,7 @@ remoting.HostList.prototype.refresh = function(onDone) {
var getHosts = function(token) {
var headers = { 'Authorization': 'OAuth ' + token };
remoting.xhr.get(
- 'https://www.googleapis.com/chromoting/v1/@me/hosts',
+ remoting.settings.DIRECTORY_API_BASE_URL + '/@me/hosts',
parseHostListResponse, '', headers);
};
/** @param {remoting.Error} error */
@@ -303,7 +303,7 @@ remoting.HostList.prototype.renameHost_ = function(hostTableEntry) {
publicKey: hostTableEntry.host.publicKey
} };
remoting.xhr.put(
- 'https://www.googleapis.com/chromoting/v1/@me/hosts/' +
+ remoting.settings.DIRECTORY_API_BASE_URL + '/@me/hosts/' +
hostTableEntry.host.hostId,
function(xhr) {},
JSON.stringify(newHostDetails),
@@ -325,7 +325,7 @@ remoting.HostList.unregisterHostById = function(hostId) {
var deleteHost = function(token) {
var headers = { 'Authorization': 'OAuth ' + token };
remoting.xhr.remove(
- 'https://www.googleapis.com/chromoting/v1/@me/hosts/' + hostId,
+ remoting.settings.DIRECTORY_API_BASE_URL + '/@me/hosts/' + hostId,
function() {}, '', headers);
}
remoting.identity.callWithToken(deleteHost, remoting.showErrorMessage);
diff --git a/remoting/webapp/host_plugin_proto.js b/remoting/webapp/host_plugin_proto.js
index f845965..fd4255e 100644
--- a/remoting/webapp/host_plugin_proto.js
+++ b/remoting/webapp/host_plugin_proto.js
@@ -100,3 +100,7 @@ remoting.HostPlugin.prototype.daemonState;
/** @type {function(boolean):void} */
remoting.HostPlugin.prototype.onNatTraversalPolicyChanged;
+
+/** @type {string} */ remoting.HostPlugin.prototype.xmppServerAddress;
+/** @type {boolean} */ remoting.HostPlugin.prototype.xmppServerUseTls;
+/** @type {string} */ remoting.HostPlugin.prototype.directoryBotJid; \ No newline at end of file
diff --git a/remoting/webapp/host_session.js b/remoting/webapp/host_session.js
index 8c25a8f0..72007a3 100644
--- a/remoting/webapp/host_session.js
+++ b/remoting/webapp/host_session.js
@@ -46,7 +46,7 @@ remoting.HostSession.State = {
*/
remoting.HostSession.createPlugin = function() {
var plugin = document.createElement('embed');
- plugin.type = remoting.PLUGIN_MIMETYPE;
+ plugin.type = remoting.settings.PLUGIN_MIMETYPE;
// Hiding the plugin means it doesn't load, so make it size zero instead.
plugin.width = 0;
plugin.height = 0;
@@ -74,6 +74,9 @@ remoting.HostSession.prototype.createPluginAndConnect =
this.plugin.onStateChanged = onStateChanged;
this.plugin.logDebugInfo = logDebugInfo;
this.plugin.localize(chrome.i18n.getMessage);
+ this.plugin.xmppServerAddress = remoting.settings.XMPP_SERVER_ADDRESS;
+ this.plugin.xmppServerUseTls = remoting.settings.XMPP_SERVER_USE_TLS;
+ this.plugin.directoryBotJid = remoting.settings.DIRECTORY_BOT_JID;
this.plugin.connect(email, 'oauth2:' + accessToken);
};
diff --git a/remoting/webapp/log_to_server.js b/remoting/webapp/log_to_server.js
index ff104d3..85e2c90 100644
--- a/remoting/webapp/log_to_server.js
+++ b/remoting/webapp/log_to_server.js
@@ -167,7 +167,8 @@ remoting.LogToServer.prototype.log = function(entry) {
console.log('Sending ' + this.pendingEntries.length + ' log ' +
((this.pendingEntries.length == 1) ? 'entry' : 'entries') +
' to the server.');
- var stanza = '<cli:iq to="remoting@bot.talk.google.com" type="set" ' +
+ var stanza = '<cli:iq to="' +
+ remoting.settings.DIRECTORY_BOT_JID + '" type="set" ' +
'xmlns:cli="jabber:client"><gr:log xmlns:gr="google:remoting">';
while (this.pendingEntries.length > 0) {
stanza += /** @type string */ this.pendingEntries.shift();
diff --git a/remoting/webapp/manifest.json b/remoting/webapp/manifest.json
index a52b1da..0ed8b52 100644
--- a/remoting/webapp/manifest.json
+++ b/remoting/webapp/manifest.json
@@ -22,11 +22,12 @@
"js": [ "cs_oauth2_trampoline.js" ]
}
],
- "content_security_policy": "default-src 'self'; script-src 'self' https://*.talkgadget.google.com; style-src 'self' https://fonts.googleapis.com; img-src 'self' https://*.talkgadget.google.com; font-src *; connect-src 'self' https://accounts.google.com https://www.googleapis.com https://*.talkgadget.google.com https://relay.google.com",
+ "content_security_policy": "default-src 'self'; script-src 'self' TALK_GADGET_HOST; style-src 'self' https://fonts.googleapis.com; img-src 'self' TALK_GADGET_HOST; font-src *; connect-src 'self' OAUTH2_ACCOUNTS_HOST GOOGLE_API_HOSTS TALK_GADGET_HOST https://relay.google.com",
"permissions": [
- "https://accounts.google.com/*",
- "https://www.googleapis.com/chromoting/*",
- "https://*.talkgadget.google.com/talkgadget/*",
+ "OAUTH2_ACCOUNTS_HOST/*",
+ "OAUTH2_API_BASE_URL/*",
+ "DIRECTORY_API_BASE_URL/*",
+ "TALK_GADGET_HOST/talkgadget/*",
"https://relay.google.com/*",
"clipboardRead",
"clipboardWrite"
diff --git a/remoting/webapp/oauth2.js b/remoting/webapp/oauth2.js
index f6594cf..752c880 100644
--- a/remoting/webapp/oauth2.js
+++ b/remoting/webapp/oauth2.js
@@ -46,12 +46,56 @@ remoting.OAuth2.prototype.SCOPE_ =
'https://www.googleapis.com/auth/chromoting ' +
'https://www.googleapis.com/auth/googletalk ' +
'https://www.googleapis.com/auth/userinfo#email';
-/** @private */
-remoting.OAuth2.prototype.OAUTH2_TOKEN_ENDPOINT_ =
- 'https://accounts.google.com/o/oauth2/token';
-/** @private */
-remoting.OAuth2.prototype.OAUTH2_REVOKE_TOKEN_ENDPOINT_ =
- 'https://accounts.google.com/o/oauth2/revoke';
+
+// Configurable URLs/strings.
+/** @private
+ * @return {string} OAuth2 redirect URI.
+ */
+remoting.OAuth2.prototype.getRedirectUri_ = function() {
+ return remoting.settings.OAUTH2_REDIRECT_URL;
+};
+
+/** @private
+ * @return {string} API client ID.
+ */
+remoting.OAuth2.prototype.getClientId_ = function() {
+ return remoting.settings.OAUTH2_CLIENT_ID;
+};
+
+/** @private
+ * @return {string} API client secret.
+ */
+remoting.OAuth2.prototype.getClientSecret_ = function() {
+ return remoting.settings.OAUTH2_CLIENT_SECRET;
+};
+
+/** @private
+ * @return {string} OAuth2 authentication URL.
+ */
+remoting.OAuth2.prototype.getOAuth2AuthEndpoint_ = function() {
+ return remoting.settings.OAUTH2_BASE_URL + '/auth';
+};
+
+/** @private
+ * @return {string} OAuth2 token URL.
+ */
+remoting.OAuth2.prototype.getOAuth2TokenEndpoint_ = function() {
+ return remoting.settings.OAUTH2_BASE_URL + '/token';
+};
+
+/** @private
+ * @return {string} OAuth token revocation URL.
+ */
+remoting.OAuth2.prototype.getOAuth2RevokeTokenEndpoint_ = function() {
+ return remoting.settings.OAUTH2_BASE_URL + '/revoke';
+};
+
+/** @private
+ * @return {string} OAuth2 userinfo API URL.
+ */
+remoting.OAuth2.prototype.getOAuth2ApiUserInfoEndpoint_ = function() {
+ return remoting.settings.OAUTH2_API_BASE_URL + '/v1/userinfo';
+};
/** @return {boolean} True if the app is already authenticated. */
remoting.OAuth2.prototype.isAuthenticated = function() {
@@ -252,13 +296,13 @@ remoting.OAuth2.prototype.refreshAccessToken_ = function(onDone) {
}
var parameters = {
- 'client_id': this.CLIENT_ID_,
- 'client_secret': this.CLIENT_SECRET_,
+ 'client_id': this.getClientId_(),
+ 'client_secret': this.getClientSecret_(),
'refresh_token': this.getRefreshToken_(),
'grant_type': 'refresh_token'
};
- remoting.xhr.post(this.OAUTH2_TOKEN_ENDPOINT_,
+ remoting.xhr.post(this.getOAuth2TokenEndpoint_(),
this.processTokenResponse_.bind(this, onDone),
parameters);
};
@@ -281,10 +325,10 @@ remoting.OAuth2.prototype.generateXsrfToken_ = function() {
remoting.OAuth2.prototype.doAuthRedirect = function() {
var xsrf_token = this.generateXsrfToken_();
window.localStorage.setItem(this.KEY_XSRF_TOKEN_, xsrf_token);
- var GET_CODE_URL = 'https://accounts.google.com/o/oauth2/auth?' +
+ var GET_CODE_URL = this.getOAuth2AuthEndpoint_() + '?' +
remoting.xhr.urlencodeParamHash({
- 'client_id': this.CLIENT_ID_,
- 'redirect_uri': this.REDIRECT_URI_,
+ 'client_id': this.getClientId_(),
+ 'redirect_uri': this.getRedirectUri_(),
'scope': this.SCOPE_,
'state': xsrf_token,
'response_type': 'code',
@@ -311,13 +355,13 @@ remoting.OAuth2.prototype.exchangeCodeForToken = function(code, state, onDone) {
onDone(null);
}
var parameters = {
- 'client_id': this.CLIENT_ID_,
- 'client_secret': this.CLIENT_SECRET_,
- 'redirect_uri': this.REDIRECT_URI_,
+ 'client_id': this.getClientId_(),
+ 'client_secret': this.getClientSecret_(),
+ 'redirect_uri': this.getRedirectUri_(),
'code': code,
'grant_type': 'authorization_code'
};
- remoting.xhr.post(this.OAUTH2_TOKEN_ENDPOINT_,
+ remoting.xhr.post(this.getOAuth2TokenEndpoint_(),
this.processTokenResponse_.bind(this, onDone),
parameters);
};
@@ -365,7 +409,7 @@ remoting.OAuth2.prototype.revokeToken_ = function(token) {
' ; response: ' + xhr.responseText + ' ; xhr: ', xhr);
}
};
- remoting.xhr.post(this.OAUTH2_REVOKE_TOKEN_ENDPOINT_,
+ remoting.xhr.post(this.getOAuth2RevokeTokenEndpoint_(),
processResponse,
parameters);
};
@@ -466,7 +510,7 @@ remoting.OAuth2.prototype.getEmail = function(onOk, onError) {
/** @param {string} token The access token. */
var getEmailFromToken = function(token) {
var headers = { 'Authorization': 'OAuth ' + token };
- remoting.xhr.get('https://www.googleapis.com/oauth2/v1/userinfo',
+ remoting.xhr.get(that.getOAuth2ApiUserInfoEndpoint_(),
onResponse, '', headers);
};
diff --git a/remoting/webapp/oauth2_callback.js b/remoting/webapp/oauth2_callback.js
index 6d94dca..3517935 100644
--- a/remoting/webapp/oauth2_callback.js
+++ b/remoting/webapp/oauth2_callback.js
@@ -13,6 +13,8 @@
'use strict';
+var remoting = remoting || {};
+
function retrieveRefreshToken() {
var query = window.location.search.substring(1);
var parts = query.split('&');
@@ -23,6 +25,7 @@ function retrieveRefreshToken() {
}
if ('code' in queryArgs && 'state' in queryArgs) {
+ remoting.settings = new remoting.Settings();
var oauth2 = new remoting.OAuth2();
oauth2.exchangeCodeForToken(queryArgs['code'], queryArgs['state'],
function() {
diff --git a/remoting/webapp/plugin_settings.js b/remoting/webapp/plugin_settings.js
index d3fde9a..8ca53be 100644
--- a/remoting/webapp/plugin_settings.js
+++ b/remoting/webapp/plugin_settings.js
@@ -6,22 +6,43 @@
// Keeping all that centralized here allows us to use symlinks for the other
// files making for a faster compile/run cycle when only modifying HTML/JS.
+'use strict';
+
/** @suppress {duplicate} */
var remoting = remoting || {};
-/**
- * @type {string} The MIME type of the Host plugin.
- */
-remoting.PLUGIN_MIMETYPE = 'HOST_PLUGIN_MIMETYPE';
-
-/**
- * @type {string} The OAuth2 redirect URL.
- * @private
- */
-remoting.OAuth2.prototype.REDIRECT_URI_ = 'OAUTH2_REDIRECT_URL';
-
-// Constants for parameters used in retrieving the OAuth2 credentials.
-/** @private */
-remoting.OAuth2.prototype.CLIENT_ID_ = 'API_CLIENT_ID';
-/** @private */
-remoting.OAuth2.prototype.CLIENT_SECRET_ = 'API_CLIENT_SECRET';
+/** @type {remoting.Settings} */
+remoting.settings = null;
+/** @constructor */
+remoting.Settings = function() {};
+
+// The settings on this file are automatically substituted by build-webapp.py.
+// Do not override them manually, except for running local tests.
+
+/** @type {string} MIME type for the host plugin.*/
+remoting.Settings.prototype.PLUGIN_MIMETYPE = 'HOST_PLUGIN_MIMETYPE';
+/** @type {string} API client ID.*/
+remoting.Settings.prototype.OAUTH2_CLIENT_ID = 'API_CLIENT_ID';
+/** @type {string} API client secret.*/
+remoting.Settings.prototype.OAUTH2_CLIENT_SECRET = 'API_CLIENT_SECRET';
+
+/** @type {string} Base URL for OAuth2 authentication. */
+remoting.Settings.prototype.OAUTH2_BASE_URL = 'OAUTH2_BASE_URL';
+/** @type {string} Base URL for the OAuth2 API. */
+remoting.Settings.prototype.OAUTH2_API_BASE_URL = 'OAUTH2_API_BASE_URL';
+/** @type {string} Base URL for the Remoting Directory REST API. */
+remoting.Settings.prototype.DIRECTORY_API_BASE_URL = 'DIRECTORY_API_BASE_URL';
+/** @type {string} URL for the talk gadget web service. */
+remoting.Settings.prototype.TALK_GADGET_URL = 'TALK_GADGET_URL';
+/** @type {string} OAuth2 redirect URI. */
+remoting.Settings.prototype.OAUTH2_REDIRECT_URL = 'OAUTH2_REDIRECT_URL';
+
+/** @type {string} XMPP JID for the remoting directory server bot. */
+remoting.Settings.prototype.DIRECTORY_BOT_JID = 'DIRECTORY_BOT_JID';
+
+// XMPP server connection settings.
+/** @type {string} XMPP server host name (or IP address) and port. */
+remoting.Settings.prototype.XMPP_SERVER_ADDRESS = 'XMPP_SERVER_ADDRESS';
+/** @type {boolean} Whether to use TLS on connections to the XMPP server. */
+remoting.Settings.prototype.XMPP_SERVER_USE_TLS =
+ Boolean('XMPP_SERVER_USE_TLS');
diff --git a/remoting/webapp/remoting.js b/remoting/webapp/remoting.js
index f5d1fe1..8ffc477 100644
--- a/remoting/webapp/remoting.js
+++ b/remoting/webapp/remoting.js
@@ -41,6 +41,7 @@ remoting.init = function() {
remoting.logExtensionInfoAsync_();
l10n.localize();
// Create global objects.
+ remoting.settings = new remoting.Settings();
remoting.oauth2 = new remoting.OAuth2();
// TODO(jamiewalch): Reinstate this when we migrate to apps v2
// (http://crbug.com/ 134213).
diff --git a/remoting/webapp/wcs_loader.js b/remoting/webapp/wcs_loader.js
index 8befcc4..3ab10bf 100644
--- a/remoting/webapp/wcs_loader.js
+++ b/remoting/webapp/wcs_loader.js
@@ -30,14 +30,6 @@ remoting.WcsLoader = function() {
};
/**
- * The URL of the GTalk gadget.
- * @type {string}
- * @private
- */
-remoting.WcsLoader.prototype.TALK_GADGET_URL_ =
- 'https://chromoting-client.talkgadget.google.com/talkgadget/';
-
-/**
* The id of the script node.
* @type {string}
* @private
@@ -69,7 +61,7 @@ remoting.WcsLoader.prototype.start = function(token, onReady, onError) {
// Create a script node to load the WCS driver.
node = document.createElement('script');
node.id = this.SCRIPT_NODE_ID_;
- node.src = this.TALK_GADGET_URL_ + 'iq?access_token=' + token;
+ node.src = remoting.settings.TALK_GADGET_URL + 'iq?access_token=' + token;
node.type = 'text/javascript';
document.body.insertBefore(node, document.body.firstChild);
@@ -114,10 +106,6 @@ remoting.WcsLoader.prototype.constructWcs_ = function(token, onReady) {
remoting.wcsLoader.wcsIqClient, token, onReady);
};
-/** @private */
-remoting.WcsLoader.prototype.OAUTH2_VALIDATE_TOKEN_ENDPOINT_ =
- 'https://www.googleapis.com/oauth2/v1/tokeninfo';
-
/**
* Validates an OAuth2 access token.
*
@@ -151,6 +139,8 @@ remoting.WcsLoader.prototype.validateToken = function(token, onOk, onError) {
}
};
var parameters = '?access_token=' + encodeURIComponent(token);
- xhr.open('GET', this.OAUTH2_VALIDATE_TOKEN_ENDPOINT_ + parameters, true);
+ xhr.open('GET',
+ remoting.settings.OAUTH2_API_BASE_URL + '/v1/tokeninfo' + parameters,
+ true);
xhr.send(null);
};
diff --git a/remoting/webapp/wcs_sandbox.html b/remoting/webapp/wcs_sandbox.html
index a84ef17..b768d05 100644
--- a/remoting/webapp/wcs_sandbox.html
+++ b/remoting/webapp/wcs_sandbox.html
@@ -9,6 +9,7 @@ found in the LICENSE file.
<head>
<meta charset="utf-8">
<script src="error.js"></script>
+ <script src="plugin_settings.js"></script>
<script src="xhr_proxy.js"></script>
<script src="wcs.js"></script>
<script src="wcs_loader.js"></script>
diff --git a/remoting/webapp/wcs_sandbox_content.js b/remoting/webapp/wcs_sandbox_content.js
index c297900..b97f6a4 100644
--- a/remoting/webapp/wcs_sandbox_content.js
+++ b/remoting/webapp/wcs_sandbox_content.js
@@ -213,6 +213,7 @@ function onSandboxInit() {
oldAEL(type, listener, useCapture);
};
+ remoting.settings = new remoting.Settings();
remoting.sandboxContent = new remoting.WcsSandboxContent();
}