Chromium Code Reviews| Index: chrome/browser/chromeos/login/profile_image_downloader.cc |
| diff --git a/chrome/browser/chromeos/login/profile_image_downloader.cc b/chrome/browser/chromeos/login/profile_image_downloader.cc |
| index 6093feff6c24ffb0280d73dfe0fbf0b355b5b0db..5a292d5041218c7d7c1071a9ee16f43b961c2396 100644 |
| --- a/chrome/browser/chromeos/login/profile_image_downloader.cc |
| +++ b/chrome/browser/chromeos/login/profile_image_downloader.cc |
| @@ -44,6 +44,12 @@ const char kThumbnailSizeFormat[] = "s%d-c"; |
| // Default Picasa thumbnail size. |
| const int kDefaultThumbnailSize = 64; |
| +// Path components that identify the default profile picture. |
| +const char* kDefaultProfileImagePathComponents[] = { |
| + "/AAAAAAAAAAI/AAAAAAAAAAA/", |
| + "/AAAAAAAAAA/" |
| +}; |
| + |
| } // namespace |
| std::string ProfileImageDownloader::GetProfileImageURL( |
| @@ -105,6 +111,21 @@ std::string ProfileImageDownloader::GetProfileImageURL( |
| return thumbnail_url.spec(); |
| } |
| +bool ProfileImageDownloader::IsDefaultProfileImageURL( |
| + const std::string& url) const { |
| + GURL image_url_object(url); |
| + DCHECK(image_url_object.is_valid()); |
| + for (size_t i = 0; |
| + i < arraysize(kDefaultProfileImagePathComponents); |
| + ++i) { |
| + const char* component = |
| + kDefaultProfileImagePathComponents[i]; |
| + if (image_url_object.path().find(component) != std::string::npos) |
|
Ivan Korotkov
2011/10/26 20:43:57
This will match /AAAAAAAAAA/ anywhere in the path.
whywhat
2011/10/27 13:28:10
Done.
|
| + return true; |
| + } |
| + return false; |
| +} |
| + |
| ProfileImageDownloader::ProfileImageDownloader(Delegate* delegate) |
| : delegate_(delegate) { |
| } |
| @@ -175,6 +196,11 @@ void ProfileImageDownloader::OnURLFetchComplete( |
| delegate_->OnDownloadFailure(); |
| return; |
| } |
| + if (IsDefaultProfileImageURL(image_url)) { |
| + if (delegate_) |
| + delegate_->OnDownloadDefaultImage(); |
| + return; |
| + } |
| VLOG(1) << "Fetching profile image from " << image_url; |
| profile_image_fetcher_.reset(content::URLFetcher::Create( |
| GURL(image_url), content::URLFetcher::GET, this)); |