| OLD | NEW |
| 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.h" | 5 #include "chrome/browser/ui/webui/policy_ui.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 | 258 |
| 259 // Status provider implementation that pulls cloud policy status from a | 259 // Status provider implementation that pulls cloud policy status from a |
| 260 // CloudPolicyCore instance provided at construction time. Also listens for | 260 // CloudPolicyCore instance provided at construction time. Also listens for |
| 261 // changes on that CloudPolicyCore and reports them through the status change | 261 // changes on that CloudPolicyCore and reports them through the status change |
| 262 // callback. | 262 // callback. |
| 263 class CloudPolicyCoreStatusProvider | 263 class CloudPolicyCoreStatusProvider |
| 264 : public CloudPolicyStatusProvider, | 264 : public CloudPolicyStatusProvider, |
| 265 public policy::CloudPolicyStore::Observer { | 265 public policy::CloudPolicyStore::Observer { |
| 266 public: | 266 public: |
| 267 explicit CloudPolicyCoreStatusProvider(policy::CloudPolicyCore* core); | 267 explicit CloudPolicyCoreStatusProvider(policy::CloudPolicyCore* core); |
| 268 virtual ~CloudPolicyCoreStatusProvider(); | 268 ~CloudPolicyCoreStatusProvider() override; |
| 269 | 269 |
| 270 // policy::CloudPolicyStore::Observer implementation. | 270 // policy::CloudPolicyStore::Observer implementation. |
| 271 virtual void OnStoreLoaded(policy::CloudPolicyStore* store) override; | 271 void OnStoreLoaded(policy::CloudPolicyStore* store) override; |
| 272 virtual void OnStoreError(policy::CloudPolicyStore* store) override; | 272 void OnStoreError(policy::CloudPolicyStore* store) override; |
| 273 | 273 |
| 274 protected: | 274 protected: |
| 275 // Policy status is read from the CloudPolicyClient, CloudPolicyStore and | 275 // Policy status is read from the CloudPolicyClient, CloudPolicyStore and |
| 276 // CloudPolicyRefreshScheduler hosted by this |core_|. | 276 // CloudPolicyRefreshScheduler hosted by this |core_|. |
| 277 policy::CloudPolicyCore* core_; | 277 policy::CloudPolicyCore* core_; |
| 278 | 278 |
| 279 private: | 279 private: |
| 280 DISALLOW_COPY_AND_ASSIGN(CloudPolicyCoreStatusProvider); | 280 DISALLOW_COPY_AND_ASSIGN(CloudPolicyCoreStatusProvider); |
| 281 }; | 281 }; |
| 282 | 282 |
| 283 // A cloud policy status provider for user policy. | 283 // A cloud policy status provider for user policy. |
| 284 class UserPolicyStatusProvider : public CloudPolicyCoreStatusProvider { | 284 class UserPolicyStatusProvider : public CloudPolicyCoreStatusProvider { |
| 285 public: | 285 public: |
| 286 explicit UserPolicyStatusProvider(policy::CloudPolicyCore* core); | 286 explicit UserPolicyStatusProvider(policy::CloudPolicyCore* core); |
| 287 virtual ~UserPolicyStatusProvider(); | 287 ~UserPolicyStatusProvider() override; |
| 288 | 288 |
| 289 // CloudPolicyCoreStatusProvider implementation. | 289 // CloudPolicyCoreStatusProvider implementation. |
| 290 virtual void GetStatus(base::DictionaryValue* dict) override; | 290 void GetStatus(base::DictionaryValue* dict) override; |
| 291 | 291 |
| 292 private: | 292 private: |
| 293 DISALLOW_COPY_AND_ASSIGN(UserPolicyStatusProvider); | 293 DISALLOW_COPY_AND_ASSIGN(UserPolicyStatusProvider); |
| 294 }; | 294 }; |
| 295 | 295 |
| 296 #if defined(OS_CHROMEOS) | 296 #if defined(OS_CHROMEOS) |
| 297 // A cloud policy status provider for device policy. | 297 // A cloud policy status provider for device policy. |
| 298 class DevicePolicyStatusProvider : public CloudPolicyCoreStatusProvider { | 298 class DevicePolicyStatusProvider : public CloudPolicyCoreStatusProvider { |
| 299 public: | 299 public: |
| 300 explicit DevicePolicyStatusProvider( | 300 explicit DevicePolicyStatusProvider( |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyStatusProvider); | 339 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyStatusProvider); |
| 340 }; | 340 }; |
| 341 #endif | 341 #endif |
| 342 | 342 |
| 343 // The JavaScript message handler for the chrome://policy page. | 343 // The JavaScript message handler for the chrome://policy page. |
| 344 class PolicyUIHandler : public content::NotificationObserver, | 344 class PolicyUIHandler : public content::NotificationObserver, |
| 345 public content::WebUIMessageHandler, | 345 public content::WebUIMessageHandler, |
| 346 public policy::PolicyService::Observer { | 346 public policy::PolicyService::Observer { |
| 347 public: | 347 public: |
| 348 PolicyUIHandler(); | 348 PolicyUIHandler(); |
| 349 virtual ~PolicyUIHandler(); | 349 ~PolicyUIHandler() override; |
| 350 | 350 |
| 351 // content::NotificationObserver implementation. | 351 // content::NotificationObserver implementation. |
| 352 virtual void Observe(int type, | 352 void Observe(int type, |
| 353 const content::NotificationSource& source, | 353 const content::NotificationSource& source, |
| 354 const content::NotificationDetails& details) override; | 354 const content::NotificationDetails& details) override; |
| 355 | 355 |
| 356 // content::WebUIMessageHandler implementation. | 356 // content::WebUIMessageHandler implementation. |
| 357 virtual void RegisterMessages() override; | 357 void RegisterMessages() override; |
| 358 | 358 |
| 359 // policy::PolicyService::Observer implementation. | 359 // policy::PolicyService::Observer implementation. |
| 360 virtual void OnPolicyUpdated(const policy::PolicyNamespace& ns, | 360 void OnPolicyUpdated(const policy::PolicyNamespace& ns, |
| 361 const policy::PolicyMap& previous, | 361 const policy::PolicyMap& previous, |
| 362 const policy::PolicyMap& current) override; | 362 const policy::PolicyMap& current) override; |
| 363 | 363 |
| 364 private: | 364 private: |
| 365 // Send a dictionary containing the names of all known policies to the UI. | 365 // Send a dictionary containing the names of all known policies to the UI. |
| 366 void SendPolicyNames() const; | 366 void SendPolicyNames() const; |
| 367 | 367 |
| 368 // Send information about the current policy values to the UI. For each policy | 368 // Send information about the current policy values to the UI. For each policy |
| 369 // whose value has been set, a dictionary containing the value and additional | 369 // whose value has been set, a dictionary containing the value and additional |
| 370 // metadata is sent. | 370 // metadata is sent. |
| 371 void SendPolicyValues() const; | 371 void SendPolicyValues() const; |
| 372 | 372 |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 795 } | 795 } |
| 796 | 796 |
| 797 PolicyUI::PolicyUI(content::WebUI* web_ui) : WebUIController(web_ui) { | 797 PolicyUI::PolicyUI(content::WebUI* web_ui) : WebUIController(web_ui) { |
| 798 web_ui->AddMessageHandler(new PolicyUIHandler); | 798 web_ui->AddMessageHandler(new PolicyUIHandler); |
| 799 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), | 799 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), |
| 800 CreatePolicyUIHTMLSource()); | 800 CreatePolicyUIHTMLSource()); |
| 801 } | 801 } |
| 802 | 802 |
| 803 PolicyUI::~PolicyUI() { | 803 PolicyUI::~PolicyUI() { |
| 804 } | 804 } |
| OLD | NEW |