| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "remoting/jingle_glue/xmpp_signal_strategy.h" | 5 #include "remoting/jingle_glue/xmpp_signal_strategy.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "jingle/notifier/base/gaia_token_pre_xmpp_auth.h" | 10 #include "jingle/notifier/base/gaia_token_pre_xmpp_auth.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 // Disconnect first if we are currently connected. | 54 // Disconnect first if we are currently connected. |
| 55 Disconnect(); | 55 Disconnect(); |
| 56 | 56 |
| 57 buzz::XmppClientSettings settings; | 57 buzz::XmppClientSettings settings; |
| 58 buzz::Jid login_jid(username_); | 58 buzz::Jid login_jid(username_); |
| 59 settings.set_user(login_jid.node()); | 59 settings.set_user(login_jid.node()); |
| 60 settings.set_host(login_jid.domain()); | 60 settings.set_host(login_jid.domain()); |
| 61 settings.set_resource(resource_name_); | 61 settings.set_resource(resource_name_); |
| 62 settings.set_use_tls(buzz::TLS_ENABLED); | 62 settings.set_use_tls(buzz::TLS_ENABLED); |
| 63 settings.set_token_service(auth_token_service_); | 63 settings.set_token_service(auth_token_service_); |
| 64 settings.set_auth_cookie(auth_token_); | 64 settings.set_auth_token(buzz::AUTH_MECHANISM_GOOGLE_TOKEN, auth_token_); |
| 65 settings.set_server(talk_base::SocketAddress("talk.google.com", 5222)); | 65 settings.set_server(talk_base::SocketAddress("talk.google.com", 5222)); |
| 66 | 66 |
| 67 buzz::AsyncSocket* socket = new XmppSocketAdapter(settings, false); | 67 buzz::AsyncSocket* socket = new XmppSocketAdapter(settings, false); |
| 68 | 68 |
| 69 xmpp_client_ = new buzz::XmppClient(thread_->task_pump()); | 69 xmpp_client_ = new buzz::XmppClient(thread_->task_pump()); |
| 70 xmpp_client_->Connect(settings, "", socket, CreatePreXmppAuth(settings)); | 70 xmpp_client_->Connect(settings, "", socket, CreatePreXmppAuth(settings)); |
| 71 xmpp_client_->SignalStateChange.connect( | 71 xmpp_client_->SignalStateChange.connect( |
| 72 this, &XmppSignalStrategy::OnConnectionStateChanged); | 72 this, &XmppSignalStrategy::OnConnectionStateChanged); |
| 73 xmpp_client_->engine()->AddStanzaHandler(this, buzz::XmppEngine::HL_TYPE); | 73 xmpp_client_->engine()->AddStanzaHandler(this, buzz::XmppEngine::HL_TYPE); |
| 74 xmpp_client_->Start(); | 74 xmpp_client_->Start(); |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 // static | 232 // static |
| 233 buzz::PreXmppAuth* XmppSignalStrategy::CreatePreXmppAuth( | 233 buzz::PreXmppAuth* XmppSignalStrategy::CreatePreXmppAuth( |
| 234 const buzz::XmppClientSettings& settings) { | 234 const buzz::XmppClientSettings& settings) { |
| 235 buzz::Jid jid(settings.user(), settings.host(), buzz::STR_EMPTY); | 235 buzz::Jid jid(settings.user(), settings.host(), buzz::STR_EMPTY); |
| 236 std::string mechanism = notifier::GaiaTokenPreXmppAuth::kDefaultAuthMechanism; | 236 std::string mechanism = notifier::GaiaTokenPreXmppAuth::kDefaultAuthMechanism; |
| 237 if (settings.token_service() == "oauth2") { | 237 if (settings.token_service() == "oauth2") { |
| 238 mechanism = "X-OAUTH2"; | 238 mechanism = "X-OAUTH2"; |
| 239 } | 239 } |
| 240 | 240 |
| 241 return new notifier::GaiaTokenPreXmppAuth( | 241 return new notifier::GaiaTokenPreXmppAuth( |
| 242 jid.Str(), settings.auth_cookie(), settings.token_service(), mechanism); | 242 jid.Str(), settings.auth_token(), settings.token_service(), mechanism); |
| 243 } | 243 } |
| 244 | 244 |
| 245 } // namespace remoting | 245 } // namespace remoting |
| OLD | NEW |