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/cloud/user_info_fetcher.h" | 5 #include "chrome/browser/policy/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/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
11 #include "google_apis/gaia/gaia_urls.h" | 11 #include "google_apis/gaia/gaia_urls.h" |
12 #include "google_apis/gaia/google_service_auth_error.h" | 12 #include "google_apis/gaia/google_service_auth_error.h" |
13 #include "googleurl/src/gurl.h" | 13 #include "googleurl/src/gurl.h" |
14 #include "net/base/load_flags.h" | 14 #include "net/base/load_flags.h" |
15 #include "net/http/http_status_code.h" | 15 #include "net/http/http_status_code.h" |
16 #include "net/url_request/url_fetcher.h" | 16 #include "net/url_request/url_fetcher.h" |
17 #include "net/url_request/url_request_status.h" | 17 #include "net/url_request/url_request_status.h" |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
21 static const char kAuthorizationHeaderFormat[] = | 21 static const char kAuthorizationHeaderFormat[] = |
22 "Authorization: Bearer %s"; | 22 "Authorization: Bearer %s"; |
23 | 23 |
24 static std::string MakeAuthorizationHeader(const std::string& auth_token) { | 24 static std::string MakeAuthorizationHeader(const std::string& auth_token) { |
25 return StringPrintf(kAuthorizationHeaderFormat, auth_token.c_str()); | 25 return base::StringPrintf(kAuthorizationHeaderFormat, auth_token.c_str()); |
26 } | 26 } |
27 | 27 |
28 } // namespace | 28 } // namespace |
29 | 29 |
30 namespace policy { | 30 namespace policy { |
31 | 31 |
32 UserInfoFetcher::UserInfoFetcher(Delegate* delegate, | 32 UserInfoFetcher::UserInfoFetcher(Delegate* delegate, |
33 net::URLRequestContextGetter* context) | 33 net::URLRequestContextGetter* context) |
34 : delegate_(delegate), | 34 : delegate_(delegate), |
35 context_(context) { | 35 context_(context) { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 |