1 // Copyright (c) 2012 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. 4 5 #include "remoting/host/service_urls.h" 6 7 #include "base/command_line.h" 8 #include "base/logging.h" 9 10 // Configurable service data. 11 const char kDirectoryBaseUrl[] = "https://www.googleapis.com/chromoting/v1"; 12 const char kXmppServerAddress[] = "talk.google.com:5222"; 13 const bool kXmppServerUseTls = true; 14 const char kDirectoryBotJid[] = "remoting@bot.talk.google.com"; 15 16 // Command line switches. 17 #if !defined(NDEBUG) 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) 23 24 // Non-configurable service paths. 25 const char kDirectoryHostsSuffix[] = "/@me/hosts/"; 26 27 namespace remoting { 28 ServiceUrls()29ServiceUrls::ServiceUrls() 30 : directory_base_url_(kDirectoryBaseUrl), 31 xmpp_server_address_(kXmppServerAddress), 32 xmpp_server_use_tls_(kXmppServerUseTls), 33 directory_bot_jid_(kDirectoryBotJid) { 34 #if !defined(NDEBUG) 35 // Allow debug builds to override urls via command line. 36 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 37 CHECK(command_line); 38 if (command_line->HasSwitch(kDirectoryBaseUrlSwitch)) { 39 directory_base_url_ = command_line->GetSwitchValueASCII( 40 kDirectoryBaseUrlSwitch); 41 } 42 if (command_line->HasSwitch(kXmppServerAddressSwitch)) { 43 xmpp_server_address_ = command_line->GetSwitchValueASCII( 44 kXmppServerAddressSwitch); 45 } 46 if (command_line->HasSwitch(kXmppServerDisableTlsSwitch)) { 47 xmpp_server_use_tls_ = false; 48 } 49 if (command_line->HasSwitch(kDirectoryBotJidSwitch)) { 50 directory_bot_jid_ = command_line->GetSwitchValueASCII( 51 kDirectoryBotJidSwitch); 52 } 53 #endif // !defined(NDEBUG) 54 55 directory_hosts_url_ = directory_base_url_ + kDirectoryHostsSuffix; 56 } 57 ~ServiceUrls()58ServiceUrls::~ServiceUrls() { 59 } 60 GetInstance()61ServiceUrls* remoting::ServiceUrls::GetInstance() { 62 return Singleton<ServiceUrls>::get(); 63 } 64 directory_base_url() const65const std::string& ServiceUrls::directory_base_url() const { 66 return directory_base_url_; 67 } 68 directory_hosts_url() const69const std::string& ServiceUrls::directory_hosts_url() const { 70 return directory_hosts_url_; 71 } 72 xmpp_server_address() const73const std::string& ServiceUrls::xmpp_server_address() const { 74 return xmpp_server_address_; 75 } 76 xmpp_server_use_tls() const77bool ServiceUrls::xmpp_server_use_tls() const { 78 return xmpp_server_use_tls_; 79 } 80 directory_bot_jid() const81const std::string& ServiceUrls::directory_bot_jid() const { 82 return directory_bot_jid_; 83 } 84 85 } // namespace remoting 86