OLD | NEW |
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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 #if defined(OS_CHROMEOS) | 124 #if defined(OS_CHROMEOS) |
125 if (is_primary_user_) { | 125 if (is_primary_user_) { |
126 if (user_cloud_policy_manager) | 126 if (user_cloud_policy_manager) |
127 connector->SetUserPolicyDelegate(user_cloud_policy_manager); | 127 connector->SetUserPolicyDelegate(user_cloud_policy_manager); |
128 else if (special_user_policy_provider_) | 128 else if (special_user_policy_provider_) |
129 connector->SetUserPolicyDelegate(special_user_policy_provider_.get()); | 129 connector->SetUserPolicyDelegate(special_user_policy_provider_.get()); |
130 } | 130 } |
131 #endif | 131 #endif |
132 } | 132 } |
133 | 133 |
134 void ProfilePolicyConnector::InitForTesting(scoped_ptr<PolicyService> service) { | 134 void ProfilePolicyConnector::InitForTesting( |
| 135 scoped_ptr<PolicyService> service, |
| 136 CloudPolicyManager* user_cloud_policy_manager) { |
135 policy_service_ = service.Pass(); | 137 policy_service_ = service.Pass(); |
| 138 user_cloud_policy_manager_ = user_cloud_policy_manager; |
136 } | 139 } |
137 | 140 |
138 void ProfilePolicyConnector::Shutdown() { | 141 void ProfilePolicyConnector::Shutdown() { |
139 #if defined(OS_CHROMEOS) | 142 #if defined(OS_CHROMEOS) |
140 BrowserPolicyConnectorChromeOS* connector = | 143 BrowserPolicyConnectorChromeOS* connector = |
141 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 144 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
142 if (is_primary_user_) | 145 if (is_primary_user_) |
143 connector->SetUserPolicyDelegate(NULL); | 146 connector->SetUserPolicyDelegate(NULL); |
144 if (special_user_policy_provider_) | 147 if (special_user_policy_provider_) |
145 special_user_policy_provider_->Shutdown(); | 148 special_user_policy_provider_->Shutdown(); |
146 #endif | 149 #endif |
147 if (wrapped_platform_policy_provider_) | 150 if (wrapped_platform_policy_provider_) |
148 wrapped_platform_policy_provider_->Shutdown(); | 151 wrapped_platform_policy_provider_->Shutdown(); |
149 } | 152 } |
150 | 153 |
151 bool ProfilePolicyConnector::IsManaged() const { | 154 bool ProfilePolicyConnector::IsManaged() const { |
152 return !GetManagementDomain().empty(); | 155 return !GetManagementDomain().empty(); |
153 } | 156 } |
154 | 157 |
155 std::string ProfilePolicyConnector::GetManagementDomain() const { | 158 std::string ProfilePolicyConnector::GetManagementDomain() const { |
| 159 LOG(ERROR) << "cloud policy mgr " << user_cloud_policy_manager_; |
156 if (!user_cloud_policy_manager_) | 160 if (!user_cloud_policy_manager_) |
157 return ""; | 161 return ""; |
158 CloudPolicyStore* store = user_cloud_policy_manager_->core()->store(); | 162 CloudPolicyStore* store = user_cloud_policy_manager_->core()->store(); |
| 163 LOG(ERROR) << "store " << (store != nullptr) << " is_managed " |
| 164 << (store ? store->is_managed() : false); |
159 if (store && store->is_managed() && store->policy()->has_username()) | 165 if (store && store->is_managed() && store->policy()->has_username()) |
160 return gaia::ExtractDomainName(store->policy()->username()); | 166 return gaia::ExtractDomainName(store->policy()->username()); |
161 return ""; | 167 return ""; |
162 } | 168 } |
163 | 169 |
164 bool ProfilePolicyConnector::IsPolicyFromCloudPolicy(const char* name) const { | 170 bool ProfilePolicyConnector::IsPolicyFromCloudPolicy(const char* name) const { |
165 if (!HasChromePolicy(user_cloud_policy_manager_, name)) | 171 if (!HasChromePolicy(user_cloud_policy_manager_, name)) |
166 return false; | 172 return false; |
167 | 173 |
168 // Check all the providers that have higher priority than the | 174 // Check all the providers that have higher priority than the |
169 // |user_cloud_policy_manager_|. These checks must be kept in sync with the | 175 // |user_cloud_policy_manager_|. These checks must be kept in sync with the |
170 // order of the providers in Init(). | 176 // order of the providers in Init(). |
171 | 177 |
172 if (HasChromePolicy(wrapped_platform_policy_provider_.get(), name)) | 178 if (HasChromePolicy(wrapped_platform_policy_provider_.get(), name)) |
173 return false; | 179 return false; |
174 | 180 |
175 #if defined(OS_CHROMEOS) | 181 #if defined(OS_CHROMEOS) |
176 BrowserPolicyConnectorChromeOS* connector = | 182 BrowserPolicyConnectorChromeOS* connector = |
177 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 183 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
178 if (HasChromePolicy(connector->GetDeviceCloudPolicyManager(), name)) | 184 if (HasChromePolicy(connector->GetDeviceCloudPolicyManager(), name)) |
179 return false; | 185 return false; |
180 #endif | 186 #endif |
181 | 187 |
182 return true; | 188 return true; |
183 } | 189 } |
184 | 190 |
185 } // namespace policy | 191 } // namespace policy |
OLD | NEW |