| 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/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 std::string json; | 153 std::string json; |
| 154 base::JSONWriter::WriteWithOptions(services.get(), | 154 base::JSONWriter::WriteWithOptions(services.get(), |
| 155 base::JSONWriter::OPTIONS_PRETTY_PRINT, | 155 base::JSONWriter::OPTIONS_PRETTY_PRINT, |
| 156 &json); | 156 &json); |
| 157 return json; | 157 return json; |
| 158 } | 158 } |
| 159 | 159 |
| 160 std::string ServiceState::LoginToGoogle(const std::string& service, | 160 std::string ServiceState::LoginToGoogle(const std::string& service, |
| 161 const std::string& email, | 161 const std::string& email, |
| 162 const std::string& password) { | 162 const std::string& password) { |
| 163 base::MessageLoop loop(base::MessageLoop::TYPE_IO); | 163 base::MessageLoopForIO loop; |
| 164 | 164 |
| 165 net::URLRequestContextBuilder builder; | 165 net::URLRequestContextBuilder builder; |
| 166 scoped_ptr<net::URLRequestContext> context(builder.Build()); | 166 scoped_ptr<net::URLRequestContext> context(builder.Build()); |
| 167 | 167 |
| 168 ServiceStateURLRequestDelegate fetcher_delegate; | 168 ServiceStateURLRequestDelegate fetcher_delegate; |
| 169 GURL url(kClientLoginUrl); | 169 GURL url(kClientLoginUrl); |
| 170 | 170 |
| 171 std::string post_body; | 171 std::string post_body; |
| 172 post_body += "accountType=GOOGLE"; | 172 post_body += "accountType=GOOGLE"; |
| 173 post_body += "&Email=" + net::EscapeUrlEncodedData(email, true); | 173 post_body += "&Email=" + net::EscapeUrlEncodedData(email, true); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 const std::string& password, | 213 const std::string& password, |
| 214 const std::string& proxy_id) { | 214 const std::string& proxy_id) { |
| 215 robot_token_.clear(); | 215 robot_token_.clear(); |
| 216 robot_email_.clear(); | 216 robot_email_.clear(); |
| 217 email_ = email; | 217 email_ = email; |
| 218 proxy_id_ = proxy_id; | 218 proxy_id_ = proxy_id; |
| 219 auth_token_ = LoginToGoogle("cloudprint", email_, password); | 219 auth_token_ = LoginToGoogle("cloudprint", email_, password); |
| 220 xmpp_auth_token_ = LoginToGoogle("chromiumsync", email_, password); | 220 xmpp_auth_token_ = LoginToGoogle("chromiumsync", email_, password); |
| 221 return IsValid(); | 221 return IsValid(); |
| 222 } | 222 } |
| OLD | NEW |