| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_SUPERVISED_USER_CUSTODIAN_PROFILE_DOWNLOADER_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SUPERVISED_USER_CUSTODIAN_PROFILE_DOWNLOADER_SERVICE_H_ |
| 6 #define CHROME_BROWSER_SUPERVISED_USER_CUSTODIAN_PROFILE_DOWNLOADER_SERVICE_H_ | 6 #define CHROME_BROWSER_SUPERVISED_USER_CUSTODIAN_PROFILE_DOWNLOADER_SERVICE_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "chrome/browser/profiles/profile_downloader.h" | 9 #include "chrome/browser/profiles/profile_downloader.h" |
| 10 #include "chrome/browser/profiles/profile_downloader_delegate.h" | 10 #include "chrome/browser/profiles/profile_downloader_delegate.h" |
| 11 #include "components/keyed_service/core/keyed_service.h" | 11 #include "components/keyed_service/core/keyed_service.h" |
| 12 | 12 |
| 13 class CustodianProfileDownloaderService : public KeyedService, | 13 class CustodianProfileDownloaderService : public KeyedService, |
| 14 public ProfileDownloaderDelegate { | 14 public ProfileDownloaderDelegate { |
| 15 public: | 15 public: |
| 16 // Callback for DownloadProfile() below. If the GAIA profile download is | 16 // Callback for DownloadProfile() below. If the GAIA profile download is |
| 17 // successful, the profile's full (display) name will be returned. | 17 // successful, the profile's full (display) name will be returned. |
| 18 typedef base::Callback<void(const base::string16& /* full name */)> | 18 typedef base::Callback<void(const base::string16& /* full name */)> |
| 19 DownloadProfileCallback; | 19 DownloadProfileCallback; |
| 20 | 20 |
| 21 virtual ~CustodianProfileDownloaderService(); | 21 virtual ~CustodianProfileDownloaderService(); |
| 22 | 22 |
| 23 // KeyedService: | 23 // KeyedService: |
| 24 virtual void Shutdown() OVERRIDE; | 24 virtual void Shutdown() override; |
| 25 | 25 |
| 26 // Downloads the GAIA account information for the |custodian_profile_|. | 26 // Downloads the GAIA account information for the |custodian_profile_|. |
| 27 // This is a best-effort attempt with no error reporting nor timeout. | 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 | 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, | 29 // be returned via the callback. If the download fails or never completes, |
| 30 // the callback will not be called. | 30 // the callback will not be called. |
| 31 void DownloadProfile(const DownloadProfileCallback& callback); | 31 void DownloadProfile(const DownloadProfileCallback& callback); |
| 32 | 32 |
| 33 // ProfileDownloaderDelegate: | 33 // ProfileDownloaderDelegate: |
| 34 virtual bool NeedsProfilePicture() const OVERRIDE; | 34 virtual bool NeedsProfilePicture() const override; |
| 35 virtual int GetDesiredImageSideLength() const OVERRIDE; | 35 virtual int GetDesiredImageSideLength() const override; |
| 36 virtual std::string GetCachedPictureURL() const OVERRIDE; | 36 virtual std::string GetCachedPictureURL() const override; |
| 37 virtual Profile* GetBrowserProfile() OVERRIDE; | 37 virtual Profile* GetBrowserProfile() override; |
| 38 virtual void OnProfileDownloadSuccess(ProfileDownloader* downloader) OVERRIDE; | 38 virtual void OnProfileDownloadSuccess(ProfileDownloader* downloader) override; |
| 39 virtual void OnProfileDownloadFailure( | 39 virtual void OnProfileDownloadFailure( |
| 40 ProfileDownloader* downloader, | 40 ProfileDownloader* downloader, |
| 41 ProfileDownloaderDelegate::FailureReason reason) OVERRIDE; | 41 ProfileDownloaderDelegate::FailureReason reason) override; |
| 42 | 42 |
| 43 private: | 43 private: |
| 44 friend class CustodianProfileDownloaderServiceFactory; | 44 friend class CustodianProfileDownloaderServiceFactory; |
| 45 // Use |CustodianProfileDownloaderServiceFactory::GetForProfile(...)| to | 45 // Use |CustodianProfileDownloaderServiceFactory::GetForProfile(...)| to |
| 46 // get instances of this service. | 46 // get instances of this service. |
| 47 explicit CustodianProfileDownloaderService(Profile* custodian_profile); | 47 explicit CustodianProfileDownloaderService(Profile* custodian_profile); |
| 48 | 48 |
| 49 scoped_ptr<ProfileDownloader> profile_downloader_; | 49 scoped_ptr<ProfileDownloader> profile_downloader_; |
| 50 DownloadProfileCallback download_callback_; | 50 DownloadProfileCallback download_callback_; |
| 51 | 51 |
| 52 // Owns us via the KeyedService mechanism. | 52 // Owns us via the KeyedService mechanism. |
| 53 Profile* custodian_profile_; | 53 Profile* custodian_profile_; |
| 54 | 54 |
| 55 std::string last_downloaded_profile_email_; | 55 std::string last_downloaded_profile_email_; |
| 56 std::string in_progress_profile_email_; | 56 std::string in_progress_profile_email_; |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 #endif // CHROME_BROWSER_SUPERVISED_USER_CUSTODIAN_PROFILE_DOWNLOADER_SERVICE_H
_ | 59 #endif // CHROME_BROWSER_SUPERVISED_USER_CUSTODIAN_PROFILE_DOWNLOADER_SERVICE_H
_ |
| OLD | NEW |