Chromium Code Reviews| 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 5961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5972 #if !defined(ENABLE_CONFIGURATION_POLICY) || defined(OFFICIAL_BUILD) | 5972 #if !defined(ENABLE_CONFIGURATION_POLICY) || defined(OFFICIAL_BUILD) |
| 5973 reply->SendError("Configuration Policy disabled"); | 5973 reply->SendError("Configuration Policy disabled"); |
| 5974 #else | 5974 #else |
| 5975 const policy::PolicyDefinitionList* list = | 5975 const policy::PolicyDefinitionList* list = |
| 5976 policy::GetChromePolicyDefinitionList(); | 5976 policy::GetChromePolicyDefinitionList(); |
| 5977 policy::BrowserPolicyConnector* connector = | 5977 policy::BrowserPolicyConnector* connector = |
| 5978 g_browser_process->browser_policy_connector(); | 5978 g_browser_process->browser_policy_connector(); |
| 5979 struct { | 5979 struct { |
| 5980 std::string name; | 5980 std::string name; |
| 5981 policy::ConfigurationPolicyProvider* provider; | 5981 policy::ConfigurationPolicyProvider* provider; |
| 5982 policy::PolicyLevel level; | |
| 5982 } providers[] = { | 5983 } providers[] = { |
| 5983 { "managed_cloud", connector->GetManagedCloudProvider() }, | 5984 { "managed_cloud", |
| 5984 { "managed_platform", connector->GetManagedPlatformProvider() }, | 5985 connector->GetManagedCloudProvider(), |
| 5985 { "recommended_cloud", connector->GetRecommendedCloudProvider() }, | 5986 policy::POLICY_LEVEL_MANDATORY }, |
| 5986 { "recommended_platform", connector->GetRecommendedPlatformProvider() } | 5987 { "managed_platform", |
| 5988 connector->GetManagedPlatformProvider(), | |
| 5989 policy::POLICY_LEVEL_MANDATORY }, | |
| 5990 { "recommended_cloud", | |
| 5991 connector->GetRecommendedCloudProvider(), | |
| 5992 policy::POLICY_LEVEL_RECOMMENDED }, | |
| 5993 { "recommended_platform", | |
| 5994 connector->GetRecommendedPlatformProvider(), | |
| 5995 policy::POLICY_LEVEL_RECOMMENDED }, | |
| 5987 }; | 5996 }; |
| 5988 // Verify if all the requested providers exist before changing anything. | 5997 // Verify if all the requested providers exist before changing anything. |
| 5989 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(providers); ++i) { | 5998 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(providers); ++i) { |
| 5990 DictionaryValue* policies = NULL; | 5999 DictionaryValue* policies = NULL; |
| 5991 if (args->GetDictionary(providers[i].name, &policies) && | 6000 if (args->GetDictionary(providers[i].name, &policies) && |
| 5992 policies && | 6001 policies && |
| 5993 !providers[i].provider) { | 6002 !providers[i].provider) { |
| 5994 reply->SendError("Provider not available: " + providers[i].name); | 6003 reply->SendError("Provider not available: " + providers[i].name); |
| 5995 return; | 6004 return; |
| 5996 } | 6005 } |
| 5997 } | 6006 } |
| 5998 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(providers); ++i) { | 6007 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(providers); ++i) { |
| 5999 DictionaryValue* policies = NULL; | 6008 DictionaryValue* policies = NULL; |
| 6000 if (args->GetDictionary(providers[i].name, &policies) && policies) { | 6009 if (args->GetDictionary(providers[i].name, &policies) && policies) { |
| 6001 policy::PolicyMap* map = new policy::PolicyMap; | 6010 policy::PolicyMap* map = new policy::PolicyMap; |
| 6002 map->LoadFrom(policies, list); | 6011 map->LoadFrom( |
| 6012 policies, list, providers[i].level, policy::POLICY_SCOPE_USER); | |
|
Mattias Nissler (ping if slow)
2012/01/16 18:23:33
nitty nit: Putting the first 3 parameters after (
Joao da Silva
2012/01/17 13:09:29
The scope should indeed be configurable. Added an
| |
| 6003 providers[i].provider->OverridePolicies(map); | 6013 providers[i].provider->OverridePolicies(map); |
| 6004 } | 6014 } |
| 6005 } | 6015 } |
| 6006 | 6016 |
| 6007 // Make sure the policies are in effect before returning. This will go | 6017 // Make sure the policies are in effect before returning. This will go |
| 6008 // away once all platforms rely on directly installing the policy files and | 6018 // away once all platforms rely on directly installing the policy files and |
| 6009 // using RefreshPolicies, and SetPolicies is removed. | 6019 // using RefreshPolicies, and SetPolicies is removed. |
| 6010 PolicyUpdatesObserver::PostCallbackAfterPolicyUpdates( | 6020 PolicyUpdatesObserver::PostCallbackAfterPolicyUpdates( |
| 6011 base::Bind(&AutomationJSONReply::SendSuccess, | 6021 base::Bind(&AutomationJSONReply::SendSuccess, |
| 6012 base::Owned(reply.release()), | 6022 base::Owned(reply.release()), |
| (...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6719 | 6729 |
| 6720 Send(reply_message_); | 6730 Send(reply_message_); |
| 6721 redirect_query_ = 0; | 6731 redirect_query_ = 0; |
| 6722 reply_message_ = NULL; | 6732 reply_message_ = NULL; |
| 6723 } | 6733 } |
| 6724 | 6734 |
| 6725 void TestingAutomationProvider::OnRemoveProvider() { | 6735 void TestingAutomationProvider::OnRemoveProvider() { |
| 6726 if (g_browser_process) | 6736 if (g_browser_process) |
| 6727 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); | 6737 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); |
| 6728 } | 6738 } |
| OLD | NEW |