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. 4 5#include "remoting/base/service_urls.h" 6 7#include "base/command_line.h" 8#include "base/logging.h" 9 10// Configurable service data. 11const char kDirectoryBaseUrl[] = "https://www.googleapis.com/chromoting/v1"; 12const char kXmppServerAddress[] = "talk.google.com:5222"; 13const bool kXmppServerUseTls = true; 14const char kDirectoryBotJid[] = "remoting@bot.talk.google.com"; 15 16// Command line switches. 17#if !defined(NDEBUG) 18const char kDirectoryBaseUrlSwitch[] = "directory-base-url"; 19const char kXmppServerAddressSwitch[] = "xmpp-server-address"; 20const char kXmppServerDisableTlsSwitch[] = "disable-xmpp-server-tls"; 21const char kDirectoryBotJidSwitch[] = "directory-bot-jid"; 22#endif // !defined(NDEBUG) 23 24// Non-configurable service paths. 25const char kDirectoryHostsSuffix[] = "/@me/hosts/"; 26 27namespace remoting { 28 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 58ServiceUrls::~ServiceUrls() { 59} 60 61ServiceUrls* remoting::ServiceUrls::GetInstance() { 62 return Singleton<ServiceUrls>::get(); 63} 64 65const std::string& ServiceUrls::directory_base_url() const { 66 return directory_base_url_; 67} 68 69const std::string& ServiceUrls::directory_hosts_url() const { 70 return directory_hosts_url_; 71} 72 73const std::string& ServiceUrls::xmpp_server_address() const { 74 return xmpp_server_address_; 75} 76 77bool ServiceUrls::xmpp_server_use_tls() const { 78 return xmpp_server_use_tls_; 79} 80 81const std::string& ServiceUrls::directory_bot_jid() const { 82 return directory_bot_jid_; 83} 84 85} // namespace remoting 86