| 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 "components/policy/core/common/cloud/user_info_fetcher.h" | 5 #include "components/policy/core/common/cloud/user_info_fetcher.h" |
| 6 | 6 |
| 7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 if (error.state() != GoogleServiceAuthError::NONE) { | 71 if (error.state() != GoogleServiceAuthError::NONE) { |
| 72 delegate_->OnGetUserInfoFailure(error); | 72 delegate_->OnGetUserInfoFailure(error); |
| 73 return; | 73 return; |
| 74 } | 74 } |
| 75 | 75 |
| 76 // Successfully fetched userinfo from the server - parse it and hand it off | 76 // Successfully fetched userinfo from the server - parse it and hand it off |
| 77 // to the delegate. | 77 // to the delegate. |
| 78 std::string unparsed_data; | 78 std::string unparsed_data; |
| 79 source->GetResponseAsString(&unparsed_data); | 79 source->GetResponseAsString(&unparsed_data); |
| 80 DVLOG(1) << "Received UserInfo response: " << unparsed_data; | 80 DVLOG(1) << "Received UserInfo response: " << unparsed_data; |
| 81 scoped_ptr<base::Value> parsed_value = base::JSONReader::Read(unparsed_data); | 81 std::unique_ptr<base::Value> parsed_value = |
| 82 base::JSONReader::Read(unparsed_data); |
| 82 base::DictionaryValue* dict; | 83 base::DictionaryValue* dict; |
| 83 if (parsed_value.get() && parsed_value->GetAsDictionary(&dict)) { | 84 if (parsed_value.get() && parsed_value->GetAsDictionary(&dict)) { |
| 84 delegate_->OnGetUserInfoSuccess(dict); | 85 delegate_->OnGetUserInfoSuccess(dict); |
| 85 } else { | 86 } else { |
| 86 NOTREACHED() << "Could not parse userinfo response from server"; | 87 NOTREACHED() << "Could not parse userinfo response from server"; |
| 87 delegate_->OnGetUserInfoFailure(GoogleServiceAuthError( | 88 delegate_->OnGetUserInfoFailure(GoogleServiceAuthError( |
| 88 GoogleServiceAuthError::CONNECTION_FAILED)); | 89 GoogleServiceAuthError::CONNECTION_FAILED)); |
| 89 } | 90 } |
| 90 } | 91 } |
| 91 | 92 |
| 92 }; // namespace policy | 93 }; // namespace policy |
| OLD | NEW |