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" |
11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
13 #include "net/base/escape.h" | 13 #include "net/base/escape.h" |
14 #include "net/base/io_buffer.h" | 14 #include "net/base/io_buffer.h" |
| 15 #include "net/base/load_flags.h" |
15 #include "net/url_request/url_request.h" | 16 #include "net/url_request/url_request.h" |
16 #include "net/url_request/url_request_context.h" | 17 #include "net/url_request/url_request_context.h" |
17 #include "net/url_request/url_request_context_builder.h" | 18 #include "net/url_request/url_request_context_builder.h" |
18 | 19 |
19 namespace { | 20 namespace { |
20 | 21 |
21 const char kCloudPrintJsonName[] = "cloud_print"; | 22 const char kCloudPrintJsonName[] = "cloud_print"; |
22 const char kEnabledOptionName[] = "enabled"; | 23 const char kEnabledOptionName[] = "enabled"; |
23 | 24 |
24 const char kEmailOptionName[] = "email"; | 25 const char kEmailOptionName[] = "email"; |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 GURL url(kClientLoginUrl); | 166 GURL url(kClientLoginUrl); |
166 | 167 |
167 std::string post_body; | 168 std::string post_body; |
168 post_body += "accountType=GOOGLE"; | 169 post_body += "accountType=GOOGLE"; |
169 post_body += "&Email=" + net::EscapeUrlEncodedData(email, true); | 170 post_body += "&Email=" + net::EscapeUrlEncodedData(email, true); |
170 post_body += "&Passwd=" + net::EscapeUrlEncodedData(password, true); | 171 post_body += "&Passwd=" + net::EscapeUrlEncodedData(password, true); |
171 post_body += "&source=" + net::EscapeUrlEncodedData("CP-Service", true); | 172 post_body += "&source=" + net::EscapeUrlEncodedData("CP-Service", true); |
172 post_body += "&service=" + net::EscapeUrlEncodedData(service, true); | 173 post_body += "&service=" + net::EscapeUrlEncodedData(service, true); |
173 | 174 |
174 net::URLRequest request(url, &fetcher_delegate, context.get()); | 175 net::URLRequest request(url, &fetcher_delegate, context.get()); |
| 176 int load_flags = request.load_flags(); |
| 177 load_flags = load_flags | net::LOAD_DO_NOT_SEND_COOKIES; |
| 178 load_flags = load_flags | net::LOAD_DO_NOT_SAVE_COOKIES; |
| 179 request.set_load_flags(load_flags); |
175 | 180 |
176 request.AppendBytesToUpload(post_body.c_str(), post_body.size()); | 181 request.AppendBytesToUpload(post_body.c_str(), post_body.size()); |
177 request.SetExtraRequestHeaderByName( | 182 request.SetExtraRequestHeaderByName( |
178 "Content-Type", "application/x-www-form-urlencoded", true); | 183 "Content-Type", "application/x-www-form-urlencoded", true); |
179 request.set_method("POST"); | 184 request.set_method("POST"); |
180 request.Start(); | 185 request.Start(); |
181 | 186 |
182 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 187 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
183 MessageLoop::QuitClosure(), | 188 MessageLoop::QuitClosure(), |
184 base::TimeDelta::FromMilliseconds(kRequestTimeoutMs)); | 189 base::TimeDelta::FromMilliseconds(kRequestTimeoutMs)); |
(...skipping 16 matching lines...) Expand all Loading... |
201 const std::string& password, | 206 const std::string& password, |
202 const std::string& proxy_id) { | 207 const std::string& proxy_id) { |
203 robot_token_.clear(); | 208 robot_token_.clear(); |
204 robot_email_.clear(); | 209 robot_email_.clear(); |
205 email_ = email; | 210 email_ = email; |
206 proxy_id_ = proxy_id; | 211 proxy_id_ = proxy_id; |
207 auth_token_ = LoginToGoogle("cloudprint", email_, password); | 212 auth_token_ = LoginToGoogle("cloudprint", email_, password); |
208 xmpp_auth_token_ = LoginToGoogle("chromiumsync", email_, password); | 213 xmpp_auth_token_ = LoginToGoogle("chromiumsync", email_, password); |
209 return IsValid(); | 214 return IsValid(); |
210 } | 215 } |
OLD | NEW |