Chromium Code Reviews| Index: chrome/browser/gaia_userinfo/profile_downloader.h |
| diff --git a/chrome/browser/chromeos/login/profile_image_downloader.h b/chrome/browser/gaia_userinfo/profile_downloader.h |
| similarity index 57% |
| rename from chrome/browser/chromeos/login/profile_image_downloader.h |
| rename to chrome/browser/gaia_userinfo/profile_downloader.h |
| index 8701b343e0aff683a5c8b48ed01438f9011d405f..4f00ba3fd55b6167eebe4f8df187161f2aba607f 100644 |
| --- a/chrome/browser/chromeos/login/profile_image_downloader.h |
| +++ b/chrome/browser/gaia_userinfo/profile_downloader.h |
| @@ -2,26 +2,25 @@ |
| // 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_GAIA_USERINFO_PROFILE_DOWNLOADER_H_ |
| +#define CHROME_BROWSER_GAIA_USERINFO_PROFILE_DOWNLOADER_H_ |
| #pragma once |
| -#include <string> |
|
whywhat
2011/11/15 12:19:21
I think this header belongs here.
sail
2011/11/15 20:17:22
Done.
|
| - |
| #include "base/basictypes.h" |
| #include "base/memory/scoped_ptr.h" |
| -#include "chrome/browser/chromeos/login/image_decoder.h" |
| +#include "chrome/browser/gaia_userinfo/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" |
| -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 { |
| @@ -34,25 +33,8 @@ class ProfileImageDownloader : public content::URLFetcherDelegate, |
| 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(Delegate* delegate); |
| + virtual ~ProfileDownloader(); |
| // Starts downloading the picture if the necessary authorization token is |
| // ready. If not, subscribes to token service and starts fetching if the |
| @@ -73,9 +55,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. Return value is set to empty on failure. |
| + void GetProfileNickNameAndImageURL(const std::string& data, |
|
Ivan Korotkov
2011/11/15 11:05:08
What about returning bool to indicate parsing erro
sail
2011/11/15 20:17:22
Done.
|
| + string16* nick_name, |
| + std::string* url); |
| // Returns true if the image url is url of the default profile picture. |
| bool IsDefaultProfileImageURL(const std::string& url) const; |
| @@ -88,10 +72,9 @@ class ProfileImageDownloader : public content::URLFetcherDelegate, |
| scoped_ptr<content::URLFetcher> user_entry_fetcher_; |
| scoped_ptr<content::URLFetcher> profile_image_fetcher_; |
| content::NotificationRegistrar registrar_; |
| + string16 full_name_; |
|
whywhat
2011/11/15 12:19:21
nit: you should include "base/string16.h" for this
sail
2011/11/15 20:17:22
Done.
|
| - DISALLOW_COPY_AND_ASSIGN(ProfileImageDownloader); |
| + DISALLOW_COPY_AND_ASSIGN(ProfileDownloader); |
| }; |
| -} // namespace chromeos |
| - |
| -#endif // CHROME_BROWSER_CHROMEOS_LOGIN_PROFILE_IMAGE_DOWNLOADER_H_ |
| +#endif // CHROME_BROWSER_GAIA_USERINFO_PROFILE_DOWNLOADER_H_ |