1 // Copyright (c) 2012 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.
5 #ifndef CHROME_BROWSER_PROFILES_PROFILE_DOWNLOADER_DELEGATE_H_
6 #define CHROME_BROWSER_PROFILES_PROFILE_DOWNLOADER_DELEGATE_H_
10 #include "base/basictypes.h"
11 #include "base/strings/string16.h"
14 class ProfileDownloader
;
16 // Reports on success or failure of Profile download. It is OK to delete the
17 // |ProfileImageDownloader| instance in any of these handlers.
18 class ProfileDownloaderDelegate
{
20 // Error codes passed to OnProfileDownloadFailure.
22 TOKEN_ERROR
, // Cannot fetch OAuth2 token.
23 NETWORK_ERROR
, // Network failure while downloading profile.
24 SERVICE_ERROR
, // Service returned an error or malformed reply.
25 IMAGE_DECODE_FAILED
// Cannot decode fetched image.
28 virtual ~ProfileDownloaderDelegate() {}
30 // Whether the delegate need profile picture to be downloaded.
31 virtual bool NeedsProfilePicture() const = 0;
33 // Returns the desired side length of the profile image. If 0, returns image
34 // of the originally uploaded size.
35 virtual int GetDesiredImageSideLength() const = 0;
37 // Returns the cached URL. If the cache URL matches the new image URL
38 // the image will not be downloaded. Return an empty string when there is no
40 virtual std::string
GetCachedPictureURL() const = 0;
42 // Returns the browser profile associated with this download request.
43 virtual Profile
* GetBrowserProfile() = 0;
45 // Called when the profile download has completed successfully. Delegate can
46 // query the downloader for the picture and full name.
47 virtual void OnProfileDownloadSuccess(ProfileDownloader
* downloader
) = 0;
49 // Called when the profile download has failed.
50 virtual void OnProfileDownloadFailure(
51 ProfileDownloader
* downloader
,
52 ProfileDownloaderDelegate::FailureReason reason
) = 0;
55 #endif // CHROME_BROWSER_PROFILES_PROFILE_DOWNLOADER_DELEGATE_H_