Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / supervised_user / legacy / custodian_profile_downloader_service.h
blobc8cac37215f21ee5321de2df789339de71fd3b5a
1 // Copyright 2014 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_SUPERVISED_USER_LEGACY_CUSTODIAN_PROFILE_DOWNLOADER_SERVICE_H_
6 #define CHROME_BROWSER_SUPERVISED_USER_LEGACY_CUSTODIAN_PROFILE_DOWNLOADER_SERVICE_H_
8 #include "base/callback.h"
9 #include "chrome/browser/profiles/profile_downloader.h"
10 #include "chrome/browser/profiles/profile_downloader_delegate.h"
11 #include "components/keyed_service/core/keyed_service.h"
13 class CustodianProfileDownloaderService : public KeyedService,
14 public ProfileDownloaderDelegate {
15 public:
16 // Callback for DownloadProfile() below. If the GAIA profile download is
17 // successful, the profile's full (display) name will be returned.
18 typedef base::Callback<void(const base::string16& /* full name */)>
19 DownloadProfileCallback;
21 ~CustodianProfileDownloaderService() override;
23 // KeyedService:
24 void Shutdown() override;
26 // Downloads the GAIA account information for the |custodian_profile_|.
27 // This is a best-effort attempt with no error reporting nor timeout.
28 // If the download is successful, the profile's full (display) name will
29 // be returned via the callback. If the download fails or never completes,
30 // the callback will not be called.
31 void DownloadProfile(const DownloadProfileCallback& callback);
33 // ProfileDownloaderDelegate:
34 bool NeedsProfilePicture() const override;
35 int GetDesiredImageSideLength() const override;
36 std::string GetCachedPictureURL() const override;
37 Profile* GetBrowserProfile() override;
38 bool IsPreSignin() const override;
39 void OnProfileDownloadSuccess(ProfileDownloader* downloader) override;
40 void OnProfileDownloadFailure(
41 ProfileDownloader* downloader,
42 ProfileDownloaderDelegate::FailureReason reason) override;
44 private:
45 friend class CustodianProfileDownloaderServiceFactory;
46 // Use |CustodianProfileDownloaderServiceFactory::GetForProfile(...)| to
47 // get instances of this service.
48 explicit CustodianProfileDownloaderService(Profile* custodian_profile);
50 scoped_ptr<ProfileDownloader> profile_downloader_;
51 DownloadProfileCallback download_callback_;
53 // Owns us via the KeyedService mechanism.
54 Profile* custodian_profile_;
56 std::string last_downloaded_profile_email_;
57 std::string in_progress_profile_email_;
60 #endif // CHROME_BROWSER_SUPERVISED_USER_LEGACY_CUSTODIAN_PROFILE_DOWNLOADER_SERVICE_H_