Chromium Code Reviews| Index: chrome/browser/profiles/profile_downloader.h |
| diff --git a/chrome/browser/chromeos/login/profile_image_downloader.h b/chrome/browser/profiles/profile_downloader.h |
| similarity index 50% |
| rename from chrome/browser/chromeos/login/profile_image_downloader.h |
| rename to chrome/browser/profiles/profile_downloader.h |
| index 8701b343e0aff683a5c8b48ed01438f9011d405f..74e6e9ff608eeda5be28effd238352c32bd28e34 100644 |
| --- a/chrome/browser/chromeos/login/profile_image_downloader.h |
| +++ b/chrome/browser/profiles/profile_downloader.h |
| @@ -2,63 +2,47 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#ifndef CHROME_BROWSER_CHROMEOS_LOGIN_PROFILE_IMAGE_DOWNLOADER_H_ |
| -#define CHROME_BROWSER_CHROMEOS_LOGIN_PROFILE_IMAGE_DOWNLOADER_H_ |
| +#ifndef CHROME_BROWSER_PROFILES_PROFILE_DOWNLOADER_H_ |
| +#define CHROME_BROWSER_PROFILES_PROFILE_DOWNLOADER_H_ |
| #pragma once |
| #include <string> |
| #include "base/basictypes.h" |
| #include "base/memory/scoped_ptr.h" |
| -#include "chrome/browser/chromeos/login/image_decoder.h" |
| +#include "base/string16.h" |
| +#include "chrome/browser/image_decoder.h" |
| #include "content/public/browser/notification_observer.h" |
| #include "content/public/browser/notification_registrar.h" |
| #include "content/public/common/url_fetcher_delegate.h" |
| #include "googleurl/src/gurl.h" |
| +#include "third_party/skia/include/core/SkBitmap.h" |
| -namespace chromeos { |
| +class ProfileDownloaderDelegate; |
| -// Downloads user profile image, decodes it in a sandboxed process. |
| -class ProfileImageDownloader : public content::URLFetcherDelegate, |
| - public ImageDecoder::Delegate, |
| - public content::NotificationObserver { |
| +// Downloads user profile information. The profile picture is decoded in a |
| +// sandboxed process. |
| +class ProfileDownloader : public content::URLFetcherDelegate, |
| + public ImageDecoder::Delegate, |
| + public content::NotificationObserver { |
| public: |
| - // Enum for reporting histograms about profile picture download. |
| - enum DownloadResult { |
| - kDownloadSuccessChanged, |
| - kDownloadSuccess, |
| - kDownloadFailure, |
| - kDownloadDefault, |
| - |
| - // Must be the last, convenient count. |
| - kDownloadResultsCount |
| - }; |
| - |
| - // Reports on success or failure of Profile image download. It is OK to |
| - // delete the |ProfileImageDownloader| instance in any of these handlers. |
| - class Delegate { |
| - public: |
| - virtual ~Delegate() {} |
| - |
| - // Called when image is successfully downloaded and decoded. |
| - virtual void OnDownloadSuccess(const SkBitmap& image) = 0; |
| - |
| - // Called on download failure. |
| - virtual void OnDownloadFailure() {} |
| - |
| - // Called when user has the default profile image and we won't download |
| - // it. |
| - virtual void OnDownloadDefaultImage() {} |
| - }; |
| - |
| - explicit ProfileImageDownloader(Delegate* delegate); |
| - virtual ~ProfileImageDownloader(); |
| + explicit ProfileDownloader(ProfileDownloaderDelegate* delegate); |
| + virtual ~ProfileDownloader(); |
| // Starts downloading the picture if the necessary authorization token is |
|
Ivan Korotkov
2011/11/17 08:37:12
Starts downloading profile information... ?
sail
2011/11/21 22:01:00
Done.
|
| // ready. If not, subscribes to token service and starts fetching if the |
| // token is available. Should not be called more than once. |
| void Start(); |
| + // On successful download this returns the full name of the user. For example |
| + // "Pat Smith". |
| + const string16& GetProfileFullName() const; |
|
Ivan Korotkov
2011/11/17 08:37:12
These are simple getters. Unless you're planning t
sail
2011/11/21 22:01:00
Yea, this will have to be virtual eventually. I sh
|
| + |
| + // On successful download this returns the profile picture of the user. |
| + // For users with no profile picture set (that is, they have the default |
| + // profile picture) this will return an Null bitmap. |
| + const SkBitmap& GetProfilePicture() const; |
| + |
| private: |
| // Overriden from content::URLFetcherDelegate: |
| virtual void OnURLFetchComplete(const content::URLFetcher* source) OVERRIDE; |
| @@ -73,9 +57,11 @@ class ProfileImageDownloader : public content::URLFetcherDelegate, |
| const content::NotificationSource& source, |
| const content::NotificationDetails& details) OVERRIDE; |
| - // Searches for profile image URL in user entry response from Picasa. |
| - // Returns an empty string on failure. |
| - std::string GetProfileImageURL(const std::string& data) const; |
| + // Parses the entry response from Picasa and gets the nick name and |
| + // and profile image URL. Returns false to indicate a parsing error. |
| + bool GetProfileNickNameAndImageURL(const std::string& data, |
| + string16* nick_name, |
| + std::string* url) const; |
| // Returns true if the image url is url of the default profile picture. |
| bool IsDefaultProfileImageURL(const std::string& url) const; |
| @@ -83,15 +69,15 @@ class ProfileImageDownloader : public content::URLFetcherDelegate, |
| // Issues the first request to get user profile image. |
| void StartFetchingImage(); |
| - Delegate* delegate_; |
| + ProfileDownloaderDelegate* delegate_; |
| std::string auth_token_; |
| scoped_ptr<content::URLFetcher> user_entry_fetcher_; |
| scoped_ptr<content::URLFetcher> profile_image_fetcher_; |
| content::NotificationRegistrar registrar_; |
| + string16 profile_full_name_; |
| + SkBitmap profile_picture_; |
| - DISALLOW_COPY_AND_ASSIGN(ProfileImageDownloader); |
| + DISALLOW_COPY_AND_ASSIGN(ProfileDownloader); |
| }; |
| -} // namespace chromeos |
| - |
| -#endif // CHROME_BROWSER_CHROMEOS_LOGIN_PROFILE_IMAGE_DOWNLOADER_H_ |
| +#endif // CHROME_BROWSER_PROFILES_PROFILE_DOWNLOADER_H_ |