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/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/sequenced_task_runner.h" | 9 #include "base/sequenced_task_runner.h" |
10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 is_elevated_(false) { | 90 is_elevated_(false) { |
91 } | 91 } |
92 | 92 |
93 ManagedUserService::~ManagedUserService() { | 93 ManagedUserService::~ManagedUserService() { |
94 } | 94 } |
95 | 95 |
96 bool ManagedUserService::ProfileIsManaged() const { | 96 bool ManagedUserService::ProfileIsManaged() const { |
97 return profile_->GetPrefs()->GetBoolean(prefs::kProfileIsManaged); | 97 return profile_->GetPrefs()->GetBoolean(prefs::kProfileIsManaged); |
98 } | 98 } |
99 | 99 |
| 100 bool ManagedUserService::IsElevated() const { |
| 101 return is_elevated_; |
| 102 } |
| 103 |
100 // static | 104 // static |
101 void ManagedUserService::RegisterUserPrefs(PrefRegistrySyncable* registry) { | 105 void ManagedUserService::RegisterUserPrefs(PrefRegistrySyncable* registry) { |
102 registry->RegisterDictionaryPref(prefs::kManagedModeManualHosts, | 106 registry->RegisterDictionaryPref(prefs::kManagedModeManualHosts, |
103 PrefRegistrySyncable::UNSYNCABLE_PREF); | 107 PrefRegistrySyncable::UNSYNCABLE_PREF); |
104 registry->RegisterDictionaryPref(prefs::kManagedModeManualURLs, | 108 registry->RegisterDictionaryPref(prefs::kManagedModeManualURLs, |
105 PrefRegistrySyncable::UNSYNCABLE_PREF); | 109 PrefRegistrySyncable::UNSYNCABLE_PREF); |
106 registry->RegisterIntegerPref(prefs::kDefaultManagedModeFilteringBehavior, | 110 registry->RegisterIntegerPref(prefs::kDefaultManagedModeFilteringBehavior, |
107 ManagedModeURLFilter::BLOCK, | 111 ManagedModeURLFilter::BLOCK, |
108 PrefRegistrySyncable::UNSYNCABLE_PREF); | 112 PrefRegistrySyncable::UNSYNCABLE_PREF); |
109 registry->RegisterStringPref(prefs::kManagedModeLocalPassphrase, | 113 registry->RegisterStringPref(prefs::kManagedModeLocalPassphrase, |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 dict->RemoveWithoutPathExpansion(url.spec(), NULL); | 328 dict->RemoveWithoutPathExpansion(url.spec(), NULL); |
325 } else { | 329 } else { |
326 dict->SetBooleanWithoutPathExpansion(url.spec(), | 330 dict->SetBooleanWithoutPathExpansion(url.spec(), |
327 behavior == MANUAL_ALLOW); | 331 behavior == MANUAL_ALLOW); |
328 } | 332 } |
329 } | 333 } |
330 | 334 |
331 UpdateManualURLs(); | 335 UpdateManualURLs(); |
332 } | 336 } |
333 | 337 |
334 void ManagedUserService::SetElevatedForTesting(bool is_elevated) { | 338 void ManagedUserService::SetElevated(bool is_elevated) { |
335 is_elevated_ = is_elevated; | 339 is_elevated_ = is_elevated; |
336 } | 340 } |
337 | 341 |
338 void ManagedUserService::Init() { | 342 void ManagedUserService::Init() { |
339 if (!ProfileIsManaged()) | 343 if (!ProfileIsManaged()) |
340 return; | 344 return; |
341 | 345 |
342 extensions::ExtensionSystem* extension_system = | 346 extensions::ExtensionSystem* extension_system = |
343 extensions::ExtensionSystem::Get(profile_); | 347 extensions::ExtensionSystem::Get(profile_); |
344 extensions::ManagementPolicy* management_policy = | 348 extensions::ManagementPolicy* management_policy = |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 profile_->GetPrefs()->GetDictionary(prefs::kManagedModeManualURLs); | 387 profile_->GetPrefs()->GetDictionary(prefs::kManagedModeManualURLs); |
384 scoped_ptr<std::map<GURL, bool> > url_map(new std::map<GURL, bool>()); | 388 scoped_ptr<std::map<GURL, bool> > url_map(new std::map<GURL, bool>()); |
385 for (DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); it.Advance()) { | 389 for (DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); it.Advance()) { |
386 bool allow = false; | 390 bool allow = false; |
387 bool result = it.value().GetAsBoolean(&allow); | 391 bool result = it.value().GetAsBoolean(&allow); |
388 DCHECK(result); | 392 DCHECK(result); |
389 (*url_map)[GURL(it.key())] = allow; | 393 (*url_map)[GURL(it.key())] = allow; |
390 } | 394 } |
391 url_filter_context_.SetManualURLs(url_map.Pass()); | 395 url_filter_context_.SetManualURLs(url_map.Pass()); |
392 } | 396 } |
OLD | NEW |