OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/chromeos/arc/policy/arc_policy_bridge.h" | 5 #include "chrome/browser/chromeos/arc/policy/arc_policy_bridge.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 weak_ptr_factory_(this) { | 304 weak_ptr_factory_(this) { |
305 VLOG(2) << "ArcPolicyBridge::ArcPolicyBridge(bridge_service, policy_service)"; | 305 VLOG(2) << "ArcPolicyBridge::ArcPolicyBridge(bridge_service, policy_service)"; |
306 arc_bridge_service()->policy()->AddObserver(this); | 306 arc_bridge_service()->policy()->AddObserver(this); |
307 } | 307 } |
308 | 308 |
309 ArcPolicyBridge::~ArcPolicyBridge() { | 309 ArcPolicyBridge::~ArcPolicyBridge() { |
310 VLOG(2) << "ArcPolicyBridge::~ArcPolicyBridge"; | 310 VLOG(2) << "ArcPolicyBridge::~ArcPolicyBridge"; |
311 arc_bridge_service()->policy()->RemoveObserver(this); | 311 arc_bridge_service()->policy()->RemoveObserver(this); |
312 } | 312 } |
313 | 313 |
| 314 // static |
| 315 void ArcPolicyBridge::RegisterProfilePrefs( |
| 316 user_prefs::PrefRegistrySyncable* registry) { |
| 317 registry->RegisterBooleanPref(prefs::kArcPolicyComplianceReported, false); |
| 318 } |
| 319 |
314 void ArcPolicyBridge::OverrideIsManagedForTesting(bool is_managed) { | 320 void ArcPolicyBridge::OverrideIsManagedForTesting(bool is_managed) { |
315 is_managed_ = is_managed; | 321 is_managed_ = is_managed; |
316 } | 322 } |
317 | 323 |
318 void ArcPolicyBridge::OnInstanceReady() { | 324 void ArcPolicyBridge::OnInstanceReady() { |
319 VLOG(1) << "ArcPolicyBridge::OnPolicyInstanceReady"; | 325 VLOG(1) << "ArcPolicyBridge::OnPolicyInstanceReady"; |
320 if (policy_service_ == nullptr) { | 326 if (policy_service_ == nullptr) { |
321 InitializePolicyService(); | 327 InitializePolicyService(); |
322 } | 328 } |
323 policy_service_->AddObserver(policy::POLICY_DOMAIN_CHROME, this); | 329 policy_service_->AddObserver(policy::POLICY_DOMAIN_CHROME, this); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 const policy::PolicyMap& policy_map = | 391 const policy::PolicyMap& policy_map = |
386 policy_service_->GetPolicies(policy_namespace); | 392 policy_service_->GetPolicies(policy_namespace); |
387 return GetFilteredJSONPolicies(policy_map); | 393 return GetFilteredJSONPolicies(policy_map); |
388 } | 394 } |
389 | 395 |
390 void ArcPolicyBridge::OnReportComplianceParseSuccess( | 396 void ArcPolicyBridge::OnReportComplianceParseSuccess( |
391 const ArcPolicyBridge::ReportComplianceCallback& callback, | 397 const ArcPolicyBridge::ReportComplianceCallback& callback, |
392 std::unique_ptr<base::Value> parsed_json) { | 398 std::unique_ptr<base::Value> parsed_json) { |
393 // Always returns "compliant". | 399 // Always returns "compliant". |
394 callback.Run(kPolicyCompliantJson); | 400 callback.Run(kPolicyCompliantJson); |
| 401 GetProfile()->GetPrefs()->SetBoolean(prefs::kArcPolicyComplianceReported, |
| 402 true); |
395 | 403 |
396 const base::DictionaryValue* dict = nullptr; | 404 const base::DictionaryValue* dict = nullptr; |
397 if (parsed_json->GetAsDictionary(&dict)) | 405 if (parsed_json->GetAsDictionary(&dict)) |
398 UpdateComplianceReportMetrics(dict); | 406 UpdateComplianceReportMetrics(dict); |
399 } | 407 } |
400 | 408 |
401 void ArcPolicyBridge::UpdateComplianceReportMetrics( | 409 void ArcPolicyBridge::UpdateComplianceReportMetrics( |
402 const base::DictionaryValue* report) { | 410 const base::DictionaryValue* report) { |
403 bool is_arc_plus_plus_report_successful = false; | 411 bool is_arc_plus_plus_report_successful = false; |
404 report->GetBoolean("isArcPlusPlusReportSuccessful", | 412 report->GetBoolean("isArcPlusPlusReportSuccessful", |
(...skipping 19 matching lines...) Expand all Loading... |
424 } | 432 } |
425 | 433 |
426 if (reported_policies_hash == update_notification_policies_hash_ && | 434 if (reported_policies_hash == update_notification_policies_hash_ && |
427 !compliance_since_update_timing_reported_) { | 435 !compliance_since_update_timing_reported_) { |
428 UpdateComplianceSinceUpdateTiming(now - update_notification_time_); | 436 UpdateComplianceSinceUpdateTiming(now - update_notification_time_); |
429 compliance_since_update_timing_reported_ = true; | 437 compliance_since_update_timing_reported_ = true; |
430 } | 438 } |
431 } | 439 } |
432 | 440 |
433 } // namespace arc | 441 } // namespace arc |
OLD | NEW |