Upstreaming browser/ui/uikit_ui_util from iOS.
[chromium-blink-merge.git] / remoting / base / service_urls.cc
blobbd3485c3eee6854307c7c0d5f5539bb4682a2064
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 kGcdBaseUrl[] = "https://www.googleapis.com/clouddevices/v1";
13 const char kXmppServerAddress[] = "talk.google.com:443";
14 const char kXmppServerAddressForMe2MeHost[] = "talk.google.com:5222";
15 const bool kXmppServerUseTls = true;
16 const char kDirectoryBotJid[] = "remoting@bot.talk.google.com";
17 const char kGcdJid[] = "clouddevices.gserviceaccount.com";
19 // Command line switches.
20 #if !defined(NDEBUG)
21 const char kDirectoryBaseUrlSwitch[] = "directory-base-url";
22 const char kGcdBaseUrlSwitch[] = "gcd-base-url";
23 const char kXmppServerAddressSwitch[] = "xmpp-server-address";
24 const char kXmppServerDisableTlsSwitch[] = "disable-xmpp-server-tls";
25 const char kDirectoryBotJidSwitch[] = "directory-bot-jid";
26 const char kGcdJidSwitch[] = "gcd-jid";
27 #endif // !defined(NDEBUG)
29 // Non-configurable service paths.
30 const char kDirectoryHostsSuffix[] = "/@me/hosts/";
32 namespace remoting {
34 ServiceUrls::ServiceUrls()
35 : directory_base_url_(kDirectoryBaseUrl),
36 gcd_base_url_(kGcdBaseUrl),
37 xmpp_server_address_(kXmppServerAddress),
38 xmpp_server_address_for_me2me_host_(kXmppServerAddressForMe2MeHost),
39 xmpp_server_use_tls_(kXmppServerUseTls),
40 directory_bot_jid_(kDirectoryBotJid),
41 gcd_jid_(kGcdJid) {
42 #if !defined(NDEBUG)
43 // Allow debug builds to override urls via command line.
44 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
45 CHECK(command_line);
46 if (command_line->HasSwitch(kDirectoryBaseUrlSwitch)) {
47 directory_base_url_ = command_line->GetSwitchValueASCII(
48 kDirectoryBaseUrlSwitch);
50 if (command_line->HasSwitch(kGcdBaseUrlSwitch)) {
51 gcd_base_url_ = command_line->GetSwitchValueASCII(kGcdBaseUrlSwitch);
53 if (command_line->HasSwitch(kXmppServerAddressSwitch)) {
54 xmpp_server_address_ = command_line->GetSwitchValueASCII(
55 kXmppServerAddressSwitch);
56 xmpp_server_address_for_me2me_host_ = xmpp_server_address_;
58 if (command_line->HasSwitch(kXmppServerDisableTlsSwitch)) {
59 xmpp_server_use_tls_ = false;
61 if (command_line->HasSwitch(kDirectoryBotJidSwitch)) {
62 directory_bot_jid_ = command_line->GetSwitchValueASCII(
63 kDirectoryBotJidSwitch);
65 if (command_line->HasSwitch(kGcdJidSwitch)) {
66 gcd_jid_ = command_line->GetSwitchValueASCII(kGcdJidSwitch);
68 #endif // !defined(NDEBUG)
70 directory_hosts_url_ = directory_base_url_ + kDirectoryHostsSuffix;
73 ServiceUrls::~ServiceUrls() {
76 ServiceUrls* remoting::ServiceUrls::GetInstance() {
77 return Singleton<ServiceUrls>::get();
80 const std::string& ServiceUrls::directory_base_url() const {
81 return directory_base_url_;
84 const std::string& ServiceUrls::directory_hosts_url() const {
85 return directory_hosts_url_;
88 const std::string& ServiceUrls::gcd_base_url() const {
89 return gcd_base_url_;
92 const std::string& ServiceUrls::xmpp_server_address() const {
93 return xmpp_server_address_;
96 const std::string& ServiceUrls::xmpp_server_address_for_me2me_host() const {
97 return xmpp_server_address_for_me2me_host_;
100 bool ServiceUrls::xmpp_server_use_tls() const {
101 return xmpp_server_use_tls_;
104 const std::string& ServiceUrls::directory_bot_jid() const {
105 return directory_bot_jid_;
108 const std::string& ServiceUrls::gcd_jid() const {
109 return directory_bot_jid_;
112 } // namespace remoting