Commit e0e5ef0d authored by sadrul@chromium.org's avatar sadrul@chromium.org

chromeos: Use gfx::ImageSkia instead of SkBitmap for downloaded profile image.

BUG=141146

Review URL: https://chromiumcodereview.appspot.com/10832336

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@151895 0039d316-1c4b-4281-b951-d872f2087c98
parent 5db4a021
......@@ -59,7 +59,7 @@ class MockUserManager : public UserManager {
MOCK_METHOD1(AddObserver, void(UserManager::Observer*));
MOCK_METHOD1(RemoveObserver, void(UserManager::Observer*));
MOCK_METHOD0(NotifyLocalStateChanged, void(void));
MOCK_CONST_METHOD0(DownloadedProfileImage, const SkBitmap& (void));
MOCK_CONST_METHOD0(DownloadedProfileImage, const gfx::ImageSkia& (void));
// You can't mock this function easily because nobody can create User objects
// but the UserManagerImpl and us.
......
......@@ -13,10 +13,13 @@
#include "chrome/browser/chromeos/login/user.h"
#include "chrome/browser/ui/webui/options2/chromeos/set_wallpaper_options_handler.h"
class SkBitmap;
class FilePath;
class PrefService;
namespace gfx {
class ImageSkia;
}
namespace chromeos {
class RemoveUserDelegate;
......@@ -237,7 +240,7 @@ class UserManager {
// Returns the result of the last successful profile image download, if any.
// Otherwise, returns an empty bitmap.
virtual const SkBitmap& DownloadedProfileImage() const = 0;
virtual const gfx::ImageSkia& DownloadedProfileImage() const = 0;
};
} // namespace chromeos
......
......@@ -684,7 +684,7 @@ void UserManagerImpl::RemoveObserver(Observer* obs) {
observer_list_.RemoveObserver(obs);
}
const SkBitmap& UserManagerImpl::DownloadedProfileImage() const {
const gfx::ImageSkia& UserManagerImpl::DownloadedProfileImage() const {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
return downloaded_profile_image_;
}
......@@ -1110,7 +1110,7 @@ void UserManagerImpl::InitDownloadedProfileImage() {
VLOG(1) << "Profile image initialized";
downloaded_profile_image_ = logged_in_user_->image();
downloaded_profile_image_data_url_ =
web_ui_util::GetImageDataUrl(gfx::ImageSkia(downloaded_profile_image_));
web_ui_util::GetImageDataUrl(downloaded_profile_image_);
profile_image_url_ = logged_in_user_->image_url();
}
}
......@@ -1255,7 +1255,7 @@ void UserManagerImpl::OnProfileDownloadSuccess(ProfileDownloader* downloader) {
return;
downloaded_profile_image_data_url_ = new_image_data_url;
downloaded_profile_image_ = downloader->GetProfilePicture();
downloaded_profile_image_ = gfx::ImageSkia(downloader->GetProfilePicture());
profile_image_url_ = GURL(downloader->GetProfilePictureURL());
if (GetLoggedInUser().image_index() == User::kProfileImageIndex) {
......@@ -1267,13 +1267,10 @@ void UserManagerImpl::OnProfileDownloadSuccess(ProfileDownloader* downloader) {
SaveUserImageFromProfileImage(GetLoggedInUser().email());
}
// TODO(ivankr): temporary measure until UserManager is fully migrated
// to use ImageSkia instead of SkBitmap.
gfx::ImageSkia profile_image(downloaded_profile_image_);
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_PROFILE_IMAGE_UPDATED,
content::Source<UserManagerImpl>(this),
content::Details<const gfx::ImageSkia>(&profile_image));
content::Details<const gfx::ImageSkia>(&downloaded_profile_image_));
}
void UserManagerImpl::OnProfileDownloadFailure(ProfileDownloader* downloader) {
......
......@@ -24,6 +24,7 @@
#include "chrome/browser/sync/profile_sync_service_observer.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "ui/gfx/image/image_skia.h"
class SkBitmap;
class FilePath;
......@@ -94,7 +95,7 @@ class UserManagerImpl : public UserManager,
virtual void AddObserver(Observer* obs) OVERRIDE;
virtual void RemoveObserver(Observer* obs) OVERRIDE;
virtual void NotifyLocalStateChanged() OVERRIDE;
virtual const SkBitmap& DownloadedProfileImage() const OVERRIDE;
virtual const gfx::ImageSkia& DownloadedProfileImage() const OVERRIDE;
// content::NotificationObserver implementation.
virtual void Observe(int type,
......@@ -300,7 +301,7 @@ class UserManagerImpl : public UserManager,
bool last_image_set_async_;
// Result of the last successful profile image download, if any.
SkBitmap downloaded_profile_image_;
gfx::ImageSkia downloaded_profile_image_;
// Data URL for |downloaded_profile_image_|.
std::string downloaded_profile_image_data_url_;
......
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