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

Unified Diff: chrome/browser/policy/profile_policy_connector.cc

Issue 304183007: Added ProfilePolicyConnector::IsFromCloudPolicy(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
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 583f15977420dbf7df3cc152780618e105444c35..bca188abde46070d1c38553e30d8fe81481826a3 100644
--- a/chrome/browser/policy/profile_policy_connector.cc
+++ b/chrome/browser/policy/profile_policy_connector.cc
@@ -30,6 +30,18 @@
namespace policy {
+namespace {
+
+bool HasChromePolicy(ConfigurationPolicyProvider* provider,
+ const char* name) {
+ if (!provider)
+ return false;
+ PolicyNamespace chrome_ns(POLICY_DOMAIN_CHROME, "");
+ return provider->policies().Get(chrome_ns).Get(name) != NULL;
+}
+
+} // namespace
+
ProfilePolicyConnector::ProfilePolicyConnector()
#if defined(OS_CHROMEOS)
: is_primary_user_(false),
@@ -58,6 +70,9 @@ void ProfilePolicyConnector::Init(
// use the policies exposed by the PolicyService!
// The default ConfigurationPolicyProvider::IsInitializationComplete()
// result is true, so take care if a provider overrides that.
+ //
+ // Note: if you append a new provider then make sure IsPolicyFromCloudPolicy()
+ // is also updated below.
std::vector<ConfigurationPolicyProvider*> providers;
#if defined(OS_CHROMEOS)
@@ -144,4 +159,25 @@ std::string ProfilePolicyConnector::GetManagementDomain() const {
return "";
}
+bool ProfilePolicyConnector::IsPolicyFromCloudPolicy(const char* name) const {
+ if (!HasChromePolicy(user_cloud_policy_manager_, name))
+ return false;
+
+ // Check all the providers that have higher priority than the
+ // |user_cloud_policy_manager_|. These checks must be kept in sync with the
+ // order of the providers in Init().
+
+ if (HasChromePolicy(forwarding_policy_provider_.get(), name))
+ return false;
+
+#if defined(OS_CHROMEOS)
+ BrowserPolicyConnectorChromeOS* connector =
+ g_browser_process->platform_part()->browser_policy_connector_chromeos();
+ if (HasChromePolicy(connector->GetDeviceCloudPolicyManager(), name))
+ return false;
+#endif
+
+ return true;
+}
+
} // namespace policy
« no previous file with comments | « chrome/browser/policy/profile_policy_connector.h ('k') | chrome/browser/policy/profile_policy_connector_stub.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698