| 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 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 virtual ~CloudPolicyCoreStatusProvider(); |
| 269 | 269 |
| 270 // policy::CloudPolicyStore::Observer implementation. | 270 // policy::CloudPolicyStore::Observer implementation. |
| 271 virtual void OnStoreLoaded(policy::CloudPolicyStore* store) OVERRIDE; | 271 virtual void OnStoreLoaded(policy::CloudPolicyStore* store) override; |
| 272 virtual void OnStoreError(policy::CloudPolicyStore* store) OVERRIDE; | 272 virtual 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 DISALLOW_COPY_AND_ASSIGN(CloudPolicyCoreStatusProvider); | 279 DISALLOW_COPY_AND_ASSIGN(CloudPolicyCoreStatusProvider); |
| 280 }; | 280 }; |
| 281 | 281 |
| 282 // A cloud policy status provider for user policy. | 282 // A cloud policy status provider for user policy. |
| 283 class UserPolicyStatusProvider : public CloudPolicyCoreStatusProvider { | 283 class UserPolicyStatusProvider : public CloudPolicyCoreStatusProvider { |
| 284 public: | 284 public: |
| 285 explicit UserPolicyStatusProvider(policy::CloudPolicyCore* core); | 285 explicit UserPolicyStatusProvider(policy::CloudPolicyCore* core); |
| 286 virtual ~UserPolicyStatusProvider(); | 286 virtual ~UserPolicyStatusProvider(); |
| 287 | 287 |
| 288 // CloudPolicyCoreStatusProvider implementation. | 288 // CloudPolicyCoreStatusProvider implementation. |
| 289 virtual void GetStatus(base::DictionaryValue* dict) OVERRIDE; | 289 virtual void GetStatus(base::DictionaryValue* dict) override; |
| 290 | 290 |
| 291 private: | 291 private: |
| 292 DISALLOW_COPY_AND_ASSIGN(UserPolicyStatusProvider); | 292 DISALLOW_COPY_AND_ASSIGN(UserPolicyStatusProvider); |
| 293 }; | 293 }; |
| 294 | 294 |
| 295 #if defined(OS_CHROMEOS) | 295 #if defined(OS_CHROMEOS) |
| 296 // A cloud policy status provider for device policy. | 296 // A cloud policy status provider for device policy. |
| 297 class DevicePolicyStatusProvider : public CloudPolicyCoreStatusProvider { | 297 class DevicePolicyStatusProvider : public CloudPolicyCoreStatusProvider { |
| 298 public: | 298 public: |
| 299 explicit DevicePolicyStatusProvider( | 299 explicit DevicePolicyStatusProvider( |
| 300 policy::BrowserPolicyConnectorChromeOS* connector); | 300 policy::BrowserPolicyConnectorChromeOS* connector); |
| 301 virtual ~DevicePolicyStatusProvider(); | 301 virtual ~DevicePolicyStatusProvider(); |
| 302 | 302 |
| 303 // CloudPolicyCoreStatusProvider implementation. | 303 // CloudPolicyCoreStatusProvider implementation. |
| 304 virtual void GetStatus(base::DictionaryValue* dict) OVERRIDE; | 304 virtual void GetStatus(base::DictionaryValue* dict) override; |
| 305 | 305 |
| 306 private: | 306 private: |
| 307 std::string domain_; | 307 std::string domain_; |
| 308 | 308 |
| 309 DISALLOW_COPY_AND_ASSIGN(DevicePolicyStatusProvider); | 309 DISALLOW_COPY_AND_ASSIGN(DevicePolicyStatusProvider); |
| 310 }; | 310 }; |
| 311 | 311 |
| 312 // A cloud policy status provider that reads policy status from the policy core | 312 // A cloud policy status provider that reads policy status from the policy core |
| 313 // associated with the device-local account specified by |user_id| at | 313 // associated with the device-local account specified by |user_id| at |
| 314 // construction time. The indirection via user ID and | 314 // construction time. The indirection via user ID and |
| 315 // DeviceLocalAccountPolicyService is necessary because the device-local account | 315 // DeviceLocalAccountPolicyService is necessary because the device-local account |
| 316 // may go away any time behind the scenes, at which point the status message | 316 // may go away any time behind the scenes, at which point the status message |
| 317 // text will indicate CloudPolicyStore::STATUS_BAD_STATE. | 317 // text will indicate CloudPolicyStore::STATUS_BAD_STATE. |
| 318 class DeviceLocalAccountPolicyStatusProvider | 318 class DeviceLocalAccountPolicyStatusProvider |
| 319 : public CloudPolicyStatusProvider, | 319 : public CloudPolicyStatusProvider, |
| 320 public policy::DeviceLocalAccountPolicyService::Observer { | 320 public policy::DeviceLocalAccountPolicyService::Observer { |
| 321 public: | 321 public: |
| 322 DeviceLocalAccountPolicyStatusProvider( | 322 DeviceLocalAccountPolicyStatusProvider( |
| 323 const std::string& user_id, | 323 const std::string& user_id, |
| 324 policy::DeviceLocalAccountPolicyService* service); | 324 policy::DeviceLocalAccountPolicyService* service); |
| 325 virtual ~DeviceLocalAccountPolicyStatusProvider(); | 325 virtual ~DeviceLocalAccountPolicyStatusProvider(); |
| 326 | 326 |
| 327 // CloudPolicyStatusProvider implementation. | 327 // CloudPolicyStatusProvider implementation. |
| 328 virtual void GetStatus(base::DictionaryValue* dict) OVERRIDE; | 328 virtual void GetStatus(base::DictionaryValue* dict) override; |
| 329 | 329 |
| 330 // policy::DeviceLocalAccountPolicyService::Observer implementation. | 330 // policy::DeviceLocalAccountPolicyService::Observer implementation. |
| 331 virtual void OnPolicyUpdated(const std::string& user_id) OVERRIDE; | 331 virtual void OnPolicyUpdated(const std::string& user_id) override; |
| 332 virtual void OnDeviceLocalAccountsChanged() OVERRIDE; | 332 virtual void OnDeviceLocalAccountsChanged() override; |
| 333 | 333 |
| 334 private: | 334 private: |
| 335 const std::string user_id_; | 335 const std::string user_id_; |
| 336 policy::DeviceLocalAccountPolicyService* service_; | 336 policy::DeviceLocalAccountPolicyService* service_; |
| 337 | 337 |
| 338 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyStatusProvider); | 338 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyStatusProvider); |
| 339 }; | 339 }; |
| 340 #endif | 340 #endif |
| 341 | 341 |
| 342 // The JavaScript message handler for the chrome://policy page. | 342 // The JavaScript message handler for the chrome://policy page. |
| 343 class PolicyUIHandler : public content::NotificationObserver, | 343 class PolicyUIHandler : public content::NotificationObserver, |
| 344 public content::WebUIMessageHandler, | 344 public content::WebUIMessageHandler, |
| 345 public policy::PolicyService::Observer { | 345 public policy::PolicyService::Observer { |
| 346 public: | 346 public: |
| 347 PolicyUIHandler(); | 347 PolicyUIHandler(); |
| 348 virtual ~PolicyUIHandler(); | 348 virtual ~PolicyUIHandler(); |
| 349 | 349 |
| 350 // content::NotificationObserver implementation. | 350 // content::NotificationObserver implementation. |
| 351 virtual void Observe(int type, | 351 virtual void Observe(int type, |
| 352 const content::NotificationSource& source, | 352 const content::NotificationSource& source, |
| 353 const content::NotificationDetails& details) OVERRIDE; | 353 const content::NotificationDetails& details) override; |
| 354 | 354 |
| 355 // content::WebUIMessageHandler implementation. | 355 // content::WebUIMessageHandler implementation. |
| 356 virtual void RegisterMessages() OVERRIDE; | 356 virtual void RegisterMessages() override; |
| 357 | 357 |
| 358 // policy::PolicyService::Observer implementation. | 358 // policy::PolicyService::Observer implementation. |
| 359 virtual void OnPolicyUpdated(const policy::PolicyNamespace& ns, | 359 virtual void OnPolicyUpdated(const policy::PolicyNamespace& ns, |
| 360 const policy::PolicyMap& previous, | 360 const policy::PolicyMap& previous, |
| 361 const policy::PolicyMap& current) OVERRIDE; | 361 const policy::PolicyMap& current) override; |
| 362 | 362 |
| 363 private: | 363 private: |
| 364 // Send a dictionary containing the names of all known policies to the UI. | 364 // Send a dictionary containing the names of all known policies to the UI. |
| 365 void SendPolicyNames() const; | 365 void SendPolicyNames() const; |
| 366 | 366 |
| 367 // Send information about the current policy values to the UI. For each policy | 367 // Send information about the current policy values to the UI. For each policy |
| 368 // whose value has been set, a dictionary containing the value and additional | 368 // whose value has been set, a dictionary containing the value and additional |
| 369 // metadata is sent. | 369 // metadata is sent. |
| 370 void SendPolicyValues() const; | 370 void SendPolicyValues() const; |
| 371 | 371 |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 788 } | 788 } |
| 789 | 789 |
| 790 PolicyUI::PolicyUI(content::WebUI* web_ui) : WebUIController(web_ui) { | 790 PolicyUI::PolicyUI(content::WebUI* web_ui) : WebUIController(web_ui) { |
| 791 web_ui->AddMessageHandler(new PolicyUIHandler); | 791 web_ui->AddMessageHandler(new PolicyUIHandler); |
| 792 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), | 792 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), |
| 793 CreatePolicyUIHTMLSource()); | 793 CreatePolicyUIHTMLSource()); |
| 794 } | 794 } |
| 795 | 795 |
| 796 PolicyUI::~PolicyUI() { | 796 PolicyUI::~PolicyUI() { |
| 797 } | 797 } |
| OLD | NEW |