Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_PROFILES_PROFILE_DOWNLOADER_H_ | 5 #ifndef CHROME_BROWSER_PROFILES_PROFILE_DOWNLOADER_H_ |
| 6 #define CHROME_BROWSER_PROFILES_PROFILE_DOWNLOADER_H_ | 6 #define CHROME_BROWSER_PROFILES_PROFILE_DOWNLOADER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/string16.h" | 13 #include "base/string16.h" |
| 14 #include "chrome/browser/image_decoder.h" | 14 #include "chrome/browser/image_decoder.h" |
| 15 #include "content/public/browser/notification_observer.h" | 15 #include "content/public/browser/notification_observer.h" |
| 16 #include "content/public/browser/notification_registrar.h" | 16 #include "content/public/browser/notification_registrar.h" |
| 17 #include "content/public/common/url_fetcher_delegate.h" | 17 #include "content/public/common/url_fetcher_delegate.h" |
| 18 #include "googleurl/src/gurl.h" | 18 #include "googleurl/src/gurl.h" |
| 19 #include "third_party/skia/include/core/SkBitmap.h" | 19 #include "third_party/skia/include/core/SkBitmap.h" |
| 20 | 20 |
| 21 class ProfileDownloaderDelegate; | 21 class ProfileDownloaderDelegate; |
| 22 | 22 |
| 23 // Downloads user profile information. The profile picture is decoded in a | 23 // Downloads user profile information. The profile picture is decoded in a |
| 24 // sandboxed process. | 24 // sandboxed process. |
| 25 class ProfileDownloader : public content::URLFetcherDelegate, | 25 class ProfileDownloader : public content::URLFetcherDelegate, |
| 26 public ImageDecoder::Delegate, | 26 public ImageDecoder::Delegate, |
| 27 public content::NotificationObserver { | 27 public content::NotificationObserver { |
| 28 public: | 28 public: |
| 29 enum PictureResult { | |
|
Ivan Korotkov
2011/11/30 14:35:44
[here and in other names] "picture result" sounds
sail
2011/11/30 19:00:23
Done. Changed to PictureStatus
| |
| 30 PICTURE_SUCCESS, | |
| 31 PICTURE_FAILED, | |
| 32 PICTURE_DEFAULT, | |
| 33 PICTURE_CACHED, | |
| 34 }; | |
| 35 | |
| 29 explicit ProfileDownloader(ProfileDownloaderDelegate* delegate); | 36 explicit ProfileDownloader(ProfileDownloaderDelegate* delegate); |
| 30 virtual ~ProfileDownloader(); | 37 virtual ~ProfileDownloader(); |
| 31 | 38 |
| 32 // Starts downloading profile information if the necessary authorization token | 39 // Starts downloading profile information if the necessary authorization token |
| 33 // is ready. If not, subscribes to token service and starts fetching if the | 40 // is ready. If not, subscribes to token service and starts fetching if the |
| 34 // token is available. Should not be called more than once. | 41 // token is available. Should not be called more than once. |
| 35 virtual void Start(); | 42 virtual void Start(); |
| 36 | 43 |
| 37 // On successful download this returns the full name of the user. For example | 44 // On successful download this returns the full name of the user. For example |
| 38 // "Pat Smith". | 45 // "Pat Smith". |
| 39 virtual string16 GetProfileFullName() const; | 46 virtual string16 GetProfileFullName() const; |
| 40 | 47 |
| 41 // On successful download this returns the profile picture of the user. | 48 // On successful download this returns the profile picture of the user. |
| 42 // For users with no profile picture set (that is, they have the default | 49 // For users with no profile picture set (that is, they have the default |
| 43 // profile picture) this will return an Null bitmap. | 50 // profile picture) this will return an Null bitmap. |
| 44 virtual SkBitmap GetProfilePicture() const; | 51 virtual SkBitmap GetProfilePicture() const; |
| 45 | 52 |
| 53 // Gets the profile picture result. | |
| 54 virtual PictureResult GetProfilePictureResult() const; | |
| 55 | |
| 56 // Gets the URL for the profile picture. | |
|
Ivan Korotkov
2011/11/30 14:35:44
Please document when (for which values of PictureR
sail
2011/11/30 19:00:23
Done.
| |
| 57 virtual std::string GetProfilePictureURL() const; | |
| 58 | |
| 46 private: | 59 private: |
| 47 // Overriden from content::URLFetcherDelegate: | 60 // Overriden from content::URLFetcherDelegate: |
| 48 virtual void OnURLFetchComplete(const content::URLFetcher* source) OVERRIDE; | 61 virtual void OnURLFetchComplete(const content::URLFetcher* source) OVERRIDE; |
| 49 | 62 |
| 50 // Overriden from ImageDecoder::Delegate: | 63 // Overriden from ImageDecoder::Delegate: |
| 51 virtual void OnImageDecoded(const ImageDecoder* decoder, | 64 virtual void OnImageDecoded(const ImageDecoder* decoder, |
| 52 const SkBitmap& decoded_image) OVERRIDE; | 65 const SkBitmap& decoded_image) OVERRIDE; |
| 53 virtual void OnDecodeImageFailed(const ImageDecoder* decoder) OVERRIDE; | 66 virtual void OnDecodeImageFailed(const ImageDecoder* decoder) OVERRIDE; |
| 54 | 67 |
| 55 // Overriden from content::NotificationObserver: | 68 // Overriden from content::NotificationObserver: |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 69 // Issues the first request to get user profile image. | 82 // Issues the first request to get user profile image. |
| 70 void StartFetchingImage(); | 83 void StartFetchingImage(); |
| 71 | 84 |
| 72 ProfileDownloaderDelegate* delegate_; | 85 ProfileDownloaderDelegate* delegate_; |
| 73 std::string auth_token_; | 86 std::string auth_token_; |
| 74 scoped_ptr<content::URLFetcher> user_entry_fetcher_; | 87 scoped_ptr<content::URLFetcher> user_entry_fetcher_; |
| 75 scoped_ptr<content::URLFetcher> profile_image_fetcher_; | 88 scoped_ptr<content::URLFetcher> profile_image_fetcher_; |
| 76 content::NotificationRegistrar registrar_; | 89 content::NotificationRegistrar registrar_; |
| 77 string16 profile_full_name_; | 90 string16 profile_full_name_; |
| 78 SkBitmap profile_picture_; | 91 SkBitmap profile_picture_; |
| 92 PictureResult picture_result_; | |
| 93 std::string picture_url_; | |
| 79 | 94 |
| 80 DISALLOW_COPY_AND_ASSIGN(ProfileDownloader); | 95 DISALLOW_COPY_AND_ASSIGN(ProfileDownloader); |
| 81 }; | 96 }; |
| 82 | 97 |
| 83 #endif // CHROME_BROWSER_PROFILES_PROFILE_DOWNLOADER_H_ | 98 #endif // CHROME_BROWSER_PROFILES_PROFILE_DOWNLOADER_H_ |
| OLD | NEW |