OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/managed_mode/managed_user_service.h" | 5 #include "chrome/browser/managed_mode/managed_user_service.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 | 270 |
271 void ManagedUserService::DidBlockNavigation( | 271 void ManagedUserService::DidBlockNavigation( |
272 content::WebContents* web_contents) { | 272 content::WebContents* web_contents) { |
273 for (std::vector<NavigationBlockedCallback>::iterator it = | 273 for (std::vector<NavigationBlockedCallback>::iterator it = |
274 navigation_blocked_callbacks_.begin(); | 274 navigation_blocked_callbacks_.begin(); |
275 it != navigation_blocked_callbacks_.end(); ++it) { | 275 it != navigation_blocked_callbacks_.end(); ++it) { |
276 it->Run(web_contents); | 276 it->Run(web_contents); |
277 } | 277 } |
278 } | 278 } |
279 | 279 |
| 280 void ManagedUserService::AddInitCallback( |
| 281 const base::Closure& callback) { |
| 282 init_callbacks_.push_back(callback); |
| 283 } |
| 284 |
280 std::string ManagedUserService::GetDebugPolicyProviderName() const { | 285 std::string ManagedUserService::GetDebugPolicyProviderName() const { |
281 // Save the string space in official builds. | 286 // Save the string space in official builds. |
282 #ifdef NDEBUG | 287 #ifdef NDEBUG |
283 NOTREACHED(); | 288 NOTREACHED(); |
284 return std::string(); | 289 return std::string(); |
285 #else | 290 #else |
286 return "Managed User Service"; | 291 return "Managed User Service"; |
287 #endif | 292 #endif |
288 } | 293 } |
289 | 294 |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
589 BrowserList::AddObserver(this); | 594 BrowserList::AddObserver(this); |
590 | 595 |
591 if (policy_provider) | 596 if (policy_provider) |
592 policy_provider->InitLocalPolicies(); | 597 policy_provider->InitLocalPolicies(); |
593 | 598 |
594 // Initialize the filter. | 599 // Initialize the filter. |
595 OnDefaultFilteringBehaviorChanged(); | 600 OnDefaultFilteringBehaviorChanged(); |
596 UpdateSiteLists(); | 601 UpdateSiteLists(); |
597 UpdateManualHosts(); | 602 UpdateManualHosts(); |
598 UpdateManualURLs(); | 603 UpdateManualURLs(); |
| 604 |
| 605 // Call the callbacks to notify that the ManagedUserService has been |
| 606 // initialized. |
| 607 for (std::vector<base::Closure>::iterator it = init_callbacks_.begin(); |
| 608 it != init_callbacks_.end(); |
| 609 ++it) { |
| 610 it->Run(); |
| 611 } |
599 } | 612 } |
600 | 613 |
601 void ManagedUserService::RegisterAndInitSync( | 614 void ManagedUserService::RegisterAndInitSync( |
602 ManagedUserRegistrationUtility* registration_utility, | 615 ManagedUserRegistrationUtility* registration_utility, |
603 Profile* custodian_profile, | 616 Profile* custodian_profile, |
604 const std::string& managed_user_id, | 617 const std::string& managed_user_id, |
605 const ProfileManager::CreateCallback& callback) { | 618 const ProfileManager::CreateCallback& callback) { |
606 DCHECK(ProfileIsManaged()); | 619 DCHECK(ProfileIsManaged()); |
607 DCHECK(!custodian_profile->IsManaged()); | 620 DCHECK(!custodian_profile->IsManaged()); |
608 | 621 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
697 scoped_ptr<DictionaryValue> dict(new DictionaryValue); | 710 scoped_ptr<DictionaryValue> dict(new DictionaryValue); |
698 | 711 |
699 // TODO(bauerb): Use sane time when ready. | 712 // TODO(bauerb): Use sane time when ready. |
700 dict->SetDouble(kEventTimestamp, base::Time::Now().ToJsTime()); | 713 dict->SetDouble(kEventTimestamp, base::Time::Now().ToJsTime()); |
701 | 714 |
702 ManagedModePolicyProvider* provider = GetPolicyProvider(); | 715 ManagedModePolicyProvider* provider = GetPolicyProvider(); |
703 // It is NULL in tests. | 716 // It is NULL in tests. |
704 if (provider) | 717 if (provider) |
705 provider->UploadItem(key, dict.PassAs<Value>()); | 718 provider->UploadItem(key, dict.PassAs<Value>()); |
706 } | 719 } |
OLD | NEW |