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 bool kXmppServerUseTls
= true;
14 const char kDirectoryBotJid
[] = "remoting@bot.talk.google.com";
16 // Command line switches.
18 const char kDirectoryBaseUrlSwitch
[] = "directory-base-url";
19 const char kXmppServerAddressSwitch
[] = "xmpp-server-address";
20 const char kXmppServerDisableTlsSwitch
[] = "disable-xmpp-server-tls";
21 const char kDirectoryBotJidSwitch
[] = "directory-bot-jid";
22 #endif // !defined(NDEBUG)
24 // Non-configurable service paths.
25 const char kDirectoryHostsSuffix
[] = "/@me/hosts/";
29 ServiceUrls::ServiceUrls()
30 : directory_base_url_(kDirectoryBaseUrl
),
31 xmpp_server_address_(kXmppServerAddress
),
32 xmpp_server_use_tls_(kXmppServerUseTls
),
33 directory_bot_jid_(kDirectoryBotJid
) {
35 // Allow debug builds to override urls via command line.
36 base::CommandLine
* command_line
= base::CommandLine::ForCurrentProcess();
38 if (command_line
->HasSwitch(kDirectoryBaseUrlSwitch
)) {
39 directory_base_url_
= command_line
->GetSwitchValueASCII(
40 kDirectoryBaseUrlSwitch
);
42 if (command_line
->HasSwitch(kXmppServerAddressSwitch
)) {
43 xmpp_server_address_
= command_line
->GetSwitchValueASCII(
44 kXmppServerAddressSwitch
);
46 if (command_line
->HasSwitch(kXmppServerDisableTlsSwitch
)) {
47 xmpp_server_use_tls_
= false;
49 if (command_line
->HasSwitch(kDirectoryBotJidSwitch
)) {
50 directory_bot_jid_
= command_line
->GetSwitchValueASCII(
51 kDirectoryBotJidSwitch
);
53 #endif // !defined(NDEBUG)
55 directory_hosts_url_
= directory_base_url_
+ kDirectoryHostsSuffix
;
58 ServiceUrls::~ServiceUrls() {
61 ServiceUrls
* remoting::ServiceUrls::GetInstance() {
62 return Singleton
<ServiceUrls
>::get();
65 const std::string
& ServiceUrls::directory_base_url() const {
66 return directory_base_url_
;
69 const std::string
& ServiceUrls::directory_hosts_url() const {
70 return directory_hosts_url_
;
73 const std::string
& ServiceUrls::xmpp_server_address() const {
74 return xmpp_server_address_
;
77 bool ServiceUrls::xmpp_server_use_tls() const {
78 return xmpp_server_use_tls_
;
81 const std::string
& ServiceUrls::directory_bot_jid() const {
82 return directory_bot_jid_
;
85 } // namespace remoting