Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/supervised_user/supervised_user_service.h" | 5 #include "chrome/browser/supervised_user/supervised_user_service.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 61 #endif | 61 #endif |
| 62 | 62 |
| 63 #if defined(OS_CHROMEOS) | 63 #if defined(OS_CHROMEOS) |
| 64 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" | 64 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" |
| 65 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" | 65 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" |
| 66 #include "components/user_manager/user_manager.h" | 66 #include "components/user_manager/user_manager.h" |
| 67 #endif | 67 #endif |
| 68 | 68 |
| 69 #if defined(ENABLE_EXTENSIONS) | 69 #if defined(ENABLE_EXTENSIONS) |
| 70 #include "chrome/browser/extensions/extension_service.h" | 70 #include "chrome/browser/extensions/extension_service.h" |
| 71 #include "chrome/browser/extensions/extension_util.h" | |
| 71 #include "extensions/browser/extension_system.h" | 72 #include "extensions/browser/extension_system.h" |
| 72 #endif | 73 #endif |
| 73 | 74 |
| 74 #if defined(ENABLE_THEMES) | 75 #if defined(ENABLE_THEMES) |
| 75 #include "chrome/browser/themes/theme_service.h" | 76 #include "chrome/browser/themes/theme_service.h" |
| 76 #include "chrome/browser/themes/theme_service_factory.h" | 77 #include "chrome/browser/themes/theme_service_factory.h" |
| 78 #include "extensions/browser/extension_prefs.h" | |
|
Marc Treib
2016/06/16 12:35:39
wrong #ifdef
mamir
2016/06/17 08:33:18
Sorry.
Done!
| |
| 77 #endif | 79 #endif |
| 78 | 80 |
| 79 using base::DictionaryValue; | 81 using base::DictionaryValue; |
| 80 using base::UserMetricsAction; | 82 using base::UserMetricsAction; |
| 81 using content::BrowserThread; | 83 using content::BrowserThread; |
| 84 using extensions::ExtensionPrefs; | |
|
Marc Treib
2016/06/16 12:35:39
add #ifdef
mamir
2016/06/17 08:33:18
Done.
| |
| 82 | 85 |
| 83 namespace { | 86 namespace { |
| 84 | 87 |
| 85 // The URL from which to download a host blacklist if no local one exists yet. | 88 // The URL from which to download a host blacklist if no local one exists yet. |
| 86 const char kBlacklistURL[] = | 89 const char kBlacklistURL[] = |
| 87 "https://www.gstatic.com/chrome/supervised_user/blacklist-20141001-1k.bin"; | 90 "https://www.gstatic.com/chrome/supervised_user/blacklist-20141001-1k.bin"; |
| 88 // The filename under which we'll store the blacklist (in the user data dir). | 91 // The filename under which we'll store the blacklist (in the user data dir). |
| 89 const char kBlacklistFilename[] = "su-blacklist.bin"; | 92 const char kBlacklistFilename[] = "su-blacklist.bin"; |
| 90 | 93 |
| 91 const char* const kCustodianInfoPrefs[] = { | 94 const char* const kCustodianInfoPrefs[] = { |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 117 void ExtensionUpdateRequestSent(const std::string& id, bool success) { | 120 void ExtensionUpdateRequestSent(const std::string& id, bool success) { |
| 118 VLOG_IF(1, !success) << "Failed sending update request for " << id; | 121 VLOG_IF(1, !success) << "Failed sending update request for " << id; |
| 119 } | 122 } |
| 120 | 123 |
| 121 base::FilePath GetBlacklistPath() { | 124 base::FilePath GetBlacklistPath() { |
| 122 base::FilePath blacklist_dir; | 125 base::FilePath blacklist_dir; |
| 123 PathService::Get(chrome::DIR_USER_DATA, &blacklist_dir); | 126 PathService::Get(chrome::DIR_USER_DATA, &blacklist_dir); |
| 124 return blacklist_dir.AppendASCII(kBlacklistFilename); | 127 return blacklist_dir.AppendASCII(kBlacklistFilename); |
| 125 } | 128 } |
| 126 | 129 |
| 127 #if defined(ENABLE_EXTENSIONS) | |
| 128 enum ExtensionState { | |
| 129 EXTENSION_FORCED, | |
| 130 EXTENSION_BLOCKED, | |
| 131 EXTENSION_ALLOWED | |
| 132 }; | |
| 133 | |
| 134 ExtensionState GetExtensionState(const extensions::Extension* extension) { | |
| 135 bool was_installed_by_default = extension->was_installed_by_default(); | |
| 136 #if defined(OS_CHROMEOS) | |
| 137 // On Chrome OS all external sources are controlled by us so it means that | |
| 138 // they are "default". Method was_installed_by_default returns false because | |
| 139 // extensions creation flags are ignored in case of default extensions with | |
| 140 // update URL(the flags aren't passed to OnExternalExtensionUpdateUrlFound). | |
| 141 // TODO(dpolukhin): remove this Chrome OS specific code as soon as creation | |
| 142 // flags are not ignored. | |
| 143 was_installed_by_default = | |
| 144 extensions::Manifest::IsExternalLocation(extension->location()); | |
| 145 #endif | |
| 146 // Note: Component extensions are protected from modification/uninstallation | |
| 147 // anyway, so there's no need to enforce them again for supervised users. | |
| 148 // Also, leave policy-installed extensions alone - they have their own | |
| 149 // management; in particular we don't want to override the force-install list. | |
| 150 if (extensions::Manifest::IsComponentLocation(extension->location()) || | |
| 151 extensions::Manifest::IsPolicyLocation(extension->location()) || | |
| 152 extension->is_theme() || | |
| 153 extension->from_bookmark() || | |
| 154 extension->is_shared_module() || | |
| 155 was_installed_by_default) { | |
| 156 return EXTENSION_ALLOWED; | |
| 157 } | |
| 158 | |
| 159 if (extension->was_installed_by_custodian()) | |
| 160 return EXTENSION_FORCED; | |
| 161 | |
| 162 return EXTENSION_BLOCKED; | |
| 163 } | |
| 164 #endif | |
| 165 | |
| 166 } // namespace | 130 } // namespace |
| 167 | 131 |
| 168 SupervisedUserService::~SupervisedUserService() { | 132 SupervisedUserService::~SupervisedUserService() { |
| 169 DCHECK(!did_init_ || did_shutdown_); | 133 DCHECK(!did_init_ || did_shutdown_); |
| 170 url_filter_context_.ui_url_filter()->RemoveObserver(this); | 134 url_filter_context_.ui_url_filter()->RemoveObserver(this); |
| 171 } | 135 } |
| 172 | 136 |
| 173 // static | 137 // static |
| 174 void SupervisedUserService::RegisterProfilePrefs( | 138 void SupervisedUserService::RegisterProfilePrefs( |
| 175 user_prefs::PrefRegistrySyncable* registry) { | 139 user_prefs::PrefRegistrySyncable* registry) { |
| (...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 947 | 911 |
| 948 ProfileSyncService* sync_service = | 912 ProfileSyncService* sync_service = |
| 949 ProfileSyncServiceFactory::GetForProfile(profile_); | 913 ProfileSyncServiceFactory::GetForProfile(profile_); |
| 950 | 914 |
| 951 // Can be null in tests. | 915 // Can be null in tests. |
| 952 if (sync_service) | 916 if (sync_service) |
| 953 sync_service->RemovePreferenceProvider(this); | 917 sync_service->RemovePreferenceProvider(this); |
| 954 } | 918 } |
| 955 | 919 |
| 956 #if defined(ENABLE_EXTENSIONS) | 920 #if defined(ENABLE_EXTENSIONS) |
| 921 SupervisedUserService::ExtensionState SupervisedUserService::GetExtensionState( | |
| 922 const extensions::Extension* extension) const { | |
| 923 bool was_installed_by_default = extension->was_installed_by_default(); | |
| 924 #if defined(OS_CHROMEOS) | |
| 925 // On Chrome OS all external sources are controlled by us so it means that | |
| 926 // they are "default". Method was_installed_by_default returns false because | |
| 927 // extensions creation flags are ignored in case of default extensions with | |
| 928 // update URL(the flags aren't passed to OnExternalExtensionUpdateUrlFound). | |
| 929 // TODO(dpolukhin): remove this Chrome OS specific code as soon as creation | |
| 930 // flags are not ignored. | |
| 931 was_installed_by_default = | |
| 932 extensions::Manifest::IsExternalLocation(extension->location()); | |
| 933 #endif | |
| 934 // Note: Component extensions are protected from modification/uninstallation | |
| 935 // anyway, so there's no need to enforce them again for supervised users. | |
| 936 // Also, leave policy-installed extensions alone - they have their own | |
| 937 // management; in particular we don't want to override the force-install list. | |
| 938 if (extensions::Manifest::IsComponentLocation(extension->location()) || | |
| 939 extensions::Manifest::IsPolicyLocation(extension->location()) || | |
| 940 extension->is_theme() || | |
| 941 extension->from_bookmark() || | |
| 942 extension->is_shared_module() || | |
| 943 was_installed_by_default) { | |
| 944 return ExtensionState::EXTENSION_ALLOWED; | |
| 945 } | |
| 946 | |
| 947 if (extensions::util::WasInstalledByCustodian(extension->id(), profile_)) | |
| 948 return ExtensionState::EXTENSION_FORCED; | |
| 949 | |
| 950 return ExtensionState::EXTENSION_BLOCKED; | |
| 951 } | |
| 952 | |
| 957 std::string SupervisedUserService::GetDebugPolicyProviderName() const { | 953 std::string SupervisedUserService::GetDebugPolicyProviderName() const { |
| 958 // Save the string space in official builds. | 954 // Save the string space in official builds. |
| 959 #ifdef NDEBUG | 955 #ifdef NDEBUG |
| 960 NOTREACHED(); | 956 NOTREACHED(); |
| 961 return std::string(); | 957 return std::string(); |
| 962 #else | 958 #else |
| 963 return "Supervised User Service"; | 959 return "Supervised User Service"; |
| 964 #endif | 960 #endif |
| 965 } | 961 } |
| 966 | 962 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1057 content::RecordAction(UserMetricsAction("ManagedUsers_SwitchProfile")); | 1053 content::RecordAction(UserMetricsAction("ManagedUsers_SwitchProfile")); |
| 1058 | 1054 |
| 1059 is_profile_active_ = profile_became_active; | 1055 is_profile_active_ = profile_became_active; |
| 1060 } | 1056 } |
| 1061 #endif // !defined(OS_ANDROID) | 1057 #endif // !defined(OS_ANDROID) |
| 1062 | 1058 |
| 1063 void SupervisedUserService::OnSiteListUpdated() { | 1059 void SupervisedUserService::OnSiteListUpdated() { |
| 1064 FOR_EACH_OBSERVER( | 1060 FOR_EACH_OBSERVER( |
| 1065 SupervisedUserServiceObserver, observer_list_, OnURLFilterChanged()); | 1061 SupervisedUserServiceObserver, observer_list_, OnURLFilterChanged()); |
| 1066 } | 1062 } |
| OLD | NEW |