| OLD | NEW |
| (Empty) |
| 1 // Copyright 2016 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 #include "google_apis/google_api_keys.h" | |
| 10 #include "remoting/signaling/remoting_bot.h" | |
| 11 | |
| 12 // Configurable service data. | |
| 13 const char kDirectoryBaseUrl[] = "https://www.googleapis.com/chromoting/v1"; | |
| 14 const char kGcdBaseUrl[] = "https://www.googleapis.com/clouddevices/v1"; | |
| 15 const char kXmppServerAddress[] = "talk.google.com:443"; | |
| 16 const char kXmppServerAddressForMe2MeHost[] = "talk.google.com:5222"; | |
| 17 const bool kXmppServerUseTls = true; | |
| 18 const char kGcdJid[] = "clouddevices.gserviceaccount.com"; | |
| 19 const char kNetworkTraversalApiUrlBase[] = | |
| 20 "https://networktraversal.googleapis.com/v1alpha/iceconfig?key="; | |
| 21 | |
| 22 // Command line switches. | |
| 23 #if !defined(NDEBUG) | |
| 24 const char kDirectoryBaseUrlSwitch[] = "directory-base-url"; | |
| 25 const char kGcdBaseUrlSwitch[] = "gcd-base-url"; | |
| 26 const char kXmppServerAddressSwitch[] = "xmpp-server-address"; | |
| 27 const char kXmppServerDisableTlsSwitch[] = "disable-xmpp-server-tls"; | |
| 28 const char kDirectoryBotJidSwitch[] = "directory-bot-jid"; | |
| 29 const char kGcdJidSwitch[] = "gcd-jid"; | |
| 30 const char kIceConfigUrl[] = "ice_config_url"; | |
| 31 #endif // !defined(NDEBUG) | |
| 32 | |
| 33 // Non-configurable service paths. | |
| 34 const char kDirectoryHostsSuffix[] = "/@me/hosts/"; | |
| 35 | |
| 36 namespace remoting { | |
| 37 | |
| 38 ServiceUrls::ServiceUrls() | |
| 39 : directory_base_url_(kDirectoryBaseUrl), | |
| 40 gcd_base_url_(kGcdBaseUrl), | |
| 41 xmpp_server_address_(kXmppServerAddress), | |
| 42 xmpp_server_address_for_me2me_host_(kXmppServerAddressForMe2MeHost), | |
| 43 xmpp_server_use_tls_(kXmppServerUseTls), | |
| 44 directory_bot_jid_(kRemotingBotJid), | |
| 45 gcd_jid_(kGcdJid), | |
| 46 ice_config_url_(kNetworkTraversalApiUrlBase + | |
| 47 google_apis::GetRemotingAPIKey()) { | |
| 48 #if !defined(NDEBUG) | |
| 49 // Allow debug builds to override urls via command line. | |
| 50 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | |
| 51 CHECK(command_line); | |
| 52 if (command_line->HasSwitch(kDirectoryBaseUrlSwitch)) { | |
| 53 directory_base_url_ = command_line->GetSwitchValueASCII( | |
| 54 kDirectoryBaseUrlSwitch); | |
| 55 } | |
| 56 if (command_line->HasSwitch(kGcdBaseUrlSwitch)) { | |
| 57 gcd_base_url_ = command_line->GetSwitchValueASCII(kGcdBaseUrlSwitch); | |
| 58 } | |
| 59 if (command_line->HasSwitch(kXmppServerAddressSwitch)) { | |
| 60 xmpp_server_address_ = command_line->GetSwitchValueASCII( | |
| 61 kXmppServerAddressSwitch); | |
| 62 xmpp_server_address_for_me2me_host_ = xmpp_server_address_; | |
| 63 } | |
| 64 if (command_line->HasSwitch(kXmppServerDisableTlsSwitch)) { | |
| 65 xmpp_server_use_tls_ = false; | |
| 66 } | |
| 67 if (command_line->HasSwitch(kDirectoryBotJidSwitch)) { | |
| 68 directory_bot_jid_ = command_line->GetSwitchValueASCII( | |
| 69 kDirectoryBotJidSwitch); | |
| 70 } | |
| 71 if (command_line->HasSwitch(kGcdJidSwitch)) { | |
| 72 gcd_jid_ = command_line->GetSwitchValueASCII(kGcdJidSwitch); | |
| 73 } | |
| 74 if (command_line->HasSwitch(kIceConfigUrl)) { | |
| 75 ice_config_url_ = command_line->GetSwitchValueASCII(kIceConfigUrl); | |
| 76 } | |
| 77 #endif // !defined(NDEBUG) | |
| 78 | |
| 79 directory_hosts_url_ = directory_base_url_ + kDirectoryHostsSuffix; | |
| 80 } | |
| 81 | |
| 82 ServiceUrls::~ServiceUrls() {} | |
| 83 | |
| 84 ServiceUrls* remoting::ServiceUrls::GetInstance() { | |
| 85 return base::Singleton<ServiceUrls>::get(); | |
| 86 } | |
| 87 | |
| 88 } // namespace remoting | |
| OLD | NEW |