Commit 0a332812 authored by Michael Giuffrida's avatar Michael Giuffrida Committed by Commit Bot

Remove legacy CustodianProfileDownloaderService

With legacy supervised profiles no longer available, these classes can be
removed.

Bug: None
Change-Id: I90a014ca6c862b8ac3040032e0355bf3e635b756
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2318560
Auto-Submit: Michael Giuffrida <michaelpg@chromium.org>
Commit-Queue: Dan S <danan@chromium.org>
Reviewed-by: default avatarDan S <danan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#794234}
parent d875e000
...@@ -5621,16 +5621,6 @@ static_library("browser") { ...@@ -5621,16 +5621,6 @@ static_library("browser") {
"//chrome/common:supervised_user_commands_mojom", "//chrome/common:supervised_user_commands_mojom",
] ]
} }
if (enable_supervised_users && !is_android) {
sources += [
# TODO(bauerb): The legacy code should be removed(on desktop) once child
# account support has launched(https://crbug.com/505443).
"supervised_user/legacy/custodian_profile_downloader_service.cc",
"supervised_user/legacy/custodian_profile_downloader_service.h",
"supervised_user/legacy/custodian_profile_downloader_service_factory.cc",
"supervised_user/legacy/custodian_profile_downloader_service_factory.h",
]
}
if (enable_supervised_users && enable_extensions) { if (enable_supervised_users && enable_extensions) {
sources += [ sources += [
"supervised_user/supervised_user_extensions_delegate_impl.cc", "supervised_user/supervised_user_extensions_delegate_impl.cc",
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/supervised_user/legacy/custodian_profile_downloader_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/common/pref_names.h"
#include "components/prefs/pref_service.h"
#include "components/signin/public/identity_manager/consent_level.h"
#include "components/signin/public/identity_manager/identity_manager.h"
#include "content/public/browser/storage_partition.h"
#include "google_apis/gaia/gaia_auth_util.h"
CustodianProfileDownloaderService::CustodianProfileDownloaderService(
Profile* custodian_profile)
: custodian_profile_(custodian_profile) {
}
CustodianProfileDownloaderService::~CustodianProfileDownloaderService() {}
void CustodianProfileDownloaderService::Shutdown() {
profile_downloader_.reset();
}
void CustodianProfileDownloaderService::DownloadProfile(
const DownloadProfileCallback& callback) {
// The user must be logged in. "Unconsented" because this class doesn't care
// about browser sync consent.
if (!IdentityManagerFactory::GetForProfile(custodian_profile_)
->HasPrimaryAccount(signin::ConsentLevel::kNotRequired)) {
return;
}
download_callback_ = callback;
std::string current_email = custodian_profile_->GetProfileUserName();
if (gaia::AreEmailsSame(last_downloaded_profile_email_, current_email)) {
// Profile was previously downloaded successfully, use it as it is unlikely
// that we will need to download it again.
OnProfileDownloadSuccess(profile_downloader_.get());
return;
}
// If another profile download is in progress, drop it. It's not worth
// queueing them up, and more likely that the one that hasn't ended yet is
// failing somehow than that the new one won't succeed.
in_progress_profile_email_ = current_email;
profile_downloader_.reset(new ProfileDownloader(this));
profile_downloader_->Start();
}
bool CustodianProfileDownloaderService::NeedsProfilePicture() const {
return false;
}
int CustodianProfileDownloaderService::GetDesiredImageSideLength() const {
return 0;
}
std::string CustodianProfileDownloaderService::GetCachedPictureURL() const {
return std::string();
}
signin::IdentityManager*
CustodianProfileDownloaderService::GetIdentityManager() {
DCHECK(custodian_profile_);
return IdentityManagerFactory::GetForProfile(custodian_profile_);
}
network::mojom::URLLoaderFactory*
CustodianProfileDownloaderService::GetURLLoaderFactory() {
DCHECK(custodian_profile_);
return content::BrowserContext::GetDefaultStoragePartition(custodian_profile_)
->GetURLLoaderFactoryForBrowserProcess()
.get();
}
bool CustodianProfileDownloaderService::IsPreSignin() const {
return false;
}
void CustodianProfileDownloaderService::OnProfileDownloadSuccess(
ProfileDownloader* downloader) {
download_callback_.Run(downloader->GetProfileFullName());
download_callback_.Reset();
last_downloaded_profile_email_ = in_progress_profile_email_;
}
void CustodianProfileDownloaderService::OnProfileDownloadFailure(
ProfileDownloader* downloader,
ProfileDownloaderDelegate::FailureReason reason) {
// Ignore failures; proceed without the custodian's name.
download_callback_.Reset();
profile_downloader_.reset();
}
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_SUPERVISED_USER_LEGACY_CUSTODIAN_PROFILE_DOWNLOADER_SERVICE_H_
#define CHROME_BROWSER_SUPERVISED_USER_LEGACY_CUSTODIAN_PROFILE_DOWNLOADER_SERVICE_H_
#include "base/callback.h"
#include "chrome/browser/profiles/profile_downloader.h"
#include "chrome/browser/profiles/profile_downloader_delegate.h"
#include "components/keyed_service/core/keyed_service.h"
class Profile;
class CustodianProfileDownloaderService : public KeyedService,
public ProfileDownloaderDelegate {
public:
// Callback for DownloadProfile() below. If the GAIA profile download is
// successful, the profile's full (display) name will be returned.
typedef base::Callback<void(const base::string16& /* full name */)>
DownloadProfileCallback;
~CustodianProfileDownloaderService() override;
// KeyedService:
void Shutdown() override;
// Downloads the GAIA account information for the |custodian_profile_|.
// This is a best-effort attempt with no error reporting nor timeout.
// If the download is successful, the profile's full (display) name will
// be returned via the callback. If the download fails or never completes,
// the callback will not be called.
void DownloadProfile(const DownloadProfileCallback& callback);
// ProfileDownloaderDelegate:
bool NeedsProfilePicture() const override;
int GetDesiredImageSideLength() const override;
std::string GetCachedPictureURL() const override;
signin::IdentityManager* GetIdentityManager() override;
network::mojom::URLLoaderFactory* GetURLLoaderFactory() override;
bool IsPreSignin() const override;
void OnProfileDownloadSuccess(ProfileDownloader* downloader) override;
void OnProfileDownloadFailure(
ProfileDownloader* downloader,
ProfileDownloaderDelegate::FailureReason reason) override;
private:
friend class CustodianProfileDownloaderServiceFactory;
// Use |CustodianProfileDownloaderServiceFactory::GetForProfile(...)| to
// get instances of this service.
explicit CustodianProfileDownloaderService(Profile* custodian_profile);
std::unique_ptr<ProfileDownloader> profile_downloader_;
DownloadProfileCallback download_callback_;
// Owns us via the KeyedService mechanism.
Profile* custodian_profile_;
std::string last_downloaded_profile_email_;
std::string in_progress_profile_email_;
};
#endif // CHROME_BROWSER_SUPERVISED_USER_LEGACY_CUSTODIAN_PROFILE_DOWNLOADER_SERVICE_H_
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/supervised_user/legacy/custodian_profile_downloader_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/supervised_user/legacy/custodian_profile_downloader_service.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
// static
CustodianProfileDownloaderService*
CustodianProfileDownloaderServiceFactory::GetForProfile(
Profile* profile) {
return static_cast<CustodianProfileDownloaderService*>(
GetInstance()->GetServiceForBrowserContext(profile, true));
}
// static
CustodianProfileDownloaderServiceFactory*
CustodianProfileDownloaderServiceFactory::GetInstance() {
return base::Singleton<CustodianProfileDownloaderServiceFactory>::get();
}
CustodianProfileDownloaderServiceFactory::
CustodianProfileDownloaderServiceFactory()
: BrowserContextKeyedServiceFactory(
"CustodianProfileDownloaderService",
BrowserContextDependencyManager::GetInstance()) {
// Indirect dependency via ProfileDownloader.
DependsOn(IdentityManagerFactory::GetInstance());
}
CustodianProfileDownloaderServiceFactory::
~CustodianProfileDownloaderServiceFactory() {}
KeyedService* CustodianProfileDownloaderServiceFactory::BuildServiceInstanceFor(
content::BrowserContext* profile) const {
return new CustodianProfileDownloaderService(static_cast<Profile*>(profile));
}
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_SUPERVISED_USER_LEGACY_CUSTODIAN_PROFILE_DOWNLOADER_SERVICE_FACTORY_H_
#define CHROME_BROWSER_SUPERVISED_USER_LEGACY_CUSTODIAN_PROFILE_DOWNLOADER_SERVICE_FACTORY_H_
#include "base/memory/singleton.h"
#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
class CustodianProfileDownloaderService;
class Profile;
class CustodianProfileDownloaderServiceFactory
: public BrowserContextKeyedServiceFactory {
public:
static CustodianProfileDownloaderService* GetForProfile(Profile* profile);
static CustodianProfileDownloaderServiceFactory* GetInstance();
private:
friend struct base::DefaultSingletonTraits<
CustodianProfileDownloaderServiceFactory>;
CustodianProfileDownloaderServiceFactory();
~CustodianProfileDownloaderServiceFactory() override;
// BrowserContextKeyedServiceFactory:
KeyedService* BuildServiceInstanceFor(
content::BrowserContext* profile) const override;
};
#endif // CHROME_BROWSER_SUPERVISED_USER_LEGACY_CUSTODIAN_PROFILE_DOWNLOADER_SERVICE_FACTORY_H_
...@@ -22,8 +22,6 @@ ...@@ -22,8 +22,6 @@
#include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/identity_test_environment_profile_adaptor.h" #include "chrome/browser/signin/identity_test_environment_profile_adaptor.h"
#include "chrome/browser/supervised_user/legacy/custodian_profile_downloader_service.h"
#include "chrome/browser/supervised_user/legacy/custodian_profile_downloader_service_factory.h"
#include "chrome/browser/supervised_user/permission_request_creator.h" #include "chrome/browser/supervised_user/permission_request_creator.h"
#include "chrome/browser/supervised_user/supervised_user_features.h" #include "chrome/browser/supervised_user/supervised_user_features.h"
#include "chrome/browser/supervised_user/supervised_user_service_factory.h" #include "chrome/browser/supervised_user/supervised_user_service_factory.h"
...@@ -34,7 +32,6 @@ ...@@ -34,7 +32,6 @@
#include "chrome/test/base/testing_profile.h" #include "chrome/test/base/testing_profile.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
#include "components/prefs/scoped_user_pref_update.h" #include "components/prefs/scoped_user_pref_update.h"
#include "components/signin/public/identity_manager/identity_test_environment.h"
#include "components/version_info/version_info.h" #include "components/version_info/version_info.h"
#include "content/public/test/browser_task_environment.h" #include "content/public/test/browser_task_environment.h"
#include "content/public/test/test_utils.h" #include "content/public/test/test_utils.h"
...@@ -58,12 +55,6 @@ using content::MessageLoopRunner; ...@@ -58,12 +55,6 @@ using content::MessageLoopRunner;
namespace { namespace {
#if !defined(OS_ANDROID)
void OnProfileDownloadedFail(const base::string16& full_name) {
ASSERT_TRUE(false) << "Profile download should not have succeeded.";
}
#endif
// Base class for helper objects that wait for certain events to happen. // Base class for helper objects that wait for certain events to happen.
// This class will ensure that calls to QuitRunLoop() (triggered by a subclass) // This class will ensure that calls to QuitRunLoop() (triggered by a subclass)
// are balanced with Wait() calls. // are balanced with Wait() calls.
...@@ -206,10 +197,6 @@ class SupervisedUserServiceTest : public ::testing::Test { ...@@ -206,10 +197,6 @@ class SupervisedUserServiceTest : public ::testing::Test {
base::Unretained(result_holder))); base::Unretained(result_holder)));
} }
signin::IdentityTestEnvironment* identity_test_env() {
return identity_test_environment_adaptor_->identity_test_env();
}
std::unique_ptr<IdentityTestEnvironmentProfileAdaptor> std::unique_ptr<IdentityTestEnvironmentProfileAdaptor>
identity_test_environment_adaptor_; identity_test_environment_adaptor_;
content::BrowserTaskEnvironment task_environment_; content::BrowserTaskEnvironment task_environment_;
...@@ -219,22 +206,6 @@ class SupervisedUserServiceTest : public ::testing::Test { ...@@ -219,22 +206,6 @@ class SupervisedUserServiceTest : public ::testing::Test {
} // namespace } // namespace
#if !defined(OS_ANDROID)
// Ensure that the CustodianProfileDownloaderService shuts down cleanly. If no
// DCHECK is hit when the service is destroyed, this test passed.
TEST_F(SupervisedUserServiceTest, ShutDownCustodianProfileDownloader) {
CustodianProfileDownloaderService* downloader_service =
CustodianProfileDownloaderServiceFactory::GetForProfile(profile_.get());
// Emulate being logged in, then start to download a profile so a
// ProfileDownloader gets created.
identity_test_env()->MakeUnconsentedPrimaryAccountAvailable(
"logged_in@gmail.com");
downloader_service->DownloadProfile(base::Bind(&OnProfileDownloadedFail));
}
#endif
namespace { namespace {
class MockPermissionRequestCreator : public PermissionRequestCreator { class MockPermissionRequestCreator : public PermissionRequestCreator {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment