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

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

Issue 14927015: Translate device-local account IDs to user IDs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix forward declaration. Created 7 years, 7 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) 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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 // CloudPolicyCoreStatusProvider implementation. 221 // CloudPolicyCoreStatusProvider implementation.
222 virtual void GetStatus(base::DictionaryValue* dict) OVERRIDE; 222 virtual void GetStatus(base::DictionaryValue* dict) OVERRIDE;
223 223
224 private: 224 private:
225 std::string domain_; 225 std::string domain_;
226 226
227 DISALLOW_COPY_AND_ASSIGN(DevicePolicyStatusProvider); 227 DISALLOW_COPY_AND_ASSIGN(DevicePolicyStatusProvider);
228 }; 228 };
229 229
230 // A cloud policy status provider that reads policy status from the policy core 230 // A cloud policy status provider that reads policy status from the policy core
231 // associated with the device-local account specified by |account_id| at 231 // associated with the device-local account specified by |user_id| at
232 // construction time. The indirection via account ID and 232 // construction time. The indirection via user ID and
233 // DeviceLocalAccountPolicyService is necessary because the device-local account 233 // DeviceLocalAccountPolicyService is necessary because the device-local account
234 // may go away any time behind the scenes, at which point the status message 234 // may go away any time behind the scenes, at which point the status message
235 // text will indicate CloudPolicyStore::STATUS_BAD_STATE. 235 // text will indicate CloudPolicyStore::STATUS_BAD_STATE.
236 class DeviceLocalAccountPolicyStatusProvider 236 class DeviceLocalAccountPolicyStatusProvider
237 : public CloudPolicyStatusProvider, 237 : public CloudPolicyStatusProvider,
238 public policy::DeviceLocalAccountPolicyService::Observer { 238 public policy::DeviceLocalAccountPolicyService::Observer {
239 public: 239 public:
240 DeviceLocalAccountPolicyStatusProvider( 240 DeviceLocalAccountPolicyStatusProvider(
241 const std::string& account_id, 241 const std::string& user_id,
242 policy::DeviceLocalAccountPolicyService* service); 242 policy::DeviceLocalAccountPolicyService* service);
243 virtual ~DeviceLocalAccountPolicyStatusProvider(); 243 virtual ~DeviceLocalAccountPolicyStatusProvider();
244 244
245 // CloudPolicyStatusProvider implementation. 245 // CloudPolicyStatusProvider implementation.
246 virtual void GetStatus(base::DictionaryValue* dict) OVERRIDE; 246 virtual void GetStatus(base::DictionaryValue* dict) OVERRIDE;
247 247
248 // policy::DeviceLocalAccountPolicyService::Observer implementation. 248 // policy::DeviceLocalAccountPolicyService::Observer implementation.
249 virtual void OnPolicyUpdated(const std::string& account_id) OVERRIDE; 249 virtual void OnPolicyUpdated(const std::string& user_id) OVERRIDE;
250 virtual void OnDeviceLocalAccountsChanged() OVERRIDE; 250 virtual void OnDeviceLocalAccountsChanged() OVERRIDE;
251 251
252 private: 252 private:
253 const std::string account_id_; 253 const std::string user_id_;
254 policy::DeviceLocalAccountPolicyService* service_; 254 policy::DeviceLocalAccountPolicyService* service_;
255 255
256 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyStatusProvider); 256 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyStatusProvider);
257 }; 257 };
258 #endif 258 #endif
259 259
260 // The JavaScript message handler for the chrome://policy page. 260 // The JavaScript message handler for the chrome://policy page.
261 class PolicyUIHandler : public content::WebUIMessageHandler, 261 class PolicyUIHandler : public content::WebUIMessageHandler,
262 public policy::PolicyService::Observer { 262 public policy::PolicyService::Observer {
263 public: 263 public:
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 371
372 DevicePolicyStatusProvider::~DevicePolicyStatusProvider() { 372 DevicePolicyStatusProvider::~DevicePolicyStatusProvider() {
373 } 373 }
374 374
375 void DevicePolicyStatusProvider::GetStatus(base::DictionaryValue* dict) { 375 void DevicePolicyStatusProvider::GetStatus(base::DictionaryValue* dict) {
376 GetStatusFromCore(core_, dict); 376 GetStatusFromCore(core_, dict);
377 dict->SetString("domain", domain_); 377 dict->SetString("domain", domain_);
378 } 378 }
379 379
380 DeviceLocalAccountPolicyStatusProvider::DeviceLocalAccountPolicyStatusProvider( 380 DeviceLocalAccountPolicyStatusProvider::DeviceLocalAccountPolicyStatusProvider(
381 const std::string& account_id, 381 const std::string& user_id,
382 policy::DeviceLocalAccountPolicyService* service) 382 policy::DeviceLocalAccountPolicyService* service)
383 : account_id_(account_id), 383 : user_id_(user_id),
384 service_(service) { 384 service_(service) {
385 service_->AddObserver(this); 385 service_->AddObserver(this);
386 } 386 }
387 387
388 DeviceLocalAccountPolicyStatusProvider:: 388 DeviceLocalAccountPolicyStatusProvider::
389 ~DeviceLocalAccountPolicyStatusProvider() { 389 ~DeviceLocalAccountPolicyStatusProvider() {
390 service_->RemoveObserver(this); 390 service_->RemoveObserver(this);
391 } 391 }
392 392
393 void DeviceLocalAccountPolicyStatusProvider::GetStatus( 393 void DeviceLocalAccountPolicyStatusProvider::GetStatus(
394 base::DictionaryValue* dict) { 394 base::DictionaryValue* dict) {
395 const policy::DeviceLocalAccountPolicyBroker* broker = 395 const policy::DeviceLocalAccountPolicyBroker* broker =
396 service_->GetBrokerForAccount(account_id_); 396 service_->GetBrokerForUser(user_id_);
397 if (broker) { 397 if (broker) {
398 GetStatusFromCore(broker->core(), dict); 398 GetStatusFromCore(broker->core(), dict);
399 } else { 399 } else {
400 dict->SetBoolean("error", true); 400 dict->SetBoolean("error", true);
401 dict->SetString("status", 401 dict->SetString("status",
402 policy::FormatStoreStatus( 402 policy::FormatStoreStatus(
403 policy::CloudPolicyStore::STATUS_BAD_STATE, 403 policy::CloudPolicyStore::STATUS_BAD_STATE,
404 policy::CloudPolicyValidatorBase::VALIDATION_OK)); 404 policy::CloudPolicyValidatorBase::VALIDATION_OK));
405 dict->SetString("username", account_id_); 405 dict->SetString("username", std::string());
406 } 406 }
407 ExtractDomainFromUsername(dict); 407 ExtractDomainFromUsername(dict);
408 dict->SetBoolean("publicAccount", true); 408 dict->SetBoolean("publicAccount", true);
409 } 409 }
410 410
411 void DeviceLocalAccountPolicyStatusProvider::OnPolicyUpdated( 411 void DeviceLocalAccountPolicyStatusProvider::OnPolicyUpdated(
412 const std::string& account_id) { 412 const std::string& user_id) {
413 if (account_id == account_id_) 413 if (user_id == user_id_)
414 NotifyStatusChange(); 414 NotifyStatusChange();
415 } 415 }
416 416
417 void DeviceLocalAccountPolicyStatusProvider::OnDeviceLocalAccountsChanged() { 417 void DeviceLocalAccountPolicyStatusProvider::OnDeviceLocalAccountsChanged() {
418 NotifyStatusChange(); 418 NotifyStatusChange();
419 } 419 }
420 #endif 420 #endif
421 421
422 PolicyUIHandler::PolicyUIHandler() 422 PolicyUIHandler::PolicyUIHandler()
423 : weak_factory_(this) { 423 : weak_factory_(this) {
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 } 582 }
583 583
584 PolicyUI::PolicyUI(content::WebUI* web_ui) : WebUIController(web_ui) { 584 PolicyUI::PolicyUI(content::WebUI* web_ui) : WebUIController(web_ui) {
585 web_ui->AddMessageHandler(new PolicyUIHandler); 585 web_ui->AddMessageHandler(new PolicyUIHandler);
586 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), 586 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui),
587 CreatePolicyUIHTMLSource()); 587 CreatePolicyUIHTMLSource());
588 } 588 }
589 589
590 PolicyUI::~PolicyUI() { 590 PolicyUI::~PolicyUI() {
591 } 591 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/chromeos/kiosk_apps_handler.cc ('k') | chrome/chrome_browser_chromeos.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698