Chromium Code Reviews| Index: chrome/browser/policy/profile_policy_connector.cc |
| diff --git a/chrome/browser/policy/profile_policy_connector.cc b/chrome/browser/policy/profile_policy_connector.cc |
| index 9b05203d076e7dc9523c97f25efed2658c486e4a..8e9372d74b8c9194ba2bbf36759345a38d56cf09 100644 |
| --- a/chrome/browser/policy/profile_policy_connector.cc |
| +++ b/chrome/browser/policy/profile_policy_connector.cc |
| @@ -21,6 +21,7 @@ |
| #include "components/policy/core/common/policy_namespace.h" |
| #include "components/policy/core/common/policy_service_impl.h" |
| #include "components/policy/core/common/schema_registry_tracking_policy_provider.h" |
| +#include "components/policy/policy_constants.h" |
| #include "google_apis/gaia/gaia_auth_util.h" |
| #if defined(OS_CHROMEOS) |
| @@ -31,6 +32,7 @@ |
| #include "chrome/browser/chromeos/policy/device_local_account.h" |
| #include "chrome/browser/chromeos/policy/device_local_account_policy_provider.h" |
| #include "chrome/browser/chromeos/policy/login_profile_policy_provider.h" |
| +#include "chrome/browser/chromeos/policy/user_active_directory_policy_manager.h" |
| #include "components/user_manager/user.h" |
| #include "components/user_manager/user_manager.h" |
| #endif |
| @@ -39,45 +41,36 @@ namespace policy { |
| namespace { |
| -std::string GetCloudPolicyManagementDomain( |
| - const CloudPolicyManager* cloud_policy_manager) { |
| - const CloudPolicyStore* const store = cloud_policy_manager->core()->store(); |
| - if (store) { |
| - CHECK(store->is_initialized()) |
| +std::string GetStoreManagementDomain(const CloudPolicyStore* policy_store) { |
| + if (policy_store) { |
| + CHECK(policy_store->is_initialized()) |
| << "Cloud policy management domain must be " |
| "requested only after the policy system is fully initialized"; |
| - if (store->is_managed() && store->policy()->has_username()) |
| - return gaia::ExtractDomainName(store->policy()->username()); |
| + if (policy_store->is_managed() && policy_store->policy()->has_username()) |
| + return gaia::ExtractDomainName(policy_store->policy()->username()); |
| } |
| - return ""; |
| + return std::string(); |
| } |
| } // namespace |
| -ProfilePolicyConnector::ProfilePolicyConnector() |
| -#if defined(OS_CHROMEOS) |
| - : is_primary_user_(false), |
| - user_cloud_policy_manager_(nullptr) |
| -#else |
| - : user_cloud_policy_manager_(nullptr) |
| -#endif |
| -{ |
| -} |
| +ProfilePolicyConnector::ProfilePolicyConnector() {} |
| ProfilePolicyConnector::~ProfilePolicyConnector() {} |
| void ProfilePolicyConnector::Init( |
| -#if defined(OS_CHROMEOS) |
| const user_manager::User* user, |
| -#endif |
| SchemaRegistry* schema_registry, |
| - CloudPolicyManager* user_cloud_policy_manager) { |
| - user_cloud_policy_manager_ = user_cloud_policy_manager; |
| + ConfigurationPolicyProvider* configuration_policy_provider, |
| + const CloudPolicyStore* policy_store) { |
| + configuration_policy_provider_ = configuration_policy_provider; |
| + policy_store_ = policy_store; |
| #if defined(OS_CHROMEOS) |
| BrowserPolicyConnectorChromeOS* connector = |
| g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
| #else |
| + DCHECK_EQ(nullptr, user); |
| BrowserPolicyConnector* connector = |
| g_browser_process->browser_policy_connector(); |
| #endif |
| @@ -100,8 +93,8 @@ void ProfilePolicyConnector::Init( |
| } |
| #endif |
| - if (user_cloud_policy_manager) |
| - policy_providers_.push_back(user_cloud_policy_manager); |
| + if (configuration_policy_provider) |
| + policy_providers_.push_back(configuration_policy_provider); |
| #if defined(OS_CHROMEOS) |
| if (!user) { |
| @@ -129,8 +122,8 @@ void ProfilePolicyConnector::Init( |
| #if defined(OS_CHROMEOS) |
| if (is_primary_user_) { |
| - if (user_cloud_policy_manager) |
| - connector->SetUserPolicyDelegate(user_cloud_policy_manager); |
| + if (configuration_policy_provider) |
| + connector->SetUserPolicyDelegate(configuration_policy_provider); |
| else if (special_user_policy_provider_) |
| connector->SetUserPolicyDelegate(special_user_policy_provider_.get()); |
| } |
| @@ -163,12 +156,19 @@ void ProfilePolicyConnector::Shutdown() { |
| bool ProfilePolicyConnector::IsManaged() const { |
| if (is_managed_override_) |
| return *is_managed_override_; |
| - return !GetManagementDomain().empty(); |
| + return policy_store_ && policy_store_->is_managed(); |
|
emaxx
2016/12/28 19:09:20
You are changing the behavior here, when special_u
Thiemo Nagel
2016/12/29 15:08:27
Good point. Maybe not. I'm reverting this part.
|
| +} |
| + |
| +std::string ProfilePolicyConnector::GetDisplayDomainForManagedBookmarks() |
| + const { |
| + if (!IsProfilePolicy(policy::key::kManagedBookmarks)) |
| + return std::string(); |
| + return GetManagementDomain(); |
| } |
| std::string ProfilePolicyConnector::GetManagementDomain() const { |
| - if (user_cloud_policy_manager_) |
| - return GetCloudPolicyManagementDomain(user_cloud_policy_manager_); |
| + if (policy_store_) |
| + return GetStoreManagementDomain(policy_store_); |
| #if defined(OS_CHROMEOS) |
| if (special_user_policy_provider_) { |
| // |special_user_policy_provider_| is non-null for device-local accounts and |
| @@ -180,16 +180,17 @@ std::string ProfilePolicyConnector::GetManagementDomain() const { |
| ->GetDeviceCloudPolicyManager(); |
| // The device_cloud_policy_manager can be a nullptr in unit tests. |
| if (device_cloud_policy_manager) |
| - return GetCloudPolicyManagementDomain(device_cloud_policy_manager); |
| + return GetStoreManagementDomain( |
| + device_cloud_policy_manager->core()->store()); |
| } |
| #endif |
| - return ""; |
| + return std::string(); |
| } |
| -bool ProfilePolicyConnector::IsPolicyFromCloudPolicy(const char* name) const { |
| +bool ProfilePolicyConnector::IsProfilePolicy(const char* name) const { |
| const ConfigurationPolicyProvider* const provider = |
| DeterminePolicyProviderForPolicy(name); |
| - return provider == user_cloud_policy_manager_; |
| + return (provider == configuration_policy_provider_); |
|
emaxx
2016/12/28 19:09:20
nit: The parentheses here don't seem to be helpful
Thiemo Nagel
2016/12/29 15:08:27
Sorry, that was not intentional.
|
| } |
| const ConfigurationPolicyProvider* |