Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(407)

Side by Side Diff: chrome/browser/gaia_userinfo/profile_image_downloader.h

Issue 8511064: GAIA Profile info prototype (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: test Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_GAIA_USERINFO_PROFILE_IMAGE_DOWNLOADER_H_
6 #define CHROME_BROWSER_GAIA_USERINFO_PROFILE_IMAGE_DOWNLOADER_H_
7 #pragma once
8
9 #include <string>
10
11 #include "base/basictypes.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "chrome/browser/gaia_userinfo/image_decoder.h"
14 #include "content/public/browser/notification_observer.h"
15 #include "content/public/browser/notification_registrar.h"
16 #include "content/public/common/url_fetcher_delegate.h"
17 #include "googleurl/src/gurl.h"
18
19 class Profile;
20
21 // Downloads user profile image, decodes it in a sandboxed process.
22 class ProfileImageDownloader : public content::URLFetcherDelegate,
23 public ImageDecoder::Delegate,
24 public content::NotificationObserver {
25 public:
26 // Enum for reporting histograms about profile picture download.
27 enum DownloadResult {
28 kDownloadSuccessChanged,
29 kDownloadSuccess,
30 kDownloadFailure,
31 kDownloadDefault,
32
33 // Must be the last, convenient count.
34 kDownloadResultsCount
35 };
36
37 // Reports on success or failure of Profile image download.
38 class Delegate {
39 public:
40 virtual ~Delegate() {}
41
42 // Returns the desierd size of the profile image.
43 virtual int GetDesiredImageSize() = 0;
44
45 // Returns the signed in user's user name.
46 virtual std::string GetProfileUserName() = 0;
47
48 // Returns the profile for associated with this download request.
49 virtual Profile* GetProfile() = 0;
50
51 // Called when image is successfully downloaded and decoded.
52 virtual void OnDownloadSuccess(const SkBitmap& image,
53 const string16& full_name) = 0;
54
55 // Called on download failure.
56 virtual void OnDownloadFailure() {}
57
58 // Called when user has the default profile image and we won't download
59 // it.
60 virtual void OnDownloadDefaultImage() {}
61 };
62
63 explicit ProfileImageDownloader(Delegate* delegate);
64 virtual ~ProfileImageDownloader();
65
66 // Starts downloading the picture if the necessary authorization token is
67 // ready. If not, subscribes to token service and starts fetching if the
68 // token is available.
69 void Start();
70
71 private:
72 // Overriden from content::URLFetcherDelegate:
73 virtual void OnURLFetchComplete(const content::URLFetcher* source) OVERRIDE;
74
75 // Overriden from ImageDecoder::Delegate:
76 virtual void OnImageDecoded(const ImageDecoder* decoder,
77 const SkBitmap& decoded_image) OVERRIDE;
78 virtual void OnDecodeImageFailed(const ImageDecoder* decoder) OVERRIDE;
79
80 // Overriden from content::NotificationObserver:
81 virtual void Observe(int type,
82 const content::NotificationSource& source,
83 const content::NotificationDetails& details) OVERRIDE;
84
85 // Searches for profile image URL in user entry response from Picasa.
86 // Returns an empty string on failure.
87 std::string GetProfileImageURL(const std::string& data);
88
89 // Returns true if the image url is url of the default profile picture.
90 bool IsDefaultProfileImageURL(const std::string& url) const;
91
92 // Issues the first request to get user profile image.
93 void StartFetchingImage();
94
95 Delegate* delegate_;
96 std::string auth_token_;
97 scoped_ptr<content::URLFetcher> user_entry_fetcher_;
98 scoped_ptr<content::URLFetcher> profile_image_fetcher_;
99 content::NotificationRegistrar registrar_;
100 string16 full_name_;
101
102 DISALLOW_COPY_AND_ASSIGN(ProfileImageDownloader);
103 };
104
105 #endif // CHROME_BROWSER_GAIA_USERINFO_PROFILE_IMAGE_DOWNLOADER_H_
OLDNEW
« no previous file with comments | « chrome/browser/gaia_userinfo/image_decoder.cc ('k') | chrome/browser/gaia_userinfo/profile_image_downloader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698