blob: 893ac7483f26f3116a6f661850749af82bcc0eb1 [file] [log] [blame]
[email protected]994bbd62012-06-28 14:24:381// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]6d33da172011-11-22 03:56:092// 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_DELEGATE_H_
6#define CHROME_BROWSER_PROFILES_PROFILE_DOWNLOADER_DELEGATE_H_
[email protected]6d33da172011-11-22 03:56:097
8#include <string>
9
[email protected]76fb05c2013-06-11 04:38:0510#include "base/strings/string16.h"
[email protected]6d33da172011-11-22 03:56:0911
[email protected]6d33da172011-11-22 03:56:0912class ProfileDownloader;
13
Miyoung Shin23737f62019-07-23 15:43:3114namespace signin {
Sylvain Defresnee220e532019-07-17 15:49:1915class IdentityManager;
Miyoung Shin23737f62019-07-23 15:43:3116} // namespace signin
Sylvain Defresnee220e532019-07-17 15:49:1917
18namespace network {
19namespace mojom {
20class URLLoaderFactory;
21} // namespace mojom
22} // namespace network
23
[email protected]6d33da172011-11-22 03:56:0924// Reports on success or failure of Profile download. It is OK to delete the
25// |ProfileImageDownloader| instance in any of these handlers.
26class ProfileDownloaderDelegate {
27 public:
[email protected]57eaa3282012-12-17 20:16:4228 // Error codes passed to OnProfileDownloadFailure.
29 enum FailureReason {
Mihai Sardarescue78ada72018-06-22 14:57:5330 TOKEN_ERROR, // Cannot fetch OAuth2 token.
31 NETWORK_ERROR, // Network failure while downloading profile.
32 SERVICE_ERROR, // Service returned an error or malformed reply.
33 IMAGE_DECODE_FAILED, // Cannot decode fetched image.
34 INVALID_PROFILE_PICTURE_URL // The profile picture URL is invalid.
[email protected]57eaa3282012-12-17 20:16:4235 };
36
[email protected]6d33da172011-11-22 03:56:0937 virtual ~ProfileDownloaderDelegate() {}
38
[email protected]994bbd62012-06-28 14:24:3839 // Whether the delegate need profile picture to be downloaded.
40 virtual bool NeedsProfilePicture() const = 0;
41
[email protected]6d33da172011-11-22 03:56:0942 // Returns the desired side length of the profile image. If 0, returns image
43 // of the originally uploaded size.
[email protected]5c9a1ad2011-11-30 23:32:4044 virtual int GetDesiredImageSideLength() const = 0;
45
46 // Returns the cached URL. If the cache URL matches the new image URL
Finnur Thorarinssonfebcdb52018-08-23 14:07:1347 // the image will not be downloaded. Return an empty string when there is no
[email protected]5c9a1ad2011-11-30 23:32:4048 // cached URL.
Finnur Thorarinssonfebcdb52018-08-23 14:07:1349 virtual std::string GetCachedPictureURL() const = 0;
[email protected]6d33da172011-11-22 03:56:0950
Sylvain Defresnee220e532019-07-17 15:49:1951 // Returns the IdentityManager associated with this download request.
Miyoung Shin23737f62019-07-23 15:43:3152 virtual signin::IdentityManager* GetIdentityManager() = 0;
Sylvain Defresnee220e532019-07-17 15:49:1953
54 // Returns the URLLoaderFactory to use for this download request.
55 virtual network::mojom::URLLoaderFactory* GetURLLoaderFactory() = 0;
[email protected]6d33da172011-11-22 03:56:0956
anthonyvdd98e85c2015-08-04 19:54:2057 // Returns true if the profile download is taking place before the user has
58 // signed in. This can happen for example on Android and will trigger some
59 // additional fetches since some information is not yet available.
60 virtual bool IsPreSignin() const = 0;
61
[email protected]994bbd62012-06-28 14:24:3862 // Called when the profile download has completed successfully. Delegate can
63 // query the downloader for the picture and full name.
64 virtual void OnProfileDownloadSuccess(ProfileDownloader* downloader) = 0;
65
66 // Called when the profile download has failed.
[email protected]57eaa3282012-12-17 20:16:4267 virtual void OnProfileDownloadFailure(
68 ProfileDownloader* downloader,
69 ProfileDownloaderDelegate::FailureReason reason) = 0;
[email protected]6d33da172011-11-22 03:56:0970};
71
72#endif // CHROME_BROWSER_PROFILES_PROFILE_DOWNLOADER_DELEGATE_H_