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

Side by Side Diff: chrome/browser/ui/webui/policy_ui_handler.cc

Issue 2486813002: Add DeviceADPolicyManager to provide AD policy. (Closed)
Patch Set: Created 4 years, 1 month 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
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/ui/webui/policy_ui_handler.h" 5 #include "chrome/browser/ui/webui/policy_ui_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 17 matching lines...) Expand all
28 #include "chrome/browser/policy/schema_registry_service_factory.h" 28 #include "chrome/browser/policy/schema_registry_service_factory.h"
29 #include "chrome/browser/profiles/profile.h" 29 #include "chrome/browser/profiles/profile.h"
30 #include "chrome/grit/policy_resources.h" 30 #include "chrome/grit/policy_resources.h"
31 #include "chrome/grit/policy_resources_map.h" 31 #include "chrome/grit/policy_resources_map.h"
32 #include "components/policy/core/browser/browser_policy_connector.h" 32 #include "components/policy/core/browser/browser_policy_connector.h"
33 #include "components/policy/core/browser/cloud/message_util.h" 33 #include "components/policy/core/browser/cloud/message_util.h"
34 #include "components/policy/core/browser/configuration_policy_handler_list.h" 34 #include "components/policy/core/browser/configuration_policy_handler_list.h"
35 #include "components/policy/core/common/cloud/cloud_policy_client.h" 35 #include "components/policy/core/common/cloud/cloud_policy_client.h"
36 #include "components/policy/core/common/cloud/cloud_policy_constants.h" 36 #include "components/policy/core/common/cloud/cloud_policy_constants.h"
37 #include "components/policy/core/common/cloud/cloud_policy_core.h" 37 #include "components/policy/core/common/cloud/cloud_policy_core.h"
38 #include "components/policy/core/common/cloud/cloud_policy_manager.h"
38 #include "components/policy/core/common/cloud/cloud_policy_refresh_scheduler.h" 39 #include "components/policy/core/common/cloud/cloud_policy_refresh_scheduler.h"
39 #include "components/policy/core/common/cloud/cloud_policy_store.h" 40 #include "components/policy/core/common/cloud/cloud_policy_store.h"
40 #include "components/policy/core/common/cloud/cloud_policy_validator.h" 41 #include "components/policy/core/common/cloud/cloud_policy_validator.h"
41 #include "components/policy/core/common/policy_details.h" 42 #include "components/policy/core/common/policy_details.h"
42 #include "components/policy/core/common/policy_types.h" 43 #include "components/policy/core/common/policy_types.h"
43 #include "components/policy/core/common/remote_commands/remote_commands_service. h" 44 #include "components/policy/core/common/remote_commands/remote_commands_service. h"
44 #include "components/policy/core/common/schema.h" 45 #include "components/policy/core/common/schema.h"
45 #include "components/policy/core/common/schema_map.h" 46 #include "components/policy/core/common/schema_map.h"
46 #include "components/policy/policy_constants.h" 47 #include "components/policy/policy_constants.h"
47 #include "components/policy/proto/device_management_backend.pb.h" 48 #include "components/policy/proto/device_management_backend.pb.h"
48 #include "components/strings/grit/components_strings.h" 49 #include "components/strings/grit/components_strings.h"
49 #include "content/public/browser/web_contents.h" 50 #include "content/public/browser/web_contents.h"
50 #include "google_apis/gaia/gaia_auth_util.h" 51 #include "google_apis/gaia/gaia_auth_util.h"
51 #include "ui/base/l10n/l10n_util.h" 52 #include "ui/base/l10n/l10n_util.h"
52 #include "ui/base/l10n/time_format.h" 53 #include "ui/base/l10n/time_format.h"
53 54
54 #if defined(OS_CHROMEOS) 55 #if defined(OS_CHROMEOS)
55 #include "chrome/browser/browser_process_platform_part.h" 56 #include "chrome/browser/browser_process_platform_part.h"
56 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" 57 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
57 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" 58 #include "chrome/browser/chromeos/policy/device_ad_policy_manager.h"
59 #include "chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.h"
58 #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h" 60 #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h"
59 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" 61 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h"
60 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chrom eos.h" 62 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chrom eos.h"
63 #include "chrome/browser/chromeos/settings/install_attributes.h"
61 #include "components/user_manager/user_manager.h" 64 #include "components/user_manager/user_manager.h"
62 #else 65 #else
63 #include "chrome/browser/policy/cloud/user_cloud_policy_manager_factory.h" 66 #include "chrome/browser/policy/cloud/user_cloud_policy_manager_factory.h"
64 #include "components/policy/core/common/cloud/user_cloud_policy_manager.h" 67 #include "components/policy/core/common/cloud/user_cloud_policy_manager.h"
65 #endif 68 #endif
66 69
67 #if defined(ENABLE_EXTENSIONS) 70 #if defined(ENABLE_EXTENSIONS)
68 #include "extensions/browser/extension_registry.h" 71 #include "extensions/browser/extension_registry.h"
69 #include "extensions/common/extension.h" 72 #include "extensions/common/extension.h"
70 #include "extensions/common/manifest.h" 73 #include "extensions/common/manifest.h"
71 #include "extensions/common/manifest_constants.h" 74 #include "extensions/common/manifest_constants.h"
72 #endif 75 #endif
73 76
74 namespace em = enterprise_management; 77 namespace em = enterprise_management;
75 78
76 namespace { 79 namespace {
77 80
78 // Strings that map from PolicySource enum to i18n string keys and their IDs. 81 // Strings that map from PolicySource enum to i18n string keys and their IDs.
79 // Their order has to follow the order of the policy::PolicySource enum. 82 // Their order has to follow the order of the policy::PolicySource enum.
80 const PolicyStringMap kPolicySources[policy::POLICY_SOURCE_COUNT] = { 83 const PolicyStringMap kPolicySources[policy::POLICY_SOURCE_COUNT] = {
81 {"sourceEnterpriseDefault", IDS_POLICY_SOURCE_ENTERPRISE_DEFAULT}, 84 {"sourceEnterpriseDefault", IDS_POLICY_SOURCE_ENTERPRISE_DEFAULT},
82 {"sourceCloud", IDS_POLICY_SOURCE_CLOUD}, 85 {"sourceCloud", IDS_POLICY_SOURCE_CLOUD},
83 {"sourcePublicSessionOverride", IDS_POLICY_SOURCE_PUBLIC_SESSION_OVERRIDE}, 86 {"sourceActiveDirectory", IDS_POLICY_SOURCE_ACTIVE_DIRECTORY},
84 {"sourcePlatform", IDS_POLICY_SOURCE_PLATFORM}, 87 {"sourcePublicSessionOverride", IDS_POLICY_SOURCE_PUBLIC_SESSION_OVERRIDE},
88 {"sourcePlatform", IDS_POLICY_SOURCE_PLATFORM},
85 }; 89 };
86 90
87 // Formats the association state indicated by |data|. If |data| is NULL, the 91 // Formats the association state indicated by |data|. If |data| is NULL, the
88 // state is considered to be UNMANAGED. 92 // state is considered to be UNMANAGED.
89 base::string16 FormatAssociationState(const em::PolicyData* data) { 93 base::string16 FormatAssociationState(const em::PolicyData* data) {
90 if (data) { 94 if (data) {
91 switch (data->state()) { 95 switch (data->state()) {
92 case em::PolicyData::ACTIVE: 96 case em::PolicyData::ACTIVE:
93 return l10n_util::GetStringUTF16(IDS_POLICY_ASSOCIATION_STATE_ACTIVE); 97 return l10n_util::GetStringUTF16(IDS_POLICY_ASSOCIATION_STATE_ACTIVE);
94 case em::PolicyData::UNMANAGED: 98 case em::PolicyData::UNMANAGED:
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 if (list->GetDictionary(i, &dict)) 195 if (list->GetDictionary(i, &dict))
192 list->Set(i, DictionaryToJSONString(*dict)); 196 list->Set(i, DictionaryToJSONString(*dict));
193 } 197 }
194 } 198 }
195 199
196 return copy; 200 return copy;
197 } 201 }
198 202
199 } // namespace 203 } // namespace
200 204
201 // An interface for querying the status of cloud policy. 205 // An interface for querying the status of a policy provider. It surfaces
202 class CloudPolicyStatusProvider { 206 // things like last fetch time or status of the backing store, but not the
207 // actual policies themselves.
208 class PolicyStatusProvider {
203 public: 209 public:
204 CloudPolicyStatusProvider(); 210 PolicyStatusProvider();
205 virtual ~CloudPolicyStatusProvider(); 211 virtual ~PolicyStatusProvider();
206 212
207 // Sets a callback to invoke upon status changes. 213 // Sets a callback to invoke upon status changes.
208 void SetStatusChangeCallback(const base::Closure& callback); 214 void SetStatusChangeCallback(const base::Closure& callback);
209 215
210 virtual void GetStatus(base::DictionaryValue* dict); 216 virtual void GetStatus(base::DictionaryValue* dict);
211 217
212 protected: 218 protected:
213 void NotifyStatusChange(); 219 void NotifyStatusChange();
214 220
215 private: 221 private:
216 base::Closure callback_; 222 base::Closure callback_;
217 223
218 DISALLOW_COPY_AND_ASSIGN(CloudPolicyStatusProvider); 224 DISALLOW_COPY_AND_ASSIGN(PolicyStatusProvider);
219 }; 225 };
220 226
221 // Status provider implementation that pulls cloud policy status from a 227 // Status provider implementation that pulls cloud policy status from a
222 // CloudPolicyCore instance provided at construction time. Also listens for 228 // CloudPolicyCore instance provided at construction time. Also listens for
223 // changes on that CloudPolicyCore and reports them through the status change 229 // changes on that CloudPolicyCore and reports them through the status change
224 // callback. 230 // callback.
225 class CloudPolicyCoreStatusProvider 231 class CloudPolicyCoreStatusProvider
226 : public CloudPolicyStatusProvider, 232 : public PolicyStatusProvider,
227 public policy::CloudPolicyStore::Observer { 233 public policy::CloudPolicyStore::Observer {
228 public: 234 public:
229 explicit CloudPolicyCoreStatusProvider(policy::CloudPolicyCore* core); 235 explicit CloudPolicyCoreStatusProvider(policy::CloudPolicyCore* core);
230 ~CloudPolicyCoreStatusProvider() override; 236 ~CloudPolicyCoreStatusProvider() override;
231 237
232 // policy::CloudPolicyStore::Observer implementation. 238 // policy::CloudPolicyStore::Observer implementation.
233 void OnStoreLoaded(policy::CloudPolicyStore* store) override; 239 void OnStoreLoaded(policy::CloudPolicyStore* store) override;
234 void OnStoreError(policy::CloudPolicyStore* store) override; 240 void OnStoreError(policy::CloudPolicyStore* store) override;
235 241
236 protected: 242 protected:
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 DISALLOW_COPY_AND_ASSIGN(DevicePolicyStatusProvider); 278 DISALLOW_COPY_AND_ASSIGN(DevicePolicyStatusProvider);
273 }; 279 };
274 280
275 // A cloud policy status provider that reads policy status from the policy core 281 // A cloud policy status provider that reads policy status from the policy core
276 // associated with the device-local account specified by |user_id| at 282 // associated with the device-local account specified by |user_id| at
277 // construction time. The indirection via user ID and 283 // construction time. The indirection via user ID and
278 // DeviceLocalAccountPolicyService is necessary because the device-local account 284 // DeviceLocalAccountPolicyService is necessary because the device-local account
279 // may go away any time behind the scenes, at which point the status message 285 // may go away any time behind the scenes, at which point the status message
280 // text will indicate CloudPolicyStore::STATUS_BAD_STATE. 286 // text will indicate CloudPolicyStore::STATUS_BAD_STATE.
281 class DeviceLocalAccountPolicyStatusProvider 287 class DeviceLocalAccountPolicyStatusProvider
282 : public CloudPolicyStatusProvider, 288 : public PolicyStatusProvider,
283 public policy::DeviceLocalAccountPolicyService::Observer { 289 public policy::DeviceLocalAccountPolicyService::Observer {
284 public: 290 public:
285 DeviceLocalAccountPolicyStatusProvider( 291 DeviceLocalAccountPolicyStatusProvider(
286 const std::string& user_id, 292 const std::string& user_id,
287 policy::DeviceLocalAccountPolicyService* service); 293 policy::DeviceLocalAccountPolicyService* service);
288 ~DeviceLocalAccountPolicyStatusProvider() override; 294 ~DeviceLocalAccountPolicyStatusProvider() override;
289 295
290 // CloudPolicyStatusProvider implementation. 296 // PolicyStatusProvider implementation.
291 void GetStatus(base::DictionaryValue* dict) override; 297 void GetStatus(base::DictionaryValue* dict) override;
292 298
293 // policy::DeviceLocalAccountPolicyService::Observer implementation. 299 // policy::DeviceLocalAccountPolicyService::Observer implementation.
294 void OnPolicyUpdated(const std::string& user_id) override; 300 void OnPolicyUpdated(const std::string& user_id) override;
295 void OnDeviceLocalAccountsChanged() override; 301 void OnDeviceLocalAccountsChanged() override;
296 302
297 private: 303 private:
298 const std::string user_id_; 304 const std::string user_id_;
299 policy::DeviceLocalAccountPolicyService* service_; 305 policy::DeviceLocalAccountPolicyService* service_;
300 306
301 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyStatusProvider); 307 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyStatusProvider);
302 }; 308 };
309
310 class DeviceADPolicyStatusProvider : public PolicyStatusProvider {
emaxx 2016/11/11 15:25:09 Add a short comment for this class?
Thiemo Nagel 2016/11/16 19:11:01 Done.
311 public:
312 explicit DeviceADPolicyStatusProvider(policy::DeviceADPolicyManager* manager);
313 ~DeviceADPolicyStatusProvider() override = default;
emaxx 2016/11/11 15:25:09 Just curious: is this due to some compiler complai
Thiemo Nagel 2016/11/16 19:11:01 No. It's probably bad form because it creates an
314
315 // PolicyStatusProvider implementation.
316 void GetStatus(base::DictionaryValue* dict) override;
317
318 private:
319 const policy::CloudPolicyStore* store_;
320 };
303 #endif 321 #endif
304 322
305 CloudPolicyStatusProvider::CloudPolicyStatusProvider() { 323 PolicyStatusProvider::PolicyStatusProvider() {}
306 }
307 324
308 CloudPolicyStatusProvider::~CloudPolicyStatusProvider() { 325 PolicyStatusProvider::~PolicyStatusProvider() {}
309 }
310 326
311 void CloudPolicyStatusProvider::SetStatusChangeCallback( 327 void PolicyStatusProvider::SetStatusChangeCallback(
312 const base::Closure& callback) { 328 const base::Closure& callback) {
313 callback_ = callback; 329 callback_ = callback;
314 } 330 }
315 331
316 void CloudPolicyStatusProvider::GetStatus(base::DictionaryValue* dict) { 332 void PolicyStatusProvider::GetStatus(base::DictionaryValue* dict) {}
317 }
318 333
319 void CloudPolicyStatusProvider::NotifyStatusChange() { 334 void PolicyStatusProvider::NotifyStatusChange() {
320 if (!callback_.is_null()) 335 if (!callback_.is_null())
321 callback_.Run(); 336 callback_.Run();
322 } 337 }
323 338
324 CloudPolicyCoreStatusProvider::CloudPolicyCoreStatusProvider( 339 CloudPolicyCoreStatusProvider::CloudPolicyCoreStatusProvider(
325 policy::CloudPolicyCore* core) : core_(core) { 340 policy::CloudPolicyCore* core) : core_(core) {
326 core_->store()->AddObserver(this); 341 core_->store()->AddObserver(this);
327 // TODO(bartfab): Add an observer that watches for client errors. Observing 342 // TODO(bartfab): Add an observer that watches for client errors. Observing
328 // core_->client() directly is not safe as the client may be destroyed and 343 // core_->client() directly is not safe as the client may be destroyed and
329 // (re-)created anytime if the user signs in or out on desktop platforms. 344 // (re-)created anytime if the user signs in or out on desktop platforms.
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 421
407 void DeviceLocalAccountPolicyStatusProvider::OnPolicyUpdated( 422 void DeviceLocalAccountPolicyStatusProvider::OnPolicyUpdated(
408 const std::string& user_id) { 423 const std::string& user_id) {
409 if (user_id == user_id_) 424 if (user_id == user_id_)
410 NotifyStatusChange(); 425 NotifyStatusChange();
411 } 426 }
412 427
413 void DeviceLocalAccountPolicyStatusProvider::OnDeviceLocalAccountsChanged() { 428 void DeviceLocalAccountPolicyStatusProvider::OnDeviceLocalAccountsChanged() {
414 NotifyStatusChange(); 429 NotifyStatusChange();
415 } 430 }
416 #endif 431
432 DeviceADPolicyStatusProvider::DeviceADPolicyStatusProvider(
433 policy::DeviceADPolicyManager* manager)
434 : store_(manager->store()) {}
435
436 void DeviceADPolicyStatusProvider::GetStatus(base::DictionaryValue* dict) {
437 base::string16 status =
438 policy::FormatStoreStatus(store_->status(), store_->validation_status());
439 dict->SetString("status", status);
440 }
441
442 #endif // defined(OS_CHROMEOS)
417 443
418 PolicyUIHandler::PolicyUIHandler() 444 PolicyUIHandler::PolicyUIHandler()
419 : weak_factory_(this) { 445 : weak_factory_(this) {
420 } 446 }
421 447
422 PolicyUIHandler::~PolicyUIHandler() { 448 PolicyUIHandler::~PolicyUIHandler() {
423 GetPolicyService()->RemoveObserver(policy::POLICY_DOMAIN_CHROME, this); 449 GetPolicyService()->RemoveObserver(policy::POLICY_DOMAIN_CHROME, this);
424 GetPolicyService()->RemoveObserver(policy::POLICY_DOMAIN_EXTENSIONS, this); 450 GetPolicyService()->RemoveObserver(policy::POLICY_DOMAIN_EXTENSIONS, this);
425 policy::SchemaRegistry* registry = 451 policy::SchemaRegistry* registry =
426 policy::SchemaRegistryServiceFactory::GetForContext( 452 policy::SchemaRegistryServiceFactory::GetForContext(
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 source->AddLocalizedString("unset", IDS_POLICY_UNSET); 486 source->AddLocalizedString("unset", IDS_POLICY_UNSET);
461 source->AddLocalizedString("unknown", IDS_POLICY_UNKNOWN); 487 source->AddLocalizedString("unknown", IDS_POLICY_UNKNOWN);
462 source->AddLocalizedString("notSpecified", IDS_POLICY_NOT_SPECIFIED); 488 source->AddLocalizedString("notSpecified", IDS_POLICY_NOT_SPECIFIED);
463 source->SetJsonPath("strings.js"); 489 source->SetJsonPath("strings.js");
464 } 490 }
465 491
466 void PolicyUIHandler::RegisterMessages() { 492 void PolicyUIHandler::RegisterMessages() {
467 #if defined(OS_CHROMEOS) 493 #if defined(OS_CHROMEOS)
468 policy::BrowserPolicyConnectorChromeOS* connector = 494 policy::BrowserPolicyConnectorChromeOS* connector =
469 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 495 g_browser_process->platform_part()->browser_policy_connector_chromeos();
470 if (connector->IsEnterpriseManaged()) 496 if (connector->IsEnterpriseManaged()) {
471 device_status_provider_.reset(new DevicePolicyStatusProvider(connector)); 497 if (connector->GetDeviceADPolicyManager()) {
498 device_status_provider_ = base::MakeUnique<DeviceADPolicyStatusProvider>(
499 connector->GetDeviceADPolicyManager());
500 } else {
501 device_status_provider_ =
502 base::MakeUnique<DevicePolicyStatusProvider>(connector);
503 }
504 }
472 505
473 const user_manager::UserManager* user_manager = 506 const user_manager::UserManager* user_manager =
474 user_manager::UserManager::Get(); 507 user_manager::UserManager::Get();
475 if (user_manager->IsLoggedInAsPublicAccount()) { 508 if (user_manager->IsLoggedInAsPublicAccount()) {
476 policy::DeviceLocalAccountPolicyService* local_account_service = 509 policy::DeviceLocalAccountPolicyService* local_account_service =
477 connector->GetDeviceLocalAccountPolicyService(); 510 connector->GetDeviceLocalAccountPolicyService();
478 if (local_account_service) { 511 if (local_account_service) {
479 user_status_provider_.reset(new DeviceLocalAccountPolicyStatusProvider( 512 user_status_provider_.reset(new DeviceLocalAccountPolicyStatusProvider(
480 user_manager->GetLoggedInUser()->GetAccountId().GetUserEmail(), 513 user_manager->GetLoggedInUser()->GetAccountId().GetUserEmail(),
481 local_account_service)); 514 local_account_service));
(...skipping 11 matching lines...) Expand all
493 policy::UserCloudPolicyManager* user_cloud_policy_manager = 526 policy::UserCloudPolicyManager* user_cloud_policy_manager =
494 policy::UserCloudPolicyManagerFactory::GetForBrowserContext( 527 policy::UserCloudPolicyManagerFactory::GetForBrowserContext(
495 web_ui()->GetWebContents()->GetBrowserContext()); 528 web_ui()->GetWebContents()->GetBrowserContext());
496 if (user_cloud_policy_manager) { 529 if (user_cloud_policy_manager) {
497 user_status_provider_.reset( 530 user_status_provider_.reset(
498 new UserPolicyStatusProvider(user_cloud_policy_manager->core())); 531 new UserPolicyStatusProvider(user_cloud_policy_manager->core()));
499 } 532 }
500 #endif 533 #endif
501 534
502 if (!user_status_provider_.get()) 535 if (!user_status_provider_.get())
503 user_status_provider_.reset(new CloudPolicyStatusProvider()); 536 user_status_provider_.reset(new PolicyStatusProvider());
504 if (!device_status_provider_.get()) 537 if (!device_status_provider_.get())
505 device_status_provider_.reset(new CloudPolicyStatusProvider()); 538 device_status_provider_.reset(new PolicyStatusProvider());
506 539
507 base::Closure update_callback(base::Bind(&PolicyUIHandler::SendStatus, 540 base::Closure update_callback(base::Bind(&PolicyUIHandler::SendStatus,
508 base::Unretained(this))); 541 base::Unretained(this)));
509 user_status_provider_->SetStatusChangeCallback(update_callback); 542 user_status_provider_->SetStatusChangeCallback(update_callback);
510 device_status_provider_->SetStatusChangeCallback(update_callback); 543 device_status_provider_->SetStatusChangeCallback(update_callback);
511 GetPolicyService()->AddObserver(policy::POLICY_DOMAIN_CHROME, this); 544 GetPolicyService()->AddObserver(policy::POLICY_DOMAIN_CHROME, this);
512 GetPolicyService()->AddObserver(policy::POLICY_DOMAIN_EXTENSIONS, this); 545 GetPolicyService()->AddObserver(policy::POLICY_DOMAIN_EXTENSIONS, this);
513 546
514 #if defined(ENABLE_EXTENSIONS) 547 #if defined(ENABLE_EXTENSIONS)
515 extensions::ExtensionRegistry::Get(Profile::FromWebUI(web_ui())) 548 extensions::ExtensionRegistry::Get(Profile::FromWebUI(web_ui()))
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 SendPolicyValues(); 755 SendPolicyValues();
723 SendStatus(); 756 SendStatus();
724 } 757 }
725 758
726 void PolicyUIHandler::HandleReloadPolicies(const base::ListValue* args) { 759 void PolicyUIHandler::HandleReloadPolicies(const base::ListValue* args) {
727 #if defined(OS_CHROMEOS) 760 #if defined(OS_CHROMEOS)
728 // Allow user to manually fetch remote commands, in case invalidation 761 // Allow user to manually fetch remote commands, in case invalidation
729 // service is not working properly. 762 // service is not working properly.
730 // TODO(binjin): evaluate and possibly remove this after invalidation 763 // TODO(binjin): evaluate and possibly remove this after invalidation
731 // service is landed and tested. http://crbug.com/480982 764 // service is landed and tested. http://crbug.com/480982
732 policy::BrowserPolicyConnectorChromeOS* connector = 765 policy::CloudPolicyManager* manager =
733 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 766 g_browser_process->platform_part()
734 policy::RemoteCommandsService* remote_commands_service = 767 ->browser_policy_connector_chromeos()
735 connector->GetDeviceCloudPolicyManager() 768 ->GetDeviceCloudPolicyManager();
736 ->core() 769 if (manager) {
737 ->remote_commands_service(); 770 policy::RemoteCommandsService* remote_commands_service =
738 if (remote_commands_service) 771 manager->core()->remote_commands_service();
739 remote_commands_service->FetchRemoteCommands(); 772 if (remote_commands_service)
773 remote_commands_service->FetchRemoteCommands();
774 }
740 #endif 775 #endif
741 GetPolicyService()->RefreshPolicies(base::Bind( 776 GetPolicyService()->RefreshPolicies(base::Bind(
742 &PolicyUIHandler::OnRefreshPoliciesDone, weak_factory_.GetWeakPtr())); 777 &PolicyUIHandler::OnRefreshPoliciesDone, weak_factory_.GetWeakPtr()));
743 } 778 }
744 779
745 void PolicyUIHandler::OnRefreshPoliciesDone() const { 780 void PolicyUIHandler::OnRefreshPoliciesDone() const {
746 web_ui()->CallJavascriptFunctionUnsafe("policy.Page.reloadPoliciesDone"); 781 web_ui()->CallJavascriptFunctionUnsafe("policy.Page.reloadPoliciesDone");
747 } 782 }
748 783
749 policy::PolicyService* PolicyUIHandler::GetPolicyService() const { 784 policy::PolicyService* PolicyUIHandler::GetPolicyService() const {
750 return policy::ProfilePolicyConnectorFactory::GetForBrowserContext( 785 return policy::ProfilePolicyConnectorFactory::GetForBrowserContext(
751 web_ui()->GetWebContents()->GetBrowserContext())->policy_service(); 786 web_ui()->GetWebContents()->GetBrowserContext())->policy_service();
752 } 787 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698