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 20 matching lines...) Expand all Loading... |
31 const char kRobotTokenOptionName[] = "robot_refresh_token"; | 31 const char kRobotTokenOptionName[] = "robot_refresh_token"; |
32 const char kAuthTokenOptionName[] = "auth_token"; | 32 const char kAuthTokenOptionName[] = "auth_token"; |
33 const char kXmppAuthTokenOptionName[] = "xmpp_auth_token"; | 33 const char kXmppAuthTokenOptionName[] = "xmpp_auth_token"; |
34 | 34 |
35 const char kClientLoginUrl[] = "https://www.google.com/accounts/ClientLogin"; | 35 const char kClientLoginUrl[] = "https://www.google.com/accounts/ClientLogin"; |
36 | 36 |
37 const int64 kRequestTimeoutMs = 10 * 1000; | 37 const int64 kRequestTimeoutMs = 10 * 1000; |
38 | 38 |
39 class ServiceStateURLRequestDelegate : public net::URLRequest::Delegate { | 39 class ServiceStateURLRequestDelegate : public net::URLRequest::Delegate { |
40 public: | 40 public: |
41 virtual void OnResponseStarted(net::URLRequest* request) OVERRIDE { | 41 virtual void OnResponseStarted(net::URLRequest* request) override { |
42 if (request->GetResponseCode() == 200) { | 42 if (request->GetResponseCode() == 200) { |
43 Read(request); | 43 Read(request); |
44 if (request->status().is_io_pending()) | 44 if (request->status().is_io_pending()) |
45 return; | 45 return; |
46 } | 46 } |
47 request->Cancel(); | 47 request->Cancel(); |
48 } | 48 } |
49 | 49 |
50 virtual void OnReadCompleted(net::URLRequest* request, | 50 virtual void OnReadCompleted(net::URLRequest* request, |
51 int bytes_read) OVERRIDE { | 51 int bytes_read) override { |
52 Read(request); | 52 Read(request); |
53 if (!request->status().is_io_pending()) | 53 if (!request->status().is_io_pending()) |
54 base::MessageLoop::current()->Quit(); | 54 base::MessageLoop::current()->Quit(); |
55 } | 55 } |
56 | 56 |
57 const std::string& data() const { | 57 const std::string& data() const { |
58 return data_; | 58 return data_; |
59 } | 59 } |
60 | 60 |
61 private: | 61 private: |
(...skipping 151 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 |