| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "chrome/browser/automation/testing_automation_provider.h" | 5 #include "chrome/browser/automation/testing_automation_provider.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 6039 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6050 #if !defined(ENABLE_CONFIGURATION_POLICY) || defined(OFFICIAL_BUILD) | 6050 #if !defined(ENABLE_CONFIGURATION_POLICY) || defined(OFFICIAL_BUILD) |
| 6051 reply->SendError("Configuration Policy disabled"); | 6051 reply->SendError("Configuration Policy disabled"); |
| 6052 #else | 6052 #else |
| 6053 const policy::PolicyDefinitionList* list = | 6053 const policy::PolicyDefinitionList* list = |
| 6054 policy::GetChromePolicyDefinitionList(); | 6054 policy::GetChromePolicyDefinitionList(); |
| 6055 policy::BrowserPolicyConnector* connector = | 6055 policy::BrowserPolicyConnector* connector = |
| 6056 g_browser_process->browser_policy_connector(); | 6056 g_browser_process->browser_policy_connector(); |
| 6057 struct { | 6057 struct { |
| 6058 std::string name; | 6058 std::string name; |
| 6059 policy::ConfigurationPolicyProvider* provider; | 6059 policy::ConfigurationPolicyProvider* provider; |
| 6060 policy::PolicyLevel level; |
| 6060 } providers[] = { | 6061 } providers[] = { |
| 6061 { "managed_cloud", connector->GetManagedCloudProvider() }, | 6062 { "managed_cloud", |
| 6062 { "managed_platform", connector->GetManagedPlatformProvider() }, | 6063 connector->GetManagedCloudProvider(), |
| 6063 { "recommended_cloud", connector->GetRecommendedCloudProvider() }, | 6064 policy::POLICY_LEVEL_MANDATORY }, |
| 6064 { "recommended_platform", connector->GetRecommendedPlatformProvider() } | 6065 { "managed_platform", |
| 6066 connector->GetManagedPlatformProvider(), |
| 6067 policy::POLICY_LEVEL_MANDATORY }, |
| 6068 { "recommended_cloud", |
| 6069 connector->GetRecommendedCloudProvider(), |
| 6070 policy::POLICY_LEVEL_RECOMMENDED }, |
| 6071 { "recommended_platform", |
| 6072 connector->GetRecommendedPlatformProvider(), |
| 6073 policy::POLICY_LEVEL_RECOMMENDED }, |
| 6065 }; | 6074 }; |
| 6066 // Verify if all the requested providers exist before changing anything. | 6075 // Verify if all the requested providers exist before changing anything. |
| 6067 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(providers); ++i) { | 6076 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(providers); ++i) { |
| 6068 DictionaryValue* policies = NULL; | 6077 DictionaryValue* policies = NULL; |
| 6069 if (args->GetDictionary(providers[i].name, &policies) && | 6078 if (args->GetDictionary(providers[i].name, &policies) && |
| 6070 policies && | 6079 policies && |
| 6071 !providers[i].provider) { | 6080 !providers[i].provider) { |
| 6072 reply->SendError("Provider not available: " + providers[i].name); | 6081 reply->SendError("Provider not available: " + providers[i].name); |
| 6073 return; | 6082 return; |
| 6074 } | 6083 } |
| 6075 } | 6084 } |
| 6085 // TODO(joaodasilva): POLICY_SCOPE_USER is currently hardcoded, and the |
| 6086 // level is determined by the provider. Change this interface to support |
| 6087 // per-policy level and scope once the PolicyService is ready. |
| 6088 // http://crbug.com/110588 |
| 6076 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(providers); ++i) { | 6089 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(providers); ++i) { |
| 6077 DictionaryValue* policies = NULL; | 6090 DictionaryValue* policies = NULL; |
| 6078 if (args->GetDictionary(providers[i].name, &policies) && policies) { | 6091 if (args->GetDictionary(providers[i].name, &policies) && policies) { |
| 6079 policy::PolicyMap* map = new policy::PolicyMap; | 6092 policy::PolicyMap* map = new policy::PolicyMap; |
| 6080 map->LoadFrom(policies, list); | 6093 map->LoadFrom(policies, list, providers[i].level, |
| 6094 policy::POLICY_SCOPE_USER); |
| 6081 providers[i].provider->OverridePolicies(map); | 6095 providers[i].provider->OverridePolicies(map); |
| 6082 } | 6096 } |
| 6083 } | 6097 } |
| 6084 | 6098 |
| 6085 // Make sure the policies are in effect before returning. This will go | 6099 // Make sure the policies are in effect before returning. This will go |
| 6086 // away once all platforms rely on directly installing the policy files and | 6100 // away once all platforms rely on directly installing the policy files and |
| 6087 // using RefreshPolicies, and SetPolicies is removed. | 6101 // using RefreshPolicies, and SetPolicies is removed. |
| 6088 PolicyUpdatesObserver::PostCallbackAfterPolicyUpdates( | 6102 PolicyUpdatesObserver::PostCallbackAfterPolicyUpdates( |
| 6089 base::Bind(&AutomationJSONReply::SendSuccess, | 6103 base::Bind(&AutomationJSONReply::SendSuccess, |
| 6090 base::Owned(reply.release()), | 6104 base::Owned(reply.release()), |
| (...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6797 | 6811 |
| 6798 Send(reply_message_); | 6812 Send(reply_message_); |
| 6799 redirect_query_ = 0; | 6813 redirect_query_ = 0; |
| 6800 reply_message_ = NULL; | 6814 reply_message_ = NULL; |
| 6801 } | 6815 } |
| 6802 | 6816 |
| 6803 void TestingAutomationProvider::OnRemoveProvider() { | 6817 void TestingAutomationProvider::OnRemoveProvider() { |
| 6804 if (g_browser_process) | 6818 if (g_browser_process) |
| 6805 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); | 6819 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); |
| 6806 } | 6820 } |
| OLD | NEW |