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

Side by Side Diff: chrome/browser/profiles/profile_downloader.h

Issue 8510069: Make ProfileImageDownloader available to non-chromeos code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix build 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
« no previous file with comments | « chrome/browser/image_decoder.cc ('k') | chrome/browser/profiles/profile_downloader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_PROFILES_PROFILE_DOWNLOADER_H_
6 #define CHROME_BROWSER_PROFILES_PROFILE_DOWNLOADER_H_
7 #pragma once
8
9 #include <string>
10
11 #include "base/basictypes.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/string16.h"
14 #include "chrome/browser/image_decoder.h"
15 #include "content/public/browser/notification_observer.h"
16 #include "content/public/browser/notification_registrar.h"
17 #include "content/public/common/url_fetcher_delegate.h"
18 #include "googleurl/src/gurl.h"
19 #include "third_party/skia/include/core/SkBitmap.h"
20
21 class ProfileDownloaderDelegate;
22
23 // Downloads user profile information. The profile picture is decoded in a
24 // sandboxed process.
25 class ProfileDownloader : public content::URLFetcherDelegate,
26 public ImageDecoder::Delegate,
27 public content::NotificationObserver {
28 public:
29 explicit ProfileDownloader(ProfileDownloaderDelegate* delegate);
30 virtual ~ProfileDownloader();
31
32 // Starts downloading profile information if the necessary authorization token
33 // is ready. If not, subscribes to token service and starts fetching if the
34 // token is available. Should not be called more than once.
35 void Start();
36
37 // On successful download this returns the full name of the user. For example
38 // "Pat Smith".
39 const string16& GetProfileFullName() const;
40
41 // 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
43 // profile picture) this will return an Null bitmap.
44 const SkBitmap& GetProfilePicture() const;
45
46 private:
47 // Overriden from content::URLFetcherDelegate:
48 virtual void OnURLFetchComplete(const content::URLFetcher* source) OVERRIDE;
49
50 // Overriden from ImageDecoder::Delegate:
51 virtual void OnImageDecoded(const ImageDecoder* decoder,
52 const SkBitmap& decoded_image) OVERRIDE;
53 virtual void OnDecodeImageFailed(const ImageDecoder* decoder) OVERRIDE;
54
55 // Overriden from content::NotificationObserver:
56 virtual void Observe(int type,
57 const content::NotificationSource& source,
58 const content::NotificationDetails& details) OVERRIDE;
59
60 // Parses the entry response from Picasa and gets the nick name and
61 // and profile image URL. Returns false to indicate a parsing error.
62 bool GetProfileNickNameAndImageURL(const std::string& data,
63 string16* nick_name,
64 std::string* url) const;
65
66 // Returns true if the image url is url of the default profile picture.
67 bool IsDefaultProfileImageURL(const std::string& url) const;
68
69 // Issues the first request to get user profile image.
70 void StartFetchingImage();
71
72 ProfileDownloaderDelegate* delegate_;
73 std::string auth_token_;
74 scoped_ptr<content::URLFetcher> user_entry_fetcher_;
75 scoped_ptr<content::URLFetcher> profile_image_fetcher_;
76 content::NotificationRegistrar registrar_;
77 string16 profile_full_name_;
78 SkBitmap profile_picture_;
79
80 DISALLOW_COPY_AND_ASSIGN(ProfileDownloader);
81 };
82
83 #endif // CHROME_BROWSER_PROFILES_PROFILE_DOWNLOADER_H_
OLDNEW
« no previous file with comments | « chrome/browser/image_decoder.cc ('k') | chrome/browser/profiles/profile_downloader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698