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 "chrome/browser/policy/user_info_fetcher.h" | 5 #include "chrome/browser/policy/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/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 net::URLFetcher::GET, this)); | 46 net::URLFetcher::GET, this)); |
47 url_fetcher_->SetRequestContext(context_); | 47 url_fetcher_->SetRequestContext(context_); |
48 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | | 48 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | |
49 net::LOAD_DO_NOT_SAVE_COOKIES); | 49 net::LOAD_DO_NOT_SAVE_COOKIES); |
50 url_fetcher_->AddExtraRequestHeader(MakeAuthorizationHeader(access_token)); | 50 url_fetcher_->AddExtraRequestHeader(MakeAuthorizationHeader(access_token)); |
51 url_fetcher_->Start(); // Results in a call to OnURLFetchComplete(). | 51 url_fetcher_->Start(); // Results in a call to OnURLFetchComplete(). |
52 } | 52 } |
53 | 53 |
54 void UserInfoFetcher::OnURLFetchComplete(const net::URLFetcher* source) { | 54 void UserInfoFetcher::OnURLFetchComplete(const net::URLFetcher* source) { |
55 net::URLRequestStatus status = source->GetStatus(); | 55 net::URLRequestStatus status = source->GetStatus(); |
56 GoogleServiceAuthError error = GoogleServiceAuthError::None(); | 56 GoogleServiceAuthError error = GoogleServiceAuthError::AuthErrorNone(); |
57 if (!status.is_success()) { | 57 if (!status.is_success()) { |
58 if (status.status() == net::URLRequestStatus::CANCELED) | 58 if (status.status() == net::URLRequestStatus::CANCELED) |
59 error = GoogleServiceAuthError(GoogleServiceAuthError::REQUEST_CANCELED); | 59 error = GoogleServiceAuthError(GoogleServiceAuthError::REQUEST_CANCELED); |
60 else | 60 else |
61 error = GoogleServiceAuthError::FromConnectionError(status.error()); | 61 error = GoogleServiceAuthError::FromConnectionError(status.error()); |
62 } else if (source->GetResponseCode() != net::HTTP_OK) { | 62 } else if (source->GetResponseCode() != net::HTTP_OK) { |
63 DLOG(WARNING) << "UserInfo request failed with HTTP code: " | 63 DLOG(WARNING) << "UserInfo request failed with HTTP code: " |
64 << source->GetResponseCode(); | 64 << source->GetResponseCode(); |
65 error = GoogleServiceAuthError( | 65 error = GoogleServiceAuthError( |
66 GoogleServiceAuthError::CONNECTION_FAILED); | 66 GoogleServiceAuthError::CONNECTION_FAILED); |
(...skipping 13 matching lines...) Expand all Loading... |
80 if (parsed_value.get() && parsed_value->GetAsDictionary(&dict)) { | 80 if (parsed_value.get() && parsed_value->GetAsDictionary(&dict)) { |
81 delegate_->OnGetUserInfoSuccess(dict); | 81 delegate_->OnGetUserInfoSuccess(dict); |
82 } else { | 82 } else { |
83 NOTREACHED() << "Could not parse userinfo response from server"; | 83 NOTREACHED() << "Could not parse userinfo response from server"; |
84 delegate_->OnGetUserInfoFailure(GoogleServiceAuthError( | 84 delegate_->OnGetUserInfoFailure(GoogleServiceAuthError( |
85 GoogleServiceAuthError::CONNECTION_FAILED)); | 85 GoogleServiceAuthError::CONNECTION_FAILED)); |
86 } | 86 } |
87 } | 87 } |
88 | 88 |
89 }; // namespace policy | 89 }; // namespace policy |
OLD | NEW |