From 2baf2a16dc7343f2096a00eaf578a03198134c14 Mon Sep 17 00:00:00 2001 From: Henrique Nakashima Date: Tue, 30 Apr 2019 21:21:10 +0000 Subject: [PATCH] Hide Profile::GetUserCloudPolicyManager() in Chrome OS. This always returns null in Chrome OS and should not be used. The API that should be used instead is currently UserPolicyManagerFactoryChromeOS::GetCloudPolicyManager() and will be soon changed to a Profile method like in other platforms. Bug: 937770 Change-Id: I1e5befd2d2a23a076c7182511c86b4b8a8c04aaf Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1588479 Commit-Queue: Henrique Nakashima Reviewed-by: Colin Blundell Cr-Commit-Position: refs/heads/master@{#655359} --- chrome/browser/profiles/off_the_record_profile_impl.cc | 2 ++ chrome/browser/profiles/off_the_record_profile_impl.h | 2 ++ chrome/browser/profiles/profile.h | 4 ++++ chrome/browser/profiles/profile_impl.cc | 2 ++ chrome/browser/profiles/profile_impl.h | 2 ++ chrome/test/base/testing_profile.cc | 2 ++ chrome/test/base/testing_profile.h | 2 ++ 7 files changed, 16 insertions(+) diff --git a/chrome/browser/profiles/off_the_record_profile_impl.cc b/chrome/browser/profiles/off_the_record_profile_impl.cc index 095057dde95bbf..7b8ae58da4efff 100644 --- a/chrome/browser/profiles/off_the_record_profile_impl.cc +++ b/chrome/browser/profiles/off_the_record_profile_impl.cc @@ -405,10 +405,12 @@ OffTheRecordProfileImpl::GetPolicySchemaRegistryService() { return nullptr; } +#if !defined(OS_CHROMEOS) policy::UserCloudPolicyManager* OffTheRecordProfileImpl::GetUserCloudPolicyManager() { return GetOriginalProfile()->GetUserCloudPolicyManager(); } +#endif net::URLRequestContextGetter* OffTheRecordProfileImpl::GetRequestContext() { return GetDefaultStoragePartition(this)->GetURLRequestContext(); diff --git a/chrome/browser/profiles/off_the_record_profile_impl.h b/chrome/browser/profiles/off_the_record_profile_impl.h index 6b592ecba2a191..e13314c3a8aa31 100644 --- a/chrome/browser/profiles/off_the_record_profile_impl.h +++ b/chrome/browser/profiles/off_the_record_profile_impl.h @@ -58,7 +58,9 @@ class OffTheRecordProfileImpl : public Profile { const PrefService* GetPrefs() const override; PrefService* GetOffTheRecordPrefs() override; policy::SchemaRegistryService* GetPolicySchemaRegistryService() override; +#if !defined(OS_CHROMEOS) policy::UserCloudPolicyManager* GetUserCloudPolicyManager() override; +#endif net::URLRequestContextGetter* GetRequestContext() override; base::OnceCallback GetExtensionsCookieStoreGetter() override; diff --git a/chrome/browser/profiles/profile.h b/chrome/browser/profiles/profile.h index cdb643e2b970f3..19f29aa48c5d45 100644 --- a/chrome/browser/profiles/profile.h +++ b/chrome/browser/profiles/profile.h @@ -235,8 +235,12 @@ class Profile : public content::BrowserContext { // Returns the SchemaRegistryService. virtual policy::SchemaRegistryService* GetPolicySchemaRegistryService() = 0; +// In Chrome OS, use UserPolicyManagerFactoryChromeOS::GetCloudPolicyManager() +// instead. +#if !defined(OS_CHROMEOS) // Returns the UserCloudPolicyManager. virtual policy::UserCloudPolicyManager* GetUserCloudPolicyManager() = 0; +#endif virtual policy::ProfilePolicyConnector* GetProfilePolicyConnector() = 0; virtual const policy::ProfilePolicyConnector* GetProfilePolicyConnector() diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc index 1a52bc73d600d4..c8d5dcabbffdea 100644 --- a/chrome/browser/profiles/profile_impl.cc +++ b/chrome/browser/profiles/profile_impl.cc @@ -1118,9 +1118,11 @@ policy::SchemaRegistryService* ProfileImpl::GetPolicySchemaRegistryService() { return schema_registry_service_.get(); } +#if !defined(OS_CHROMEOS) policy::UserCloudPolicyManager* ProfileImpl::GetUserCloudPolicyManager() { return user_cloud_policy_manager_; } +#endif policy::ProfilePolicyConnector* ProfileImpl::GetProfilePolicyConnector() { return profile_policy_connector_.get(); diff --git a/chrome/browser/profiles/profile_impl.h b/chrome/browser/profiles/profile_impl.h index 0c0033f084a84c..95102e3843ea80 100644 --- a/chrome/browser/profiles/profile_impl.h +++ b/chrome/browser/profiles/profile_impl.h @@ -142,7 +142,9 @@ class ProfileImpl : public Profile { PrefService* GetOffTheRecordPrefs() override; PrefService* GetReadOnlyOffTheRecordPrefs() override; policy::SchemaRegistryService* GetPolicySchemaRegistryService() override; +#if !defined(OS_CHROMEOS) policy::UserCloudPolicyManager* GetUserCloudPolicyManager() override; +#endif policy::ProfilePolicyConnector* GetProfilePolicyConnector() override; const policy::ProfilePolicyConnector* GetProfilePolicyConnector() const override; diff --git a/chrome/test/base/testing_profile.cc b/chrome/test/base/testing_profile.cc index 180de669fccfc8..ef2c0153acc197 100644 --- a/chrome/test/base/testing_profile.cc +++ b/chrome/test/base/testing_profile.cc @@ -933,9 +933,11 @@ TestingProfile::GetPolicySchemaRegistryService() { return schema_registry_service_.get(); } +#if !defined(OS_CHROMEOS) policy::UserCloudPolicyManager* TestingProfile::GetUserCloudPolicyManager() { return user_cloud_policy_manager_.get(); } +#endif policy::ProfilePolicyConnector* TestingProfile::GetProfilePolicyConnector() { return profile_policy_connector_.get(); diff --git a/chrome/test/base/testing_profile.h b/chrome/test/base/testing_profile.h index a10711db81bf7a..2bd579ba1f1a74 100644 --- a/chrome/test/base/testing_profile.h +++ b/chrome/test/base/testing_profile.h @@ -341,7 +341,9 @@ class TestingProfile : public Profile { base::Time GetStartTime() const override; ProfileKey* GetProfileKey() const override; policy::SchemaRegistryService* GetPolicySchemaRegistryService() override; +#if !defined(OS_CHROMEOS) policy::UserCloudPolicyManager* GetUserCloudPolicyManager() override; +#endif policy::ProfilePolicyConnector* GetProfilePolicyConnector() override; const policy::ProfilePolicyConnector* GetProfilePolicyConnector() const override;