Commit 2ece2cb9 authored by sail@chromium.org's avatar sail@chromium.org

Fix detection of default G+ profile picture

Currently we assume that any profile picture URL that contains "AAAAAAAAAAI/AAAAAAAAAAA" represents a default profile picture.

It turns out that this is incorrect. There are valid profile pictures with that URL.

With the OAuth user info API we can simply detect default profile pictures by the existance of the "picture" field in the returned data. Accounts with a default profile picture don't have this field.

BUG=106444
TEST=Compiled and verified that unit tests passed.


Review URL: http://codereview.chromium.org/8801023

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113487 0039d316-1c4b-4281-b951-d872f2087c98
parent 869a01e6
...@@ -64,12 +64,6 @@ const char kPicasaPhotoId[] = "AAAAAAAAAAA"; ...@@ -64,12 +64,6 @@ const char kPicasaPhotoId[] = "AAAAAAAAAAA";
// Photo version of the default PWA profile picture (base64 of 1). // Photo version of the default PWA profile picture (base64 of 1).
const char kDefaultPicasaPhotoVersion[] = "AAAAAAAAAAE"; const char kDefaultPicasaPhotoVersion[] = "AAAAAAAAAAE";
// Photo ID of the Google+ profile picture (base64 of 2).
const char kGooglePlusPhotoId[] = "AAAAAAAAAAI";
// Photo version of the default Google+ profile picture (base64 of 0).
const char kDefaultGooglePlusPhotoVersion[] = "AAAAAAAAAAA";
// The minimum number of path components in profile picture URL. // The minimum number of path components in profile picture URL.
const size_t kProfileImageURLPathComponentsCount = 6; const size_t kProfileImageURLPathComponentsCount = 6;
...@@ -192,12 +186,9 @@ bool ProfileDownloader::IsDefaultProfileImageURL(const std::string& url) { ...@@ -192,12 +186,9 @@ bool ProfileDownloader::IsDefaultProfileImageURL(const std::string& url) {
const std::string& photo_version = const std::string& photo_version =
path_components[kPhotoVersionPathComponentIndex]; path_components[kPhotoVersionPathComponentIndex];
// There are at least two pairs of (ID, version) for the default photo: // Check that the ID and version match the default Picasa profile photo.
// the default Google+ profile photo and the default Picasa profile photo. return photo_id == kPicasaPhotoId &&
return ((photo_id == kPicasaPhotoId && photo_version == kDefaultPicasaPhotoVersion;
photo_version == kDefaultPicasaPhotoVersion) ||
(photo_id == kGooglePlusPhotoId &&
photo_version == kDefaultGooglePlusPhotoVersion));
} }
ProfileDownloader::ProfileDownloader(ProfileDownloaderDelegate* delegate) ProfileDownloader::ProfileDownloader(ProfileDownloaderDelegate* delegate)
......
...@@ -90,8 +90,8 @@ TEST_F(ProfileDownloaderTest, DefaultURL) { ...@@ -90,8 +90,8 @@ TEST_F(ProfileDownloaderTest, DefaultURL) {
// Picasa default photo // Picasa default photo
EXPECT_TRUE(ProfileDownloader::IsDefaultProfileImageURL( EXPECT_TRUE(ProfileDownloader::IsDefaultProfileImageURL(
"https://example.com/-4/AAAAAAAAAAA/AAAAAAAAAAE/G/s64-c/photo.jpg")); "https://example.com/-4/AAAAAAAAAAA/AAAAAAAAAAE/G/s64-c/photo.jpg"));
// G+ default photo // Not default G+ photo
EXPECT_TRUE(ProfileDownloader::IsDefaultProfileImageURL( EXPECT_FALSE(ProfileDownloader::IsDefaultProfileImageURL(
"https://example.com/-4/AAAAAAAAAAI/AAAAAAAAAAA/G/photo.jpg")); "https://example.com/-4/AAAAAAAAAAI/AAAAAAAAAAA/G/photo.jpg"));
// Not default with 6 components // Not default with 6 components
EXPECT_FALSE(ProfileDownloader::IsDefaultProfileImageURL( EXPECT_FALSE(ProfileDownloader::IsDefaultProfileImageURL(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment