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 "cloud_print/service/service_state.h" | 5 #include "cloud_print/service/service_state.h" |
6 | 6 |
7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 ServiceStateURLRequestDelegate fetcher_delegate; | 164 ServiceStateURLRequestDelegate fetcher_delegate; |
165 GURL url(kClientLoginUrl); | 165 GURL url(kClientLoginUrl); |
166 | 166 |
167 std::string post_body; | 167 std::string post_body; |
168 post_body += "accountType=GOOGLE"; | 168 post_body += "accountType=GOOGLE"; |
169 post_body += "&Email=" + net::EscapeUrlEncodedData(email, true); | 169 post_body += "&Email=" + net::EscapeUrlEncodedData(email, true); |
170 post_body += "&Passwd=" + net::EscapeUrlEncodedData(password, true); | 170 post_body += "&Passwd=" + net::EscapeUrlEncodedData(password, true); |
171 post_body += "&source=" + net::EscapeUrlEncodedData("CP-Service", true); | 171 post_body += "&source=" + net::EscapeUrlEncodedData("CP-Service", true); |
172 post_body += "&service=" + net::EscapeUrlEncodedData(service, true); | 172 post_body += "&service=" + net::EscapeUrlEncodedData(service, true); |
173 | 173 |
174 net::URLRequest request(url, &fetcher_delegate); | 174 net::URLRequest request(url, &fetcher_delegate, context.get()); |
175 | 175 |
176 request.AppendBytesToUpload(post_body.c_str(), post_body.size()); | 176 request.AppendBytesToUpload(post_body.c_str(), post_body.size()); |
177 request.SetExtraRequestHeaderByName( | 177 request.SetExtraRequestHeaderByName( |
178 "Content-Type", "application/x-www-form-urlencoded", true); | 178 "Content-Type", "application/x-www-form-urlencoded", true); |
179 request.set_context(context.get()); | |
180 request.set_method("POST"); | 179 request.set_method("POST"); |
181 request.Start(); | 180 request.Start(); |
182 | 181 |
183 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 182 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
184 MessageLoop::QuitClosure(), | 183 MessageLoop::QuitClosure(), |
185 base::TimeDelta::FromMilliseconds(kRequestTimeoutMs)); | 184 base::TimeDelta::FromMilliseconds(kRequestTimeoutMs)); |
186 | 185 |
187 MessageLoop::current()->Run(); | 186 MessageLoop::current()->Run(); |
188 | 187 |
189 const char kAuthStart[] = "Auth="; | 188 const char kAuthStart[] = "Auth="; |
(...skipping 13 matching lines...) Expand all Loading... |
203 const std::string& proxy_id) { | 202 const std::string& proxy_id) { |
204 robot_token_.clear(); | 203 robot_token_.clear(); |
205 robot_email_.clear(); | 204 robot_email_.clear(); |
206 email_ = email; | 205 email_ = email; |
207 proxy_id_ = proxy_id; | 206 proxy_id_ = proxy_id; |
208 auth_token_ = LoginToGoogle("cloudprint", email_, password); | 207 auth_token_ = LoginToGoogle("cloudprint", email_, password); |
209 xmpp_auth_token_ = LoginToGoogle("chromiumsync", email_, password); | 208 xmpp_auth_token_ = LoginToGoogle("chromiumsync", email_, password); |
210 return IsValid(); | 209 return IsValid(); |
211 } | 210 } |
212 | 211 |
OLD | NEW |