Index: chrome/browser/profiles/profile_downloader.h |
diff --git a/chrome/browser/profiles/profile_downloader.h b/chrome/browser/profiles/profile_downloader.h |
index c21eb30b2e37980f294c6956faaf60f485fa461c..73357393daf012a896fd65108bc6d085f382816b 100644 |
--- a/chrome/browser/profiles/profile_downloader.h |
+++ b/chrome/browser/profiles/profile_downloader.h |
@@ -12,6 +12,7 @@ |
#include "base/memory/scoped_ptr.h" |
#include "base/strings/string16.h" |
#include "chrome/browser/image_decoder.h" |
+#include "components/signin/core/browser/account_tracker_service.h" |
#include "google_apis/gaia/gaia_oauth_client.h" |
Mike Lerman
2015/04/20 13:25:23
Probably don't need this include anymore.
anthonyvd
2015/04/29 15:15:08
Done.
|
#include "google_apis/gaia/oauth2_token_service.h" |
#include "net/url_request/url_fetcher_delegate.h" |
@@ -27,11 +28,11 @@ class URLFetcher; |
// Downloads user profile information. The profile picture is decoded in a |
// sandboxed process. |
-class ProfileDownloader : public gaia::GaiaOAuthClient::Delegate, |
- public net::URLFetcherDelegate, |
+class ProfileDownloader : public net::URLFetcherDelegate, |
public ImageDecoder::ImageRequest, |
public OAuth2TokenService::Observer, |
- public OAuth2TokenService::Consumer { |
+ public OAuth2TokenService::Consumer, |
+ public AccountTrackerService::Observer { |
public: |
enum PictureStatus { |
PICTURE_SUCCESS, |
@@ -51,7 +52,9 @@ class ProfileDownloader : public gaia::GaiaOAuthClient::Delegate, |
// Starts downloading profile information if the necessary authorization token |
// is ready. If not, subscribes to token service and starts fetching if the |
// token is available. Should not be called more than once. |
- virtual void StartForAccount(const std::string& account_id); |
+ virtual void StartForAccount( |
+ const std::string& account_id, |
+ AccountTrackerService* account_tracker_service = nullptr); |
Mike Lerman
2015/04/20 13:25:23
Pretty sure Chromium style guide doesn't permit de
anthonyvd
2015/04/29 15:15:08
You're right, it's a remain of my trying a few thi
|
// On successful download this returns the hosted domain of the user. |
virtual base::string16 GetProfileHostedDomain() const; |
@@ -80,16 +83,14 @@ class ProfileDownloader : public gaia::GaiaOAuthClient::Delegate, |
// when the picture status is PICTURE_SUCCESS. |
virtual std::string GetProfilePictureURL() const; |
+ void StartFetchingImageForTesting(net::URLFetcher* image_fetcher); |
+ |
private: |
friend class ProfileDownloaderTest; |
FRIEND_TEST_ALL_PREFIXES(ProfileDownloaderTest, ParseData); |
FRIEND_TEST_ALL_PREFIXES(ProfileDownloaderTest, DefaultURL); |
- // gaia::GaiaOAuthClient::Delegate implementation. |
- void OnGetUserInfoResponse( |
- scoped_ptr<base::DictionaryValue> user_info) override; |
- void OnOAuthError() override; |
- void OnNetworkError(int response_code) override; |
+ void FetchImageData(std::string image_url); |
// Overriden from net::URLFetcherDelegate: |
void OnURLFetchComplete(const net::URLFetcher* source) override; |
@@ -108,16 +109,12 @@ class ProfileDownloader : public gaia::GaiaOAuthClient::Delegate, |
void OnGetTokenFailure(const OAuth2TokenService::Request* request, |
const GoogleServiceAuthError& error) override; |
- // Parses the entry response and gets the name, profile image URL and locale. |
- // |data| should be the JSON formatted data return by the response. |
- // Returns false to indicate a parsing error. |
- static bool ParseProfileJSON(base::DictionaryValue* root_dictionary, |
- base::string16* full_name, |
- base::string16* given_name, |
- std::string* url, |
- int image_size, |
- std::string* profile_locale, |
- base::string16* hosted_domain); |
+ |
+ // Implementation of AccountTrackerService::Observer. |
+ void OnAccountUpdated( |
+ const AccountTrackerService::AccountInfo& info) override; |
+ void OnAccountUpdateFailed(const std::string& account_id) override; |
+ |
// Returns true if the image url is url of the default profile picture. |
static bool IsDefaultProfileImageURL(const std::string& url); |
@@ -134,16 +131,12 @@ class ProfileDownloader : public gaia::GaiaOAuthClient::Delegate, |
ProfileDownloaderDelegate* delegate_; |
std::string account_id_; |
std::string auth_token_; |
- scoped_ptr<gaia::GaiaOAuthClient> gaia_client_; |
scoped_ptr<net::URLFetcher> profile_image_fetcher_; |
scoped_ptr<OAuth2TokenService::Request> oauth2_access_token_request_; |
- base::string16 profile_hosted_domain_; |
- base::string16 profile_full_name_; |
- base::string16 profile_given_name_; |
- std::string profile_locale_; |
+ AccountTrackerService::AccountInfo account_info_; |
Mike Lerman
2015/04/20 13:25:23
A profile has multiple AccountInfo objects associa
Roger Tawa OOO till Jul 10th
2015/04/21 14:00:34
Actually, StartForAccount() can be called with an
anthonyvd
2015/04/29 15:15:08
Acknowledged.
|
SkBitmap profile_picture_; |
PictureStatus picture_status_; |
- std::string picture_url_; |
+ AccountTrackerService* account_tracker_service_; |
DISALLOW_COPY_AND_ASSIGN(ProfileDownloader); |
}; |