Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(363)

Side by Side Diff: chrome/browser/supervised_user/supervised_user_service.cc

Issue 2054773002: Replace the WAS_INSTALLED_BY_CUSTODIAN creation flag with a pref (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing the build Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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"
72 #include "extensions/browser/extension_prefs.h"
71 #include "extensions/browser/extension_system.h" 73 #include "extensions/browser/extension_system.h"
72 #endif 74 #endif
73 75
74 #if defined(ENABLE_THEMES) 76 #if defined(ENABLE_THEMES)
75 #include "chrome/browser/themes/theme_service.h" 77 #include "chrome/browser/themes/theme_service.h"
76 #include "chrome/browser/themes/theme_service_factory.h" 78 #include "chrome/browser/themes/theme_service_factory.h"
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;
82 84
85 #if defined(ENABLE_EXTENSIONS)
86 using extensions::ExtensionPrefs;
87 #endif
88
83 namespace { 89 namespace {
84 90
85 // The URL from which to download a host blacklist if no local one exists yet. 91 // The URL from which to download a host blacklist if no local one exists yet.
86 const char kBlacklistURL[] = 92 const char kBlacklistURL[] =
87 "https://www.gstatic.com/chrome/supervised_user/blacklist-20141001-1k.bin"; 93 "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). 94 // The filename under which we'll store the blacklist (in the user data dir).
89 const char kBlacklistFilename[] = "su-blacklist.bin"; 95 const char kBlacklistFilename[] = "su-blacklist.bin";
90 96
91 const char* const kCustodianInfoPrefs[] = { 97 const char* const kCustodianInfoPrefs[] = {
92 prefs::kSupervisedUserCustodianName, 98 prefs::kSupervisedUserCustodianName,
(...skipping 24 matching lines...) Expand all
117 void ExtensionUpdateRequestSent(const std::string& id, bool success) { 123 void ExtensionUpdateRequestSent(const std::string& id, bool success) {
118 VLOG_IF(1, !success) << "Failed sending update request for " << id; 124 VLOG_IF(1, !success) << "Failed sending update request for " << id;
119 } 125 }
120 126
121 base::FilePath GetBlacklistPath() { 127 base::FilePath GetBlacklistPath() {
122 base::FilePath blacklist_dir; 128 base::FilePath blacklist_dir;
123 PathService::Get(chrome::DIR_USER_DATA, &blacklist_dir); 129 PathService::Get(chrome::DIR_USER_DATA, &blacklist_dir);
124 return blacklist_dir.AppendASCII(kBlacklistFilename); 130 return blacklist_dir.AppendASCII(kBlacklistFilename);
125 } 131 }
126 132
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 133 } // namespace
167 134
168 SupervisedUserService::~SupervisedUserService() { 135 SupervisedUserService::~SupervisedUserService() {
169 DCHECK(!did_init_ || did_shutdown_); 136 DCHECK(!did_init_ || did_shutdown_);
170 url_filter_context_.ui_url_filter()->RemoveObserver(this); 137 url_filter_context_.ui_url_filter()->RemoveObserver(this);
171 } 138 }
172 139
173 // static 140 // static
174 void SupervisedUserService::RegisterProfilePrefs( 141 void SupervisedUserService::RegisterProfilePrefs(
175 user_prefs::PrefRegistrySyncable* registry) { 142 user_prefs::PrefRegistrySyncable* registry) {
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after
949 916
950 ProfileSyncService* sync_service = 917 ProfileSyncService* sync_service =
951 ProfileSyncServiceFactory::GetForProfile(profile_); 918 ProfileSyncServiceFactory::GetForProfile(profile_);
952 919
953 // Can be null in tests. 920 // Can be null in tests.
954 if (sync_service) 921 if (sync_service)
955 sync_service->RemovePreferenceProvider(this); 922 sync_service->RemovePreferenceProvider(this);
956 } 923 }
957 924
958 #if defined(ENABLE_EXTENSIONS) 925 #if defined(ENABLE_EXTENSIONS)
926 SupervisedUserService::ExtensionState SupervisedUserService::GetExtensionState(
927 const extensions::Extension* extension) const {
928 bool was_installed_by_default = extension->was_installed_by_default();
929 #if defined(OS_CHROMEOS)
930 // On Chrome OS all external sources are controlled by us so it means that
931 // they are "default". Method was_installed_by_default returns false because
932 // extensions creation flags are ignored in case of default extensions with
933 // update URL(the flags aren't passed to OnExternalExtensionUpdateUrlFound).
934 // TODO(dpolukhin): remove this Chrome OS specific code as soon as creation
935 // flags are not ignored.
936 was_installed_by_default =
937 extensions::Manifest::IsExternalLocation(extension->location());
938 #endif
939 // Note: Component extensions are protected from modification/uninstallation
940 // anyway, so there's no need to enforce them again for supervised users.
941 // Also, leave policy-installed extensions alone - they have their own
942 // management; in particular we don't want to override the force-install list.
943 if (extensions::Manifest::IsComponentLocation(extension->location()) ||
944 extensions::Manifest::IsPolicyLocation(extension->location()) ||
945 extension->is_theme() ||
946 extension->from_bookmark() ||
947 extension->is_shared_module() ||
948 was_installed_by_default) {
949 return ExtensionState::EXTENSION_ALLOWED;
950 }
951
952 if (extensions::util::WasInstalledByCustodian(extension->id(), profile_))
953 return ExtensionState::EXTENSION_FORCED;
954
955 return ExtensionState::EXTENSION_BLOCKED;
956 }
957
959 std::string SupervisedUserService::GetDebugPolicyProviderName() const { 958 std::string SupervisedUserService::GetDebugPolicyProviderName() const {
960 // Save the string space in official builds. 959 // Save the string space in official builds.
961 #ifdef NDEBUG 960 #ifdef NDEBUG
962 NOTREACHED(); 961 NOTREACHED();
963 return std::string(); 962 return std::string();
964 #else 963 #else
965 return "Supervised User Service"; 964 return "Supervised User Service";
966 #endif 965 #endif
967 } 966 }
968 967
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1059 content::RecordAction(UserMetricsAction("ManagedUsers_SwitchProfile")); 1058 content::RecordAction(UserMetricsAction("ManagedUsers_SwitchProfile"));
1060 1059
1061 is_profile_active_ = profile_became_active; 1060 is_profile_active_ = profile_became_active;
1062 } 1061 }
1063 #endif // !defined(OS_ANDROID) 1062 #endif // !defined(OS_ANDROID)
1064 1063
1065 void SupervisedUserService::OnSiteListUpdated() { 1064 void SupervisedUserService::OnSiteListUpdated() {
1066 FOR_EACH_OBSERVER( 1065 FOR_EACH_OBSERVER(
1067 SupervisedUserServiceObserver, observer_list_, OnURLFilterChanged()); 1066 SupervisedUserServiceObserver, observer_list_, OnURLFilterChanged());
1068 } 1067 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698