| 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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 | 128 |
| 129 bool ServiceState::IsValid() const { | 129 bool ServiceState::IsValid() const { |
| 130 if (email_.empty() || proxy_id_.empty()) | 130 if (email_.empty() || proxy_id_.empty()) |
| 131 return false; | 131 return false; |
| 132 bool valid_robot = !robot_email_.empty() && !robot_token_.empty(); | 132 bool valid_robot = !robot_email_.empty() && !robot_token_.empty(); |
| 133 bool valid_auth = !auth_token_.empty() && !xmpp_auth_token_.empty(); | 133 bool valid_auth = !auth_token_.empty() && !xmpp_auth_token_.empty(); |
| 134 return valid_robot || valid_auth; | 134 return valid_robot || valid_auth; |
| 135 } | 135 } |
| 136 | 136 |
| 137 std::string ServiceState::ToString() { | 137 std::string ServiceState::ToString() { |
| 138 scoped_ptr<base::DictionaryValue> services(new DictionaryValue()); | 138 scoped_ptr<base::DictionaryValue> services(new base::DictionaryValue()); |
| 139 | 139 |
| 140 scoped_ptr<base::DictionaryValue> cloud_print(new DictionaryValue()); | 140 scoped_ptr<base::DictionaryValue> cloud_print(new base::DictionaryValue()); |
| 141 cloud_print->SetBoolean(kEnabledOptionName, true); | 141 cloud_print->SetBoolean(kEnabledOptionName, true); |
| 142 | 142 |
| 143 SetNotEmptyJsonString(cloud_print.get(), kEmailOptionName, email_); | 143 SetNotEmptyJsonString(cloud_print.get(), kEmailOptionName, email_); |
| 144 SetNotEmptyJsonString(cloud_print.get(), kProxyIdOptionName, proxy_id_); | 144 SetNotEmptyJsonString(cloud_print.get(), kProxyIdOptionName, proxy_id_); |
| 145 SetNotEmptyJsonString(cloud_print.get(), kRobotEmailOptionName, robot_email_); | 145 SetNotEmptyJsonString(cloud_print.get(), kRobotEmailOptionName, robot_email_); |
| 146 SetNotEmptyJsonString(cloud_print.get(), kRobotTokenOptionName, robot_token_); | 146 SetNotEmptyJsonString(cloud_print.get(), kRobotTokenOptionName, robot_token_); |
| 147 SetNotEmptyJsonString(cloud_print.get(), kAuthTokenOptionName, auth_token_); | 147 SetNotEmptyJsonString(cloud_print.get(), kAuthTokenOptionName, auth_token_); |
| 148 SetNotEmptyJsonString(cloud_print.get(), kXmppAuthTokenOptionName, | 148 SetNotEmptyJsonString(cloud_print.get(), kXmppAuthTokenOptionName, |
| 149 xmpp_auth_token_); | 149 xmpp_auth_token_); |
| 150 | 150 |
| (...skipping 62 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 |