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

Side by Side Diff: chrome/browser/ui/webui/extensions/extension_settings_handler.cc

Issue 925563002: Supervised users: Slightly relax restrictions around extensions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@test_ext_install_disable
Patch Set: benwells review Created 5 years, 10 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/ui/webui/extensions/extension_settings_handler.h" 5 #include "chrome/browser/ui/webui/extensions/extension_settings_handler.h"
6 6
7 #include "apps/app_load_service.h" 7 #include "apps/app_load_service.h"
8 #include "apps/saved_files_service.h" 8 #include "apps/saved_files_service.h"
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/base64.h" 10 #include "base/base64.h"
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 265
266 bool recommended_install = 266 bool recommended_install =
267 !managed_install && 267 !managed_install &&
268 management_policy_->MustRemainInstalled(extension, NULL); 268 management_policy_->MustRemainInstalled(extension, NULL);
269 extension_data->SetBoolean("recommendedInstall", recommended_install); 269 extension_data->SetBoolean("recommendedInstall", recommended_install);
270 270
271 // Suspicious install should always be mutually exclusive to managed and/or 271 // Suspicious install should always be mutually exclusive to managed and/or
272 // recommended install. 272 // recommended install.
273 DCHECK(!(managed_install || recommended_install) || !suspicious_install); 273 DCHECK(!(managed_install || recommended_install) || !suspicious_install);
274 274
275 // |web_ui()| can be null in unit tests.
276 bool installed_by_custodian =
277 web_ui() && Profile::FromWebUI(web_ui())->IsSupervised() &&
278 extension->was_installed_by_custodian();
279 extension_data->SetBoolean("installedByCustodian", installed_by_custodian);
280
275 GURL icon = 281 GURL icon =
276 ExtensionIconSource::GetIconURL(extension, 282 ExtensionIconSource::GetIconURL(extension,
277 extension_misc::EXTENSION_ICON_MEDIUM, 283 extension_misc::EXTENSION_ICON_MEDIUM,
278 ExtensionIconSet::MATCH_BIGGER, 284 ExtensionIconSet::MATCH_BIGGER,
279 !enabled, NULL); 285 !enabled, NULL);
280 if (Manifest::IsUnpackedLocation(extension->location())) { 286 if (Manifest::IsUnpackedLocation(extension->location())) {
281 extension_data->SetString("path", extension->path().value()); 287 extension_data->SetString("path", extension->path().value());
282 extension_data->SetString( 288 extension_data->SetString(
283 "prettifiedPath", 289 "prettifiedPath",
284 extensions::path_util::PrettifyPath(extension->path()).value()); 290 extensions::path_util::PrettifyPath(extension->path()).value());
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after
1070 CHECK_EQ(2U, args->GetSize()); 1076 CHECK_EQ(2U, args->GetSize());
1071 std::string extension_id, enable_str; 1077 std::string extension_id, enable_str;
1072 CHECK(args->GetString(0, &extension_id)); 1078 CHECK(args->GetString(0, &extension_id));
1073 CHECK(args->GetString(1, &enable_str)); 1079 CHECK(args->GetString(1, &enable_str));
1074 1080
1075 const Extension* extension = 1081 const Extension* extension =
1076 extension_service_->GetInstalledExtension(extension_id); 1082 extension_service_->GetInstalledExtension(extension_id);
1077 if (!extension) 1083 if (!extension)
1078 return; 1084 return;
1079 1085
1086 if (Profile::FromWebUI(web_ui())->IsSupervised() &&
1087 extension->was_installed_by_custodian()) {
1088 return;
1089 }
1090
1080 if (!management_policy_->UserMayModifySettings(extension, NULL)) { 1091 if (!management_policy_->UserMayModifySettings(extension, NULL)) {
1081 LOG(ERROR) << "An attempt was made to enable an extension that is " 1092 LOG(ERROR) << "An attempt was made to enable an extension that is "
1082 << "non-usermanagable. Extension id: " << extension->id(); 1093 << "non-usermanagable. Extension id: " << extension->id();
1083 return; 1094 return;
1084 } 1095 }
1085 1096
1086 if (enable_str == "true") { 1097 if (enable_str == "true") {
1087 ExtensionPrefs* prefs = ExtensionPrefs::Get(extension_service_->profile()); 1098 ExtensionPrefs* prefs = ExtensionPrefs::Get(extension_service_->profile());
1088 if (prefs->DidExtensionEscalatePermissions(extension_id)) { 1099 if (prefs->DidExtensionEscalatePermissions(extension_id)) {
1089 ShowExtensionDisabledDialog( 1100 ShowExtensionDisabledDialog(
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1154 const base::ListValue* args) { 1165 const base::ListValue* args) {
1155 CHECK_EQ(2U, args->GetSize()); 1166 CHECK_EQ(2U, args->GetSize());
1156 std::string extension_id, allow_str; 1167 std::string extension_id, allow_str;
1157 CHECK(args->GetString(0, &extension_id)); 1168 CHECK(args->GetString(0, &extension_id));
1158 CHECK(args->GetString(1, &allow_str)); 1169 CHECK(args->GetString(1, &allow_str));
1159 const Extension* extension = 1170 const Extension* extension =
1160 extension_service_->GetInstalledExtension(extension_id); 1171 extension_service_->GetInstalledExtension(extension_id);
1161 if (!extension) 1172 if (!extension)
1162 return; 1173 return;
1163 1174
1175 if (Profile::FromWebUI(web_ui())->IsSupervised() &&
1176 extension->was_installed_by_custodian()) {
1177 return;
1178 }
1179
1164 if (!management_policy_->UserMayModifySettings(extension, NULL)) { 1180 if (!management_policy_->UserMayModifySettings(extension, NULL)) {
1165 LOG(ERROR) << "An attempt was made to change allow file access of an" 1181 LOG(ERROR) << "An attempt was made to change allow file access of an"
1166 << " extension that is non-usermanagable. Extension id : " 1182 << " extension that is non-usermanagable. Extension id : "
1167 << extension->id(); 1183 << extension->id();
1168 return; 1184 return;
1169 } 1185 }
1170 1186
1171 util::SetAllowFileAccess( 1187 util::SetAllowFileAccess(
1172 extension_id, extension_service_->profile(), allow_str == "true"); 1188 extension_id, extension_service_->profile(), allow_str == "true");
1173 } 1189 }
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
1528 extension_service_->EnableExtension(extension_id); 1544 extension_service_->EnableExtension(extension_id);
1529 } else { 1545 } else {
1530 ExtensionErrorReporter::GetInstance()->ReportError( 1546 ExtensionErrorReporter::GetInstance()->ReportError(
1531 base::UTF8ToUTF16(JoinString(requirement_errors, ' ')), 1547 base::UTF8ToUTF16(JoinString(requirement_errors, ' ')),
1532 true); // Be noisy. 1548 true); // Be noisy.
1533 } 1549 }
1534 requirements_checker_.reset(); 1550 requirements_checker_.reset();
1535 } 1551 }
1536 1552
1537 } // namespace extensions 1553 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698