1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "remoting/base/service_urls.h"
7 #include "base/command_line.h"
8 #include "base/logging.h"
10 // Configurable service data.
11 const char kDirectoryBaseUrl
[] = "https://www.googleapis.com/chromoting/v1";
12 const char kXmppServerAddress
[] = "talk.google.com:443";
13 const char kXmppServerAddressForMe2MeHost
[] = "talk.google.com:5222";
14 const bool kXmppServerUseTls
= true;
15 const char kDirectoryBotJid
[] = "remoting@bot.talk.google.com";
17 // Command line switches.
19 const char kDirectoryBaseUrlSwitch
[] = "directory-base-url";
20 const char kXmppServerAddressSwitch
[] = "xmpp-server-address";
21 const char kXmppServerDisableTlsSwitch
[] = "disable-xmpp-server-tls";
22 const char kDirectoryBotJidSwitch
[] = "directory-bot-jid";
23 #endif // !defined(NDEBUG)
25 // Non-configurable service paths.
26 const char kDirectoryHostsSuffix
[] = "/@me/hosts/";
30 ServiceUrls::ServiceUrls()
31 : directory_base_url_(kDirectoryBaseUrl
),
32 xmpp_server_address_(kXmppServerAddress
),
33 xmpp_server_address_for_me2me_host_(kXmppServerAddressForMe2MeHost
),
34 xmpp_server_use_tls_(kXmppServerUseTls
),
35 directory_bot_jid_(kDirectoryBotJid
) {
37 // Allow debug builds to override urls via command line.
38 base::CommandLine
* command_line
= base::CommandLine::ForCurrentProcess();
40 if (command_line
->HasSwitch(kDirectoryBaseUrlSwitch
)) {
41 directory_base_url_
= command_line
->GetSwitchValueASCII(
42 kDirectoryBaseUrlSwitch
);
44 if (command_line
->HasSwitch(kXmppServerAddressSwitch
)) {
45 xmpp_server_address_
= command_line
->GetSwitchValueASCII(
46 kXmppServerAddressSwitch
);
47 xmpp_server_address_for_me2me_host_
= xmpp_server_address_
;
49 if (command_line
->HasSwitch(kXmppServerDisableTlsSwitch
)) {
50 xmpp_server_use_tls_
= false;
52 if (command_line
->HasSwitch(kDirectoryBotJidSwitch
)) {
53 directory_bot_jid_
= command_line
->GetSwitchValueASCII(
54 kDirectoryBotJidSwitch
);
56 #endif // !defined(NDEBUG)
58 directory_hosts_url_
= directory_base_url_
+ kDirectoryHostsSuffix
;
61 ServiceUrls::~ServiceUrls() {
64 ServiceUrls
* remoting::ServiceUrls::GetInstance() {
65 return Singleton
<ServiceUrls
>::get();
68 const std::string
& ServiceUrls::directory_base_url() const {
69 return directory_base_url_
;
72 const std::string
& ServiceUrls::directory_hosts_url() const {
73 return directory_hosts_url_
;
76 const std::string
& ServiceUrls::xmpp_server_address() const {
77 return xmpp_server_address_
;
80 const std::string
& ServiceUrls::xmpp_server_address_for_me2me_host() const {
81 return xmpp_server_address_for_me2me_host_
;
84 bool ServiceUrls::xmpp_server_use_tls() const {
85 return xmpp_server_use_tls_
;
88 const std::string
& ServiceUrls::directory_bot_jid() const {
89 return directory_bot_jid_
;
92 } // namespace remoting