Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3289)

Unified Diff: chrome/browser/chromeos/login/profile_image_downloader.cc

Issue 8399005: [cros] Don't succeed if user has default profile picturewq (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed stats for change picture options Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..e9e6833ff3173818188da5c923193adf787e5f73 100644
--- a/chrome/browser/chromeos/login/profile_image_downloader.cc
+++ b/chrome/browser/chromeos/login/profile_image_downloader.cc
@@ -4,11 +4,13 @@
#include "chrome/browser/chromeos/login/profile_image_downloader.h"
+#include <string>
#include <vector>
#include "base/json/json_reader.h"
#include "base/logging.h"
#include "base/message_loop.h"
+#include "base/string_split.h"
#include "base/string_util.h"
#include "base/stringprintf.h"
#include "chrome/browser/chromeos/login/helper.h"
@@ -44,6 +46,27 @@ const char kThumbnailSizeFormat[] = "s%d-c";
// Default Picasa thumbnail size.
const int kDefaultThumbnailSize = 64;
+// Separator of URL path components.
+const char kURLPathSeparator = '/';
+
+// Photo ID of old low-res default profile picture (base64 of 0).
+const char kOldDefaultPhotoId[] = "AAAAAAAAAAA";
+
+// Current photo ID of the current profile picture (base64 of 2).
+const char kDefaultPhotoId[] = "AAAAAAAAAAI";
+
+// Photo version of the current profile picture (base64 of 0).
+const char kDefaultPhotoVersion[] = "AAAAAAAAAAA";
+
+// Number of path components in profile picture URL.
+const size_t kProfileImageURLPathComponentsCount = 7;
+
+// Index of path component with photo ID.
+const int kPhotoIdPathComponentIndex = 2;
+
+// Index of path component with photo version.
+const int kPhotoVersionPathComponentIndex = 3;
+
} // namespace
std::string ProfileImageDownloader::GetProfileImageURL(
@@ -105,6 +128,28 @@ 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());
+ VLOG(1) << "URL to check for default image: " << image_url_object.spec();
+ std::vector<std::string> path_components;
+ base::SplitString(image_url_object.path(),
+ kURLPathSeparator,
+ &path_components);
+
+ if (path_components.size() != kProfileImageURLPathComponentsCount)
+ return false;
+
+ const std::string& photo_id = path_components[kPhotoIdPathComponentIndex];
+ const std::string& photo_version =
+ path_components[kPhotoVersionPathComponentIndex];
+ return (photo_id == kOldDefaultPhotoId) ||
+ (photo_id == kDefaultPhotoId &&
+ photo_version == kDefaultPhotoVersion);
+}
+
ProfileImageDownloader::ProfileImageDownloader(Delegate* delegate)
: delegate_(delegate) {
}
@@ -175,6 +220,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));
« no previous file with comments | « chrome/browser/chromeos/login/profile_image_downloader.h ('k') | chrome/browser/chromeos/login/user_image_screen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698