| 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 "google_apis/gaia/google_service_auth_error.h" | 5 #include "google_apis/gaia/google_service_auth_error.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 default: | 147 default: |
| 148 NOTREACHED(); | 148 NOTREACHED(); |
| 149 } | 149 } |
| 150 return EmptyString(); | 150 return EmptyString(); |
| 151 } | 151 } |
| 152 | 152 |
| 153 const std::string& GoogleServiceAuthError::error_message() const { | 153 const std::string& GoogleServiceAuthError::error_message() const { |
| 154 return error_message_; | 154 return error_message_; |
| 155 } | 155 } |
| 156 | 156 |
| 157 DictionaryValue* GoogleServiceAuthError::ToValue() const { | 157 base::DictionaryValue* GoogleServiceAuthError::ToValue() const { |
| 158 DictionaryValue* value = new DictionaryValue(); | 158 base::DictionaryValue* value = new base::DictionaryValue(); |
| 159 std::string state_str; | 159 std::string state_str; |
| 160 switch (state_) { | 160 switch (state_) { |
| 161 #define STATE_CASE(x) case x: state_str = #x; break | 161 #define STATE_CASE(x) case x: state_str = #x; break |
| 162 STATE_CASE(NONE); | 162 STATE_CASE(NONE); |
| 163 STATE_CASE(INVALID_GAIA_CREDENTIALS); | 163 STATE_CASE(INVALID_GAIA_CREDENTIALS); |
| 164 STATE_CASE(USER_NOT_SIGNED_UP); | 164 STATE_CASE(USER_NOT_SIGNED_UP); |
| 165 STATE_CASE(CONNECTION_FAILED); | 165 STATE_CASE(CONNECTION_FAILED); |
| 166 STATE_CASE(CAPTCHA_REQUIRED); | 166 STATE_CASE(CAPTCHA_REQUIRED); |
| 167 STATE_CASE(ACCOUNT_DELETED); | 167 STATE_CASE(ACCOUNT_DELETED); |
| 168 STATE_CASE(ACCOUNT_DISABLED); | 168 STATE_CASE(ACCOUNT_DISABLED); |
| 169 STATE_CASE(SERVICE_UNAVAILABLE); | 169 STATE_CASE(SERVICE_UNAVAILABLE); |
| 170 STATE_CASE(TWO_FACTOR); | 170 STATE_CASE(TWO_FACTOR); |
| 171 STATE_CASE(REQUEST_CANCELED); | 171 STATE_CASE(REQUEST_CANCELED); |
| 172 STATE_CASE(HOSTED_NOT_ALLOWED); | 172 STATE_CASE(HOSTED_NOT_ALLOWED); |
| 173 STATE_CASE(UNEXPECTED_SERVICE_RESPONSE); | 173 STATE_CASE(UNEXPECTED_SERVICE_RESPONSE); |
| 174 STATE_CASE(SERVICE_ERROR); | 174 STATE_CASE(SERVICE_ERROR); |
| 175 #undef STATE_CASE | 175 #undef STATE_CASE |
| 176 default: | 176 default: |
| 177 NOTREACHED(); | 177 NOTREACHED(); |
| 178 break; | 178 break; |
| 179 } | 179 } |
| 180 value->SetString("state", state_str); | 180 value->SetString("state", state_str); |
| 181 if (!error_message_.empty()) { | 181 if (!error_message_.empty()) { |
| 182 value->SetString("errorMessage", error_message_); | 182 value->SetString("errorMessage", error_message_); |
| 183 } | 183 } |
| 184 if (state_ == CAPTCHA_REQUIRED) { | 184 if (state_ == CAPTCHA_REQUIRED) { |
| 185 DictionaryValue* captcha_value = new DictionaryValue(); | 185 base::DictionaryValue* captcha_value = new base::DictionaryValue(); |
| 186 value->Set("captcha", captcha_value); | 186 value->Set("captcha", captcha_value); |
| 187 captcha_value->SetString("token", captcha_.token); | 187 captcha_value->SetString("token", captcha_.token); |
| 188 captcha_value->SetString("audioUrl", captcha_.audio_url.spec()); | 188 captcha_value->SetString("audioUrl", captcha_.audio_url.spec()); |
| 189 captcha_value->SetString("imageUrl", captcha_.image_url.spec()); | 189 captcha_value->SetString("imageUrl", captcha_.image_url.spec()); |
| 190 captcha_value->SetString("unlockUrl", captcha_.unlock_url.spec()); | 190 captcha_value->SetString("unlockUrl", captcha_.unlock_url.spec()); |
| 191 captcha_value->SetInteger("imageWidth", captcha_.image_width); | 191 captcha_value->SetInteger("imageWidth", captcha_.image_width); |
| 192 captcha_value->SetInteger("imageHeight", captcha_.image_height); | 192 captcha_value->SetInteger("imageHeight", captcha_.image_height); |
| 193 } else if (state_ == CONNECTION_FAILED) { | 193 } else if (state_ == CONNECTION_FAILED) { |
| 194 value->SetString("networkError", net::ErrorToString(network_error_)); | 194 value->SetString("networkError", net::ErrorToString(network_error_)); |
| 195 } else if (state_ == TWO_FACTOR) { | 195 } else if (state_ == TWO_FACTOR) { |
| 196 DictionaryValue* two_factor_value = new DictionaryValue(); | 196 base::DictionaryValue* two_factor_value = new base::DictionaryValue(); |
| 197 value->Set("two_factor", two_factor_value); | 197 value->Set("two_factor", two_factor_value); |
| 198 two_factor_value->SetString("token", second_factor_.token); | 198 two_factor_value->SetString("token", second_factor_.token); |
| 199 two_factor_value->SetString("promptText", second_factor_.prompt_text); | 199 two_factor_value->SetString("promptText", second_factor_.prompt_text); |
| 200 two_factor_value->SetString("alternateText", second_factor_.alternate_text); | 200 two_factor_value->SetString("alternateText", second_factor_.alternate_text); |
| 201 two_factor_value->SetInteger("fieldLength", second_factor_.field_length); | 201 two_factor_value->SetInteger("fieldLength", second_factor_.field_length); |
| 202 } | 202 } |
| 203 return value; | 203 return value; |
| 204 } | 204 } |
| 205 | 205 |
| 206 std::string GoogleServiceAuthError::ToString() const { | 206 std::string GoogleServiceAuthError::ToString() const { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 GoogleServiceAuthError::GoogleServiceAuthError( | 263 GoogleServiceAuthError::GoogleServiceAuthError( |
| 264 State s, | 264 State s, |
| 265 const std::string& captcha_token, | 265 const std::string& captcha_token, |
| 266 const std::string& prompt_text, | 266 const std::string& prompt_text, |
| 267 const std::string& alternate_text, | 267 const std::string& alternate_text, |
| 268 int field_length) | 268 int field_length) |
| 269 : state_(s), | 269 : state_(s), |
| 270 second_factor_(captcha_token, prompt_text, alternate_text, field_length), | 270 second_factor_(captcha_token, prompt_text, alternate_text, field_length), |
| 271 network_error_(0) { | 271 network_error_(0) { |
| 272 } | 272 } |
| OLD | NEW |