| 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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 FROM_HERE, | 192 FROM_HERE, |
| 193 base::MessageLoop::QuitClosure(), | 193 base::MessageLoop::QuitClosure(), |
| 194 base::TimeDelta::FromMilliseconds(kRequestTimeoutMs)); | 194 base::TimeDelta::FromMilliseconds(kRequestTimeoutMs)); |
| 195 | 195 |
| 196 base::MessageLoop::current()->Run(); | 196 base::MessageLoop::current()->Run(); |
| 197 | 197 |
| 198 const char kAuthStart[] = "Auth="; | 198 const char kAuthStart[] = "Auth="; |
| 199 std::vector<std::string> lines; | 199 std::vector<std::string> lines; |
| 200 Tokenize(fetcher_delegate.data(), "\r\n", &lines); | 200 Tokenize(fetcher_delegate.data(), "\r\n", &lines); |
| 201 for (size_t i = 0; i < lines.size(); ++i) { | 201 for (size_t i = 0; i < lines.size(); ++i) { |
| 202 if (StartsWithASCII(lines[i], kAuthStart, false)) | 202 if (base::StartsWithASCII(lines[i], kAuthStart, false)) |
| 203 return lines[i].substr(arraysize(kAuthStart) - 1); | 203 return lines[i].substr(arraysize(kAuthStart) - 1); |
| 204 } | 204 } |
| 205 | 205 |
| 206 return std::string(); | 206 return std::string(); |
| 207 } | 207 } |
| 208 | 208 |
| 209 bool ServiceState::Configure(const std::string& email, | 209 bool ServiceState::Configure(const std::string& email, |
| 210 const std::string& password, | 210 const std::string& password, |
| 211 const std::string& proxy_id) { | 211 const std::string& proxy_id) { |
| 212 robot_token_.clear(); | 212 robot_token_.clear(); |
| 213 robot_email_.clear(); | 213 robot_email_.clear(); |
| 214 email_ = email; | 214 email_ = email; |
| 215 proxy_id_ = proxy_id; | 215 proxy_id_ = proxy_id; |
| 216 auth_token_ = LoginToGoogle("cloudprint", email_, password); | 216 auth_token_ = LoginToGoogle("cloudprint", email_, password); |
| 217 xmpp_auth_token_ = LoginToGoogle("chromiumsync", email_, password); | 217 xmpp_auth_token_ = LoginToGoogle("chromiumsync", email_, password); |
| 218 return IsValid(); | 218 return IsValid(); |
| 219 } | 219 } |
| OLD | NEW |