Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(559)

Side by Side Diff: chrome/browser/automation/testing_automation_provider.cc

Issue 9111022: Removed ConfigurationPolicyType and extended PolicyMap. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 6038 matching lines...) Expand 10 before | Expand all | Expand 10 after
6049 #if !defined(ENABLE_CONFIGURATION_POLICY) || defined(OFFICIAL_BUILD) 6049 #if !defined(ENABLE_CONFIGURATION_POLICY) || defined(OFFICIAL_BUILD)
6050 reply->SendError("Configuration Policy disabled"); 6050 reply->SendError("Configuration Policy disabled");
6051 #else 6051 #else
6052 const policy::PolicyDefinitionList* list = 6052 const policy::PolicyDefinitionList* list =
6053 policy::GetChromePolicyDefinitionList(); 6053 policy::GetChromePolicyDefinitionList();
6054 policy::BrowserPolicyConnector* connector = 6054 policy::BrowserPolicyConnector* connector =
6055 g_browser_process->browser_policy_connector(); 6055 g_browser_process->browser_policy_connector();
6056 struct { 6056 struct {
6057 std::string name; 6057 std::string name;
6058 policy::ConfigurationPolicyProvider* provider; 6058 policy::ConfigurationPolicyProvider* provider;
6059 policy::PolicyLevel level;
6059 } providers[] = { 6060 } providers[] = {
6060 { "managed_cloud", connector->GetManagedCloudProvider() }, 6061 { "managed_cloud",
6061 { "managed_platform", connector->GetManagedPlatformProvider() }, 6062 connector->GetManagedCloudProvider(),
6062 { "recommended_cloud", connector->GetRecommendedCloudProvider() }, 6063 policy::POLICY_LEVEL_MANDATORY },
6063 { "recommended_platform", connector->GetRecommendedPlatformProvider() } 6064 { "managed_platform",
6065 connector->GetManagedPlatformProvider(),
6066 policy::POLICY_LEVEL_MANDATORY },
6067 { "recommended_cloud",
6068 connector->GetRecommendedCloudProvider(),
6069 policy::POLICY_LEVEL_RECOMMENDED },
6070 { "recommended_platform",
6071 connector->GetRecommendedPlatformProvider(),
6072 policy::POLICY_LEVEL_RECOMMENDED },
6064 }; 6073 };
6065 // Verify if all the requested providers exist before changing anything. 6074 // Verify if all the requested providers exist before changing anything.
6066 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(providers); ++i) { 6075 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(providers); ++i) {
6067 DictionaryValue* policies = NULL; 6076 DictionaryValue* policies = NULL;
6068 if (args->GetDictionary(providers[i].name, &policies) && 6077 if (args->GetDictionary(providers[i].name, &policies) &&
6069 policies && 6078 policies &&
6070 !providers[i].provider) { 6079 !providers[i].provider) {
6071 reply->SendError("Provider not available: " + providers[i].name); 6080 reply->SendError("Provider not available: " + providers[i].name);
6072 return; 6081 return;
6073 } 6082 }
6074 } 6083 }
6084 policy::PolicyScope scope = policy::POLICY_SCOPE_USER;
6085 bool machine_scope = false;
6086 if (args->GetBoolean("machine_scope", &machine_scope) && machine_scope)
Mattias Nissler (ping if slow) 2012/01/18 15:07:07 shouldn't we rather name this "scope" with possibl
Joao da Silva 2012/01/18 16:49:29 Agreed! The level is determined by the provider an
6087 scope = policy::POLICY_SCOPE_MACHINE;
6075 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(providers); ++i) { 6088 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(providers); ++i) {
6076 DictionaryValue* policies = NULL; 6089 DictionaryValue* policies = NULL;
6077 if (args->GetDictionary(providers[i].name, &policies) && policies) { 6090 if (args->GetDictionary(providers[i].name, &policies) && policies) {
6078 policy::PolicyMap* map = new policy::PolicyMap; 6091 policy::PolicyMap* map = new policy::PolicyMap;
6079 map->LoadFrom(policies, list); 6092 map->LoadFrom(policies, list, providers[i].level, scope);
6080 providers[i].provider->OverridePolicies(map); 6093 providers[i].provider->OverridePolicies(map);
6081 } 6094 }
6082 } 6095 }
6083 6096
6084 // Make sure the policies are in effect before returning. This will go 6097 // Make sure the policies are in effect before returning. This will go
6085 // away once all platforms rely on directly installing the policy files and 6098 // away once all platforms rely on directly installing the policy files and
6086 // using RefreshPolicies, and SetPolicies is removed. 6099 // using RefreshPolicies, and SetPolicies is removed.
6087 PolicyUpdatesObserver::PostCallbackAfterPolicyUpdates( 6100 PolicyUpdatesObserver::PostCallbackAfterPolicyUpdates(
6088 base::Bind(&AutomationJSONReply::SendSuccess, 6101 base::Bind(&AutomationJSONReply::SendSuccess,
6089 base::Owned(reply.release()), 6102 base::Owned(reply.release()),
(...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after
6796 6809
6797 Send(reply_message_); 6810 Send(reply_message_);
6798 redirect_query_ = 0; 6811 redirect_query_ = 0;
6799 reply_message_ = NULL; 6812 reply_message_ = NULL;
6800 } 6813 }
6801 6814
6802 void TestingAutomationProvider::OnRemoveProvider() { 6815 void TestingAutomationProvider::OnRemoveProvider() {
6803 if (g_browser_process) 6816 if (g_browser_process)
6804 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); 6817 g_browser_process->GetAutomationProviderList()->RemoveProvider(this);
6805 } 6818 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698