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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 // static | 214 // static |
215 buzz::PreXmppAuth* XmppSignalStrategy::CreatePreXmppAuth( | 215 buzz::PreXmppAuth* XmppSignalStrategy::CreatePreXmppAuth( |
216 const buzz::XmppClientSettings& settings) { | 216 const buzz::XmppClientSettings& settings) { |
217 buzz::Jid jid(settings.user(), settings.host(), buzz::STR_EMPTY); | 217 buzz::Jid jid(settings.user(), settings.host(), buzz::STR_EMPTY); |
218 std::string mechanism = notifier::GaiaTokenPreXmppAuth::kDefaultAuthMechanism; | 218 std::string mechanism = notifier::GaiaTokenPreXmppAuth::kDefaultAuthMechanism; |
219 if (settings.token_service() == "oauth2") { | 219 if (settings.token_service() == "oauth2") { |
220 mechanism = "X-OAUTH2"; | 220 mechanism = "X-OAUTH2"; |
221 } | 221 } |
222 | 222 |
223 return new notifier::GaiaTokenPreXmppAuth( | 223 return new notifier::GaiaTokenPreXmppAuth( |
224 jid.Str(), settings.auth_cookie(), settings.token_service(), mechanism); | 224 jid.Str(), settings.auth_token(), settings.token_service(), mechanism); |
225 } | 225 } |
226 | 226 |
227 } // namespace remoting | 227 } // namespace remoting |
OLD | NEW |