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

Side by Side Diff: chrome/browser/policy/profile_policy_connector.cc

Issue 775613004: Improve documentation for special-purpose policy providers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@policy_provider_dcheck
Patch Set: Address nits. Created 6 years 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
« no previous file with comments | « chrome/browser/policy/profile_policy_connector.h ('k') | components/components_tests.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/policy/profile_policy_connector.h" 5 #include "chrome/browser/policy/profile_policy_connector.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
13 #include "components/policy/core/browser/browser_policy_connector.h" 13 #include "components/policy/core/browser/browser_policy_connector.h"
14 #include "components/policy/core/common/cloud/cloud_policy_core.h" 14 #include "components/policy/core/common/cloud/cloud_policy_core.h"
15 #include "components/policy/core/common/cloud/cloud_policy_manager.h" 15 #include "components/policy/core/common/cloud/cloud_policy_manager.h"
16 #include "components/policy/core/common/cloud/cloud_policy_store.h" 16 #include "components/policy/core/common/cloud/cloud_policy_store.h"
17 #include "components/policy/core/common/configuration_policy_provider.h" 17 #include "components/policy/core/common/configuration_policy_provider.h"
18 #include "components/policy/core/common/forwarding_policy_provider.h"
19 #include "components/policy/core/common/policy_service_impl.h" 18 #include "components/policy/core/common/policy_service_impl.h"
19 #include "components/policy/core/common/schema_registry_tracking_policy_provider .h"
20 #include "google_apis/gaia/gaia_auth_util.h" 20 #include "google_apis/gaia/gaia_auth_util.h"
21 21
22 #if defined(OS_CHROMEOS) 22 #if defined(OS_CHROMEOS)
23 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" 23 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
24 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" 24 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h"
25 #include "chrome/browser/chromeos/policy/device_local_account_policy_provider.h" 25 #include "chrome/browser/chromeos/policy/device_local_account_policy_provider.h"
26 #include "chrome/browser/chromeos/policy/login_profile_policy_provider.h" 26 #include "chrome/browser/chromeos/policy/login_profile_policy_provider.h"
27 #include "components/user_manager/user.h" 27 #include "components/user_manager/user.h"
28 #include "components/user_manager/user_manager.h" 28 #include "components/user_manager/user_manager.h"
29 #endif 29 #endif
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 77
78 #if defined(OS_CHROMEOS) 78 #if defined(OS_CHROMEOS)
79 BrowserPolicyConnectorChromeOS* connector = 79 BrowserPolicyConnectorChromeOS* connector =
80 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 80 g_browser_process->platform_part()->browser_policy_connector_chromeos();
81 #else 81 #else
82 BrowserPolicyConnector* connector = 82 BrowserPolicyConnector* connector =
83 g_browser_process->browser_policy_connector(); 83 g_browser_process->browser_policy_connector();
84 #endif 84 #endif
85 85
86 if (connector->GetPlatformProvider()) { 86 if (connector->GetPlatformProvider()) {
87 forwarding_policy_provider_.reset( 87 wrapped_platform_policy_provider_.reset(
88 new ForwardingPolicyProvider(connector->GetPlatformProvider())); 88 new SchemaRegistryTrackingPolicyProvider(
89 forwarding_policy_provider_->Init(schema_registry); 89 connector->GetPlatformProvider()));
90 providers.push_back(forwarding_policy_provider_.get()); 90 wrapped_platform_policy_provider_->Init(schema_registry);
91 providers.push_back(wrapped_platform_policy_provider_.get());
91 } 92 }
92 93
93 #if defined(OS_CHROMEOS) 94 #if defined(OS_CHROMEOS)
94 if (connector->GetDeviceCloudPolicyManager()) 95 if (connector->GetDeviceCloudPolicyManager())
95 providers.push_back(connector->GetDeviceCloudPolicyManager()); 96 providers.push_back(connector->GetDeviceCloudPolicyManager());
96 #endif 97 #endif
97 98
98 if (user_cloud_policy_manager) 99 if (user_cloud_policy_manager)
99 providers.push_back(user_cloud_policy_manager); 100 providers.push_back(user_cloud_policy_manager);
100 101
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 137
137 void ProfilePolicyConnector::Shutdown() { 138 void ProfilePolicyConnector::Shutdown() {
138 #if defined(OS_CHROMEOS) 139 #if defined(OS_CHROMEOS)
139 BrowserPolicyConnectorChromeOS* connector = 140 BrowserPolicyConnectorChromeOS* connector =
140 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 141 g_browser_process->platform_part()->browser_policy_connector_chromeos();
141 if (is_primary_user_) 142 if (is_primary_user_)
142 connector->SetUserPolicyDelegate(NULL); 143 connector->SetUserPolicyDelegate(NULL);
143 if (special_user_policy_provider_) 144 if (special_user_policy_provider_)
144 special_user_policy_provider_->Shutdown(); 145 special_user_policy_provider_->Shutdown();
145 #endif 146 #endif
146 if (forwarding_policy_provider_) 147 if (wrapped_platform_policy_provider_)
147 forwarding_policy_provider_->Shutdown(); 148 wrapped_platform_policy_provider_->Shutdown();
148 } 149 }
149 150
150 bool ProfilePolicyConnector::IsManaged() const { 151 bool ProfilePolicyConnector::IsManaged() const {
151 return !GetManagementDomain().empty(); 152 return !GetManagementDomain().empty();
152 } 153 }
153 154
154 std::string ProfilePolicyConnector::GetManagementDomain() const { 155 std::string ProfilePolicyConnector::GetManagementDomain() const {
155 if (!user_cloud_policy_manager_) 156 if (!user_cloud_policy_manager_)
156 return ""; 157 return "";
157 CloudPolicyStore* store = user_cloud_policy_manager_->core()->store(); 158 CloudPolicyStore* store = user_cloud_policy_manager_->core()->store();
158 if (store && store->is_managed() && store->policy()->has_username()) 159 if (store && store->is_managed() && store->policy()->has_username())
159 return gaia::ExtractDomainName(store->policy()->username()); 160 return gaia::ExtractDomainName(store->policy()->username());
160 return ""; 161 return "";
161 } 162 }
162 163
163 bool ProfilePolicyConnector::IsPolicyFromCloudPolicy(const char* name) const { 164 bool ProfilePolicyConnector::IsPolicyFromCloudPolicy(const char* name) const {
164 if (!HasChromePolicy(user_cloud_policy_manager_, name)) 165 if (!HasChromePolicy(user_cloud_policy_manager_, name))
165 return false; 166 return false;
166 167
167 // Check all the providers that have higher priority than the 168 // Check all the providers that have higher priority than the
168 // |user_cloud_policy_manager_|. These checks must be kept in sync with the 169 // |user_cloud_policy_manager_|. These checks must be kept in sync with the
169 // order of the providers in Init(). 170 // order of the providers in Init().
170 171
171 if (HasChromePolicy(forwarding_policy_provider_.get(), name)) 172 if (HasChromePolicy(wrapped_platform_policy_provider_.get(), name))
172 return false; 173 return false;
173 174
174 #if defined(OS_CHROMEOS) 175 #if defined(OS_CHROMEOS)
175 BrowserPolicyConnectorChromeOS* connector = 176 BrowserPolicyConnectorChromeOS* connector =
176 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 177 g_browser_process->platform_part()->browser_policy_connector_chromeos();
177 if (HasChromePolicy(connector->GetDeviceCloudPolicyManager(), name)) 178 if (HasChromePolicy(connector->GetDeviceCloudPolicyManager(), name))
178 return false; 179 return false;
179 #endif 180 #endif
180 181
181 return true; 182 return true;
182 } 183 }
183 184
184 } // namespace policy 185 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/profile_policy_connector.h ('k') | components/components_tests.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698