Index: chrome/browser/ui/webui/options2/chromeos/user_image_source2.cc |
diff --git a/chrome/browser/ui/webui/options2/chromeos/user_image_source2.cc b/chrome/browser/ui/webui/options2/chromeos/user_image_source2.cc |
index 73d2d1f4b4ec38ae1dc278e7bc2a2131405c1f65..67deb512c7a8f7bd4da5512a0ff4b604d526e1af 100644 |
--- a/chrome/browser/ui/webui/options2/chromeos/user_image_source2.cc |
+++ b/chrome/browser/ui/webui/options2/chromeos/user_image_source2.cc |
@@ -6,69 +6,21 @@ |
#include "base/memory/ref_counted_memory.h" |
#include "base/message_loop.h" |
-#include "base/string_split.h" |
#include "chrome/browser/chromeos/login/user_manager.h" |
#include "chrome/common/url_constants.h" |
-#include "googleurl/src/url_parse.h" |
#include "grit/theme_resources.h" |
#include "ui/base/resource/resource_bundle.h" |
#include "ui/gfx/codec/png_codec.h" |
-namespace { |
- |
-// Animated key is used in user image URL requests to specify that |
-// animated version of user image is required. Without that key |
-// non-animated version of user image should be returned. |
-const char kKeyAnimated[] = "animated"; |
- |
-// Extracts from user image request user email and type of requested |
-// image (animated or non-animated). |path| is an user image request |
-// and should look like "username@host?key1=value1&...&key_n=value_n". |
-// So, "username@host" is stored into |email|. If a query part of |
-// |path| contains "animated" key, |is_image_animated| is set to true, |
-// otherwise |is_image_animated| is set to false. |
-void ParseRequest(const std::string& path, |
- std::string* email, |
- bool* is_image_animated) { |
- url_parse::Parsed parsed; |
- url_parse::ParseStandardURL(path.c_str(), path.size(), &parsed); |
- DCHECK(parsed.username.is_valid()); |
- DCHECK(parsed.host.is_valid()); |
- |
- DCHECK(email != NULL); |
- *email = path.substr(parsed.username.begin, parsed.username.len); |
- email->append("@"); |
- email->append(path.substr(parsed.host.begin, parsed.host.len)); |
- |
- if (parsed.query.is_valid()) { |
- url_parse::Component query = parsed.query; |
- url_parse::Component key, value; |
- |
- DCHECK(is_image_animated != NULL); |
- *is_image_animated = false; |
- while (ExtractQueryKeyValue(path.c_str(), &query, &key, &value)) { |
- if (path.substr(key.begin, key.len) == kKeyAnimated) { |
- *is_image_animated = true; |
- break; |
- } |
- } |
- } |
-} |
- |
-} // namespace |
- |
namespace chromeos { |
namespace options2 { |
std::vector<unsigned char> UserImageSource::GetUserImage( |
- const std::string& email, bool is_image_animated) const { |
+ const std::string& email) const { |
std::vector<unsigned char> user_image; |
const chromeos::User* user = chromeos::UserManager::Get()->FindUser(email); |
if (user) { |
- if (user->has_animated_image() && is_image_animated) |
- user->GetAnimatedImage(&user_image); |
- else |
- gfx::PNGCodec::EncodeBGRASkBitmap(user->image(), false, &user_image); |
+ gfx::PNGCodec::EncodeBGRASkBitmap(user->image(), false, &user_image); |
return user_image; |
} |
gfx::PNGCodec::EncodeBGRASkBitmap( |
@@ -88,26 +40,15 @@ UserImageSource::~UserImageSource() {} |
void UserImageSource::StartDataRequest(const std::string& path, |
bool is_incognito, |
int request_id) { |
- std::string email; |
- bool is_image_animated; |
- ParseRequest(path, &email, &is_image_animated); |
- |
- std::vector<unsigned char> image = GetUserImage(email, is_image_animated); |
- SendResponse(request_id, new base::RefCountedBytes(image)); |
+ // Strip the query param value - we only use it as a hack to ensure our |
+ // image gets reloaded instead of being pulled from the browser cache |
+ std::string email = path.substr(0, path.find_first_of("?")); |
+ SendResponse(request_id, new base::RefCountedBytes(GetUserImage(email))); |
} |
-std::string UserImageSource::GetMimeType(const std::string& path) const { |
+std::string UserImageSource::GetMimeType(const std::string&) const { |
// We need to explicitly return a mime type, otherwise if the user tries to |
// drag the image they get no extension. |
- std::string email; |
- bool is_image_animated; |
- ParseRequest(path, &email, &is_image_animated); |
- |
- if (is_image_animated) { |
- const chromeos::User* user = chromeos::UserManager::Get()->FindUser(email); |
- if (user && user->has_animated_image()) |
- return "image/gif"; |
- } |
return "image/png"; |
} |