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( | 182 MessageLoop::current()->PostDelayedTask( |
184 FROM_HERE, MessageLoop::QuitClosure(), kRequestTimeoutMs); | 183 FROM_HERE, MessageLoop::QuitClosure(), kRequestTimeoutMs); |
185 | 184 |
186 MessageLoop::current()->Run(); | 185 MessageLoop::current()->Run(); |
187 | 186 |
188 const char kAuthStart[] = "Auth="; | 187 const char kAuthStart[] = "Auth="; |
189 std::vector<std::string> lines; | 188 std::vector<std::string> lines; |
(...skipping 12 matching lines...) Expand all Loading... |
202 const std::string& proxy_id) { | 201 const std::string& proxy_id) { |
203 robot_token_.clear(); | 202 robot_token_.clear(); |
204 robot_email_.clear(); | 203 robot_email_.clear(); |
205 email_ = email; | 204 email_ = email; |
206 proxy_id_ = proxy_id; | 205 proxy_id_ = proxy_id; |
207 auth_token_ = LoginToGoogle("cloudprint", email_, password); | 206 auth_token_ = LoginToGoogle("cloudprint", email_, password); |
208 xmpp_auth_token_ = LoginToGoogle("chromiumsync", email_, password); | 207 xmpp_auth_token_ = LoginToGoogle("chromiumsync", email_, password); |
209 return IsValid(); | 208 return IsValid(); |
210 } | 209 } |
211 | 210 |
OLD | NEW |