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

Side by Side 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, 6 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) 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"
(...skipping 12 matching lines...) Expand all
23 #include "chrome/browser/chromeos/login/users/user.h" 23 #include "chrome/browser/chromeos/login/users/user.h"
24 #include "chrome/browser/chromeos/login/users/user_manager.h" 24 #include "chrome/browser/chromeos/login/users/user_manager.h"
25 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" 25 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
26 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" 26 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h"
27 #include "chrome/browser/chromeos/policy/device_local_account_policy_provider.h" 27 #include "chrome/browser/chromeos/policy/device_local_account_policy_provider.h"
28 #include "chrome/browser/chromeos/policy/login_profile_policy_provider.h" 28 #include "chrome/browser/chromeos/policy/login_profile_policy_provider.h"
29 #endif 29 #endif
30 30
31 namespace policy { 31 namespace policy {
32 32
33 namespace {
34
35 bool HasChromePolicy(ConfigurationPolicyProvider* provider,
36 const char* name) {
37 if (!provider)
38 return false;
39 PolicyNamespace chrome_ns(POLICY_DOMAIN_CHROME, "");
40 return provider->policies().Get(chrome_ns).Get(name) != NULL;
41 }
42
43 } // namespace
44
33 ProfilePolicyConnector::ProfilePolicyConnector() 45 ProfilePolicyConnector::ProfilePolicyConnector()
34 #if defined(OS_CHROMEOS) 46 #if defined(OS_CHROMEOS)
35 : is_primary_user_(false), 47 : is_primary_user_(false),
36 user_cloud_policy_manager_(NULL) 48 user_cloud_policy_manager_(NULL)
37 #else 49 #else
38 : user_cloud_policy_manager_(NULL) 50 : user_cloud_policy_manager_(NULL)
39 #endif 51 #endif
40 {} 52 {}
41 53
42 ProfilePolicyConnector::~ProfilePolicyConnector() {} 54 ProfilePolicyConnector::~ProfilePolicyConnector() {}
43 55
44 void ProfilePolicyConnector::Init( 56 void ProfilePolicyConnector::Init(
45 bool force_immediate_load, 57 bool force_immediate_load,
46 #if defined(OS_CHROMEOS) 58 #if defined(OS_CHROMEOS)
47 const chromeos::User* user, 59 const chromeos::User* user,
48 #endif 60 #endif
49 SchemaRegistry* schema_registry, 61 SchemaRegistry* schema_registry,
50 CloudPolicyManager* user_cloud_policy_manager) { 62 CloudPolicyManager* user_cloud_policy_manager) {
51 user_cloud_policy_manager_ = user_cloud_policy_manager; 63 user_cloud_policy_manager_ = user_cloud_policy_manager;
52 64
53 // |providers| contains a list of the policy providers available for the 65 // |providers| contains a list of the policy providers available for the
54 // PolicyService of this connector, in decreasing order of priority. 66 // PolicyService of this connector, in decreasing order of priority.
55 // 67 //
56 // Note: all the providers appended to this vector must eventually become 68 // Note: all the providers appended to this vector must eventually become
57 // initialized for every policy domain, otherwise some subsystems will never 69 // initialized for every policy domain, otherwise some subsystems will never
58 // use the policies exposed by the PolicyService! 70 // use the policies exposed by the PolicyService!
59 // The default ConfigurationPolicyProvider::IsInitializationComplete() 71 // The default ConfigurationPolicyProvider::IsInitializationComplete()
60 // result is true, so take care if a provider overrides that. 72 // result is true, so take care if a provider overrides that.
73 //
74 // Note: if you append a new provider then make sure IsPolicyFromCloudPolicy()
75 // is also updated below.
61 std::vector<ConfigurationPolicyProvider*> providers; 76 std::vector<ConfigurationPolicyProvider*> providers;
62 77
63 #if defined(OS_CHROMEOS) 78 #if defined(OS_CHROMEOS)
64 BrowserPolicyConnectorChromeOS* connector = 79 BrowserPolicyConnectorChromeOS* connector =
65 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 80 g_browser_process->platform_part()->browser_policy_connector_chromeos();
66 #else 81 #else
67 BrowserPolicyConnector* connector = 82 BrowserPolicyConnector* connector =
68 g_browser_process->browser_policy_connector(); 83 g_browser_process->browser_policy_connector();
69 #endif 84 #endif
70 85
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 152
138 std::string ProfilePolicyConnector::GetManagementDomain() const { 153 std::string ProfilePolicyConnector::GetManagementDomain() const {
139 if (!user_cloud_policy_manager_) 154 if (!user_cloud_policy_manager_)
140 return ""; 155 return "";
141 CloudPolicyStore* store = user_cloud_policy_manager_->core()->store(); 156 CloudPolicyStore* store = user_cloud_policy_manager_->core()->store();
142 if (store && store->is_managed() && store->policy()->has_username()) 157 if (store && store->is_managed() && store->policy()->has_username())
143 return gaia::ExtractDomainName(store->policy()->username()); 158 return gaia::ExtractDomainName(store->policy()->username());
144 return ""; 159 return "";
145 } 160 }
146 161
162 bool ProfilePolicyConnector::IsPolicyFromCloudPolicy(const char* name) const {
163 if (!HasChromePolicy(user_cloud_policy_manager_, name))
164 return false;
165
166 // Check all the providers that have higher priority than the
167 // |user_cloud_policy_manager_|. These checks must be kept in sync with the
168 // order of the providers in Init().
169
170 if (HasChromePolicy(forwarding_policy_provider_.get(), name))
171 return false;
172
173 #if defined(OS_CHROMEOS)
174 BrowserPolicyConnectorChromeOS* connector =
175 g_browser_process->platform_part()->browser_policy_connector_chromeos();
176 if (HasChromePolicy(connector->GetDeviceCloudPolicyManager(), name))
177 return false;
178 #endif
179
180 return true;
181 }
182
147 } // namespace policy 183 } // namespace policy
OLDNEW
« 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