| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/chromeos/login/user_image_downloader.h" | 5 #include "chrome/browser/chromeos/login/user_image_downloader.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/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 const char kPhotoSchemaURL[] = | 33 const char kPhotoSchemaURL[] = |
| 34 "http://schemas.google.com/contacts/2008/rel#photo"; | 34 "http://schemas.google.com/contacts/2008/rel#photo"; |
| 35 | 35 |
| 36 } // namespace | 36 } // namespace |
| 37 | 37 |
| 38 UserImageDownloader::UserImageDownloader(const std::string& username, | 38 UserImageDownloader::UserImageDownloader(const std::string& username, |
| 39 const std::string& auth_token) | 39 const std::string& auth_token) |
| 40 : username_(username), | 40 : username_(username), |
| 41 auth_token_(auth_token) { | 41 auth_token_(auth_token) { |
| 42 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); | 42 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); |
| 43 if (auth_token_.empty()) | 43 if (auth_token.empty()) |
| 44 return; | 44 return; |
| 45 | 45 |
| 46 profile_fetcher_.reset(new URLFetcher(GURL(kUserInfoURL), | 46 profile_fetcher_.reset(new URLFetcher(GURL(kUserInfoURL), |
| 47 URLFetcher::GET, | 47 URLFetcher::GET, |
| 48 this)); | 48 this)); |
| 49 profile_fetcher_->set_request_context( | 49 profile_fetcher_->set_request_context( |
| 50 ProfileManager::GetDefaultProfile()->GetRequestContext()); | 50 ProfileManager::GetDefaultProfile()->GetRequestContext()); |
| 51 profile_fetcher_->set_extra_request_headers( | 51 profile_fetcher_->set_extra_request_headers( |
| 52 StringPrintf(kAuthorizationHeader, auth_token_.c_str())); | 52 StringPrintf(kAuthorizationHeader, auth_token.c_str())); |
| 53 profile_fetcher_->Start(); | 53 profile_fetcher_->Start(); |
| 54 } | 54 } |
| 55 | 55 |
| 56 UserImageDownloader::~UserImageDownloader() { | 56 UserImageDownloader::~UserImageDownloader() { |
| 57 } | 57 } |
| 58 | 58 |
| 59 void UserImageDownloader::OnURLFetchComplete(const URLFetcher* source, | 59 void UserImageDownloader::OnURLFetchComplete(const URLFetcher* source, |
| 60 const GURL& url, | 60 const GURL& url, |
| 61 const URLRequestStatus& status, | 61 const URLRequestStatus& status, |
| 62 int response_code, | 62 int response_code, |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 continue; | 207 continue; |
| 208 | 208 |
| 209 *image_url = GURL(url); | 209 *image_url = GURL(url); |
| 210 return true; | 210 return true; |
| 211 } | 211 } |
| 212 return false; | 212 return false; |
| 213 } | 213 } |
| 214 | 214 |
| 215 } // namespace chromeos | 215 } // namespace chromeos |
| 216 | 216 |
| OLD | NEW |