| 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/sequenced_task_runner.h" | 8 #include "base/sequenced_task_runner.h" |
| 9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
| 10 #include "chrome/browser/extensions/extension_system.h" | 10 #include "chrome/browser/extensions/extension_system.h" |
| 11 #include "chrome/browser/managed_mode/managed_mode_site_list.h" | 11 #include "chrome/browser/managed_mode/managed_mode_site_list.h" |
| 12 #include "chrome/browser/prefs/pref_registry_syncable.h" |
| 12 #include "chrome/browser/prefs/pref_service.h" | 13 #include "chrome/browser/prefs/pref_service.h" |
| 13 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 14 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/common/chrome_notification_types.h" | 16 #include "chrome/common/chrome_notification_types.h" |
| 16 #include "chrome/common/extensions/extension_set.h" | 17 #include "chrome/common/extensions/extension_set.h" |
| 17 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
| 18 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
| 19 #include "grit/generated_resources.h" | 20 #include "grit/generated_resources.h" |
| 20 #include "ui/base/l10n/l10n_util.h" | 21 #include "ui/base/l10n/l10n_util.h" |
| 21 | 22 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 } | 92 } |
| 92 | 93 |
| 93 ManagedUserService::~ManagedUserService() { | 94 ManagedUserService::~ManagedUserService() { |
| 94 } | 95 } |
| 95 | 96 |
| 96 bool ManagedUserService::ProfileIsManaged() const { | 97 bool ManagedUserService::ProfileIsManaged() const { |
| 97 return profile_->GetPrefs()->GetBoolean(prefs::kProfileIsManaged); | 98 return profile_->GetPrefs()->GetBoolean(prefs::kProfileIsManaged); |
| 98 } | 99 } |
| 99 | 100 |
| 100 // static | 101 // static |
| 101 void ManagedUserService::RegisterUserPrefs(PrefServiceSyncable* prefs) { | 102 void ManagedUserService::RegisterUserPrefs(PrefRegistrySyncable* registry) { |
| 102 prefs->RegisterDictionaryPref(prefs::kManagedModeManualHosts, | 103 registry->RegisterDictionaryPref(prefs::kManagedModeManualHosts, |
| 103 PrefServiceSyncable::UNSYNCABLE_PREF); | 104 PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 104 prefs->RegisterDictionaryPref(prefs::kManagedModeManualURLs, | 105 registry->RegisterDictionaryPref(prefs::kManagedModeManualURLs, |
| 105 PrefServiceSyncable::UNSYNCABLE_PREF); | 106 PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 106 prefs->RegisterIntegerPref(prefs::kDefaultManagedModeFilteringBehavior, | 107 registry->RegisterIntegerPref(prefs::kDefaultManagedModeFilteringBehavior, |
| 107 ManagedModeURLFilter::BLOCK, | 108 ManagedModeURLFilter::BLOCK, |
| 108 PrefServiceSyncable::UNSYNCABLE_PREF); | 109 PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 109 } | 110 } |
| 110 | 111 |
| 111 scoped_refptr<const ManagedModeURLFilter> | 112 scoped_refptr<const ManagedModeURLFilter> |
| 112 ManagedUserService::GetURLFilterForIOThread() { | 113 ManagedUserService::GetURLFilterForIOThread() { |
| 113 return url_filter_context_.io_url_filter(); | 114 return url_filter_context_.io_url_filter(); |
| 114 } | 115 } |
| 115 | 116 |
| 116 ManagedModeURLFilter* ManagedUserService::GetURLFilterForUIThread() { | 117 ManagedModeURLFilter* ManagedUserService::GetURLFilterForUIThread() { |
| 117 return url_filter_context_.ui_url_filter(); | 118 return url_filter_context_.ui_url_filter(); |
| 118 } | 119 } |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 profile_->GetPrefs()->GetDictionary(prefs::kManagedModeManualURLs); | 360 profile_->GetPrefs()->GetDictionary(prefs::kManagedModeManualURLs); |
| 360 scoped_ptr<std::map<GURL, bool> > url_map(new std::map<GURL, bool>()); | 361 scoped_ptr<std::map<GURL, bool> > url_map(new std::map<GURL, bool>()); |
| 361 for (DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); it.Advance()) { | 362 for (DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); it.Advance()) { |
| 362 bool allow = false; | 363 bool allow = false; |
| 363 bool result = it.value().GetAsBoolean(&allow); | 364 bool result = it.value().GetAsBoolean(&allow); |
| 364 DCHECK(result); | 365 DCHECK(result); |
| 365 (*url_map)[GURL(it.key())] = allow; | 366 (*url_map)[GURL(it.key())] = allow; |
| 366 } | 367 } |
| 367 url_filter_context_.SetManualURLs(url_map.Pass()); | 368 url_filter_context_.SetManualURLs(url_map.Pass()); |
| 368 } | 369 } |
| OLD | NEW |