[Presentation API, Android] Implement basic messaging
[chromium-blink-merge.git] / chrome / browser / profiles / profile_downloader_delegate.h
blob70253e5da864b54714465552e64a3db25cd402d6
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_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/strings/string16.h"
13 class Profile;
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 {
19 public:
20 // Error codes passed to OnProfileDownloadFailure.
21 enum FailureReason {
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
39 // cached URL.
40 virtual std::string GetCachedPictureURL() const = 0;
42 // Returns the browser profile associated with this download request.
43 virtual Profile* GetBrowserProfile() = 0;
45 // Returns true if the profile download is taking place before the user has
46 // signed in. This can happen for example on Android and will trigger some
47 // additional fetches since some information is not yet available.
48 virtual bool IsPreSignin() const = 0;
50 // Called when the profile download has completed successfully. Delegate can
51 // query the downloader for the picture and full name.
52 virtual void OnProfileDownloadSuccess(ProfileDownloader* downloader) = 0;
54 // Called when the profile download has failed.
55 virtual void OnProfileDownloadFailure(
56 ProfileDownloader* downloader,
57 ProfileDownloaderDelegate::FailureReason reason) = 0;
60 #endif // CHROME_BROWSER_PROFILES_PROFILE_DOWNLOADER_DELEGATE_H_