Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: chrome/common/net/notifier/communicator/single_login_attempt.cc

Issue 2255007: New libjingle integrated to chrome. (Closed)
Patch Set: - Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 <algorithm> 5 #include <algorithm>
6 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "chrome/common/net/notifier/communicator/single_login_attempt.h" 9 #include "chrome/common/net/notifier/communicator/single_login_attempt.h"
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "chrome/common/net/notifier/communicator/connection_options.h" 12 #include "chrome/common/net/notifier/communicator/connection_options.h"
13 #include "chrome/common/net/notifier/communicator/connection_settings.h" 13 #include "chrome/common/net/notifier/communicator/connection_settings.h"
14 #include "chrome/common/net/notifier/communicator/const_communicator.h" 14 #include "chrome/common/net/notifier/communicator/const_communicator.h"
15 #include "chrome/common/net/notifier/communicator/login_failure.h" 15 #include "chrome/common/net/notifier/communicator/login_failure.h"
16 #include "chrome/common/net/notifier/communicator/login_settings.h" 16 #include "chrome/common/net/notifier/communicator/login_settings.h"
17 #include "chrome/common/net/notifier/communicator/product_info.h" 17 #include "chrome/common/net/notifier/communicator/product_info.h"
18 #include "chrome/common/net/notifier/communicator/xmpp_connection_generator.h" 18 #include "chrome/common/net/notifier/communicator/xmpp_connection_generator.h"
19 #include "chrome/common/net/notifier/communicator/xmpp_socket_adapter.h" 19 #include "chrome/common/net/notifier/communicator/xmpp_socket_adapter.h"
20 #include "talk/base/asynchttprequest.h" 20 #include "talk/base/asynchttprequest.h"
21 #include "talk/base/firewallsocketserver.h" 21 #include "talk/base/firewallsocketserver.h"
22 #include "talk/base/signalthread.h" 22 #include "talk/base/signalthread.h"
23 #include "talk/base/taskrunner.h" 23 #include "talk/base/taskrunner.h"
24 #include "talk/base/winsock_initializer.h" 24 #include "talk/base/win32socketinit.h"
25 #include "talk/xmllite/xmlelement.h" 25 #include "talk/xmllite/xmlelement.h"
26 #include "talk/xmpp/prexmppauth.h" 26 #include "talk/xmpp/prexmppauth.h"
27 #include "talk/xmpp/saslcookiemechanism.h" 27 #include "talk/xmpp/saslcookiemechanism.h"
28 #include "talk/xmpp/xmppclient.h" 28 #include "talk/xmpp/xmppclient.h"
29 #include "talk/xmpp/xmppclientsettings.h" 29 #include "talk/xmpp/xmppclientsettings.h"
30 #include "talk/xmpp/xmppconstants.h" 30 #include "talk/xmpp/constants.h"
31 31
32 namespace notifier { 32 namespace notifier {
33 33
34 static void GetClientErrorInformation( 34 static void GetClientErrorInformation(
35 buzz::XmppClient* client, 35 buzz::XmppClient* client,
36 buzz::XmppEngine::Error* error, 36 buzz::XmppEngine::Error* error,
37 int* subcode, 37 int* subcode,
38 buzz::XmlElement** stream_error) { 38 buzz::XmlElement** stream_error) {
39 DCHECK(client); 39 DCHECK(client);
40 DCHECK(error); 40 DCHECK(error);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 // this point. 75 // this point.
76 76
77 virtual void StartPreXmppAuth( 77 virtual void StartPreXmppAuth(
78 const buzz::Jid& jid, 78 const buzz::Jid& jid,
79 const talk_base::SocketAddress& server, 79 const talk_base::SocketAddress& server,
80 const talk_base::CryptString& pass, 80 const talk_base::CryptString& pass,
81 const std::string& auth_cookie) { 81 const std::string& auth_cookie) {
82 SignalAuthDone(); 82 SignalAuthDone();
83 } 83 }
84 84
85 virtual bool IsAuthDone() { return true; } 85 virtual bool IsAuthDone() const { return true; }
86 86
87 virtual bool IsAuthorized() { return true; } 87 virtual bool IsAuthorized() const { return true; }
88 88
89 virtual bool HadError() { return false; } 89 virtual bool HadError() const { return false; }
90 90
91 virtual int GetError() { return 0; } 91 virtual int GetError() const { return 0; }
92 92
93 virtual buzz::CaptchaChallenge GetCaptchaChallenge() { 93 virtual buzz::CaptchaChallenge GetCaptchaChallenge() const {
94 return buzz::CaptchaChallenge(); 94 return buzz::CaptchaChallenge();
95 } 95 }
96 96
97 virtual std::string GetAuthCookie() { return std::string(); } 97 virtual std::string GetAuthCookie() const { return std::string(); }
98 98
99 // buzz::SaslHandler implementation. 99 // buzz::SaslHandler implementation.
100 100
101 virtual std::string ChooseBestSaslMechanism( 101 virtual std::string ChooseBestSaslMechanism(
102 const std::vector<std::string> & mechanisms, bool encrypted) { 102 const std::vector<std::string> & mechanisms, bool encrypted) {
103 return (std::find(mechanisms.begin(), 103 return (std::find(mechanisms.begin(),
104 mechanisms.end(), kGaiaAuthMechanism) != 104 mechanisms.end(), kGaiaAuthMechanism) !=
105 mechanisms.end()) ? kGaiaAuthMechanism : ""; 105 mechanisms.end()) ? kGaiaAuthMechanism : "";
106 } 106 }
107 107
108 virtual buzz::SaslMechanism* CreateSaslMechanism( 108 virtual buzz::SaslMechanism* CreateSaslMechanism(
109 const std::string& mechanism) { 109 const std::string& mechanism) {
110 return 110 return
111 (mechanism == kGaiaAuthMechanism) ? 111 (mechanism == kGaiaAuthMechanism) ?
112 new buzz::SaslCookieMechanism( 112 new buzz::SaslCookieMechanism(
113 kGaiaAuthMechanism, username_, token_, token_service_) 113 kGaiaAuthMechanism, username_, token_, token_service_)
114 : NULL; 114 : NULL;
115 } 115 }
116 116
117 // TODO(akalin): remove this code.
117 virtual bool GetTlsServerInfo(const talk_base::SocketAddress& server, 118 virtual bool GetTlsServerInfo(const talk_base::SocketAddress& server,
118 std::string* tls_server_hostname, 119 std::string* tls_server_hostname,
119 std::string* tls_server_domain) { 120 std::string* tls_server_domain) const {
120 std::string server_ip = server.IPAsString(); 121 std::string server_ip = server.IPAsString();
121 if ((server_ip == buzz::STR_TALK_GOOGLE_COM) || 122 if ((server_ip == buzz::STR_TALK_GOOGLE_COM) ||
122 (server_ip == buzz::STR_TALKX_L_GOOGLE_COM)) { 123 (server_ip == buzz::STR_TALKX_L_GOOGLE_COM)) {
123 // For Gaia auth, the talk.google.com server expects you to use 124 // For Gaia auth, the talk.google.com server expects you to use
124 // "gmail.com" in the stream, and expects the domain certificate 125 // "gmail.com" in the stream, and expects the domain certificate
125 // to be "gmail.com" as well. 126 // to be "gmail.com" as well.
126 *tls_server_hostname = buzz::STR_GMAIL_COM; 127 *tls_server_hostname = buzz::STR_GMAIL_COM;
127 *tls_server_domain = buzz::STR_GMAIL_COM; 128 *tls_server_domain = buzz::STR_GMAIL_COM;
128 return true; 129 return true;
129 } 130 }
130 return false; 131 return false;
131 } 132 }
132 133
133 private: 134 private:
134 std::string username_, token_, token_service_; 135 std::string username_, token_, token_service_;
135 }; 136 };
136 137
137 } // namespace 138 } // namespace
138 139
139 SingleLoginAttempt::SingleLoginAttempt(talk_base::Task* parent, 140 SingleLoginAttempt::SingleLoginAttempt(talk_base::TaskParent* parent,
140 LoginSettings* login_settings, 141 LoginSettings* login_settings,
141 bool successful_connection) 142 bool successful_connection)
142 : talk_base::Task(parent), 143 : talk_base::Task(parent),
143 state_(buzz::XmppEngine::STATE_NONE), 144 state_(buzz::XmppEngine::STATE_NONE),
144 code_(buzz::XmppEngine::ERROR_NONE), 145 code_(buzz::XmppEngine::ERROR_NONE),
145 subcode_(0), 146 subcode_(0),
146 need_authentication_(false), 147 need_authentication_(false),
147 certificate_expired_(false), 148 certificate_expired_(false),
148 cookie_refreshed_(false), 149 cookie_refreshed_(false),
149 successful_connection_(successful_connection), 150 successful_connection_(successful_connection),
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 DCHECK(connection_generator_.get()); 594 DCHECK(connection_generator_.get());
594 if (!connection_generator_.get()) { 595 if (!connection_generator_.get()) {
595 return; 596 return;
596 } 597 }
597 598
598 // Iterate to the next possible connection (still trying to connect). 599 // Iterate to the next possible connection (still trying to connect).
599 UseNextConnection(); 600 UseNextConnection();
600 } 601 }
601 602
602 } // namespace notifier 603 } // namespace notifier
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698