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

Unified 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: Commenting out WAS_INSTALLED_BY_CUSTODIAN flag 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/supervised_user/supervised_user_service.cc
diff --git a/chrome/browser/supervised_user/supervised_user_service.cc b/chrome/browser/supervised_user/supervised_user_service.cc
index 0f71827875aeaaebb3c71482ecd4956c8741e3f2..5cf446cafe2b44621bdbdff3888882f8f5ad2c7f 100644
--- a/chrome/browser/supervised_user/supervised_user_service.cc
+++ b/chrome/browser/supervised_user/supervised_user_service.cc
@@ -68,17 +68,20 @@
#if defined(ENABLE_EXTENSIONS)
#include "chrome/browser/extensions/extension_service.h"
+#include "chrome/browser/extensions/extension_util.h"
#include "extensions/browser/extension_system.h"
#endif
#if defined(ENABLE_THEMES)
#include "chrome/browser/themes/theme_service.h"
#include "chrome/browser/themes/theme_service_factory.h"
+#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!
#endif
using base::DictionaryValue;
using base::UserMetricsAction;
using content::BrowserThread;
+using extensions::ExtensionPrefs;
Marc Treib 2016/06/16 12:35:39 add #ifdef
mamir 2016/06/17 08:33:18 Done.
namespace {
@@ -124,45 +127,6 @@ base::FilePath GetBlacklistPath() {
return blacklist_dir.AppendASCII(kBlacklistFilename);
}
-#if defined(ENABLE_EXTENSIONS)
-enum ExtensionState {
- EXTENSION_FORCED,
- EXTENSION_BLOCKED,
- EXTENSION_ALLOWED
-};
-
-ExtensionState GetExtensionState(const extensions::Extension* extension) {
- bool was_installed_by_default = extension->was_installed_by_default();
-#if defined(OS_CHROMEOS)
- // On Chrome OS all external sources are controlled by us so it means that
- // they are "default". Method was_installed_by_default returns false because
- // extensions creation flags are ignored in case of default extensions with
- // update URL(the flags aren't passed to OnExternalExtensionUpdateUrlFound).
- // TODO(dpolukhin): remove this Chrome OS specific code as soon as creation
- // flags are not ignored.
- was_installed_by_default =
- extensions::Manifest::IsExternalLocation(extension->location());
-#endif
- // Note: Component extensions are protected from modification/uninstallation
- // anyway, so there's no need to enforce them again for supervised users.
- // Also, leave policy-installed extensions alone - they have their own
- // management; in particular we don't want to override the force-install list.
- if (extensions::Manifest::IsComponentLocation(extension->location()) ||
- extensions::Manifest::IsPolicyLocation(extension->location()) ||
- extension->is_theme() ||
- extension->from_bookmark() ||
- extension->is_shared_module() ||
- was_installed_by_default) {
- return EXTENSION_ALLOWED;
- }
-
- if (extension->was_installed_by_custodian())
- return EXTENSION_FORCED;
-
- return EXTENSION_BLOCKED;
-}
-#endif
-
} // namespace
SupervisedUserService::~SupervisedUserService() {
@@ -954,6 +918,38 @@ void SupervisedUserService::Shutdown() {
}
#if defined(ENABLE_EXTENSIONS)
+SupervisedUserService::ExtensionState SupervisedUserService::GetExtensionState(
+ const extensions::Extension* extension) const {
+ bool was_installed_by_default = extension->was_installed_by_default();
+#if defined(OS_CHROMEOS)
+ // On Chrome OS all external sources are controlled by us so it means that
+ // they are "default". Method was_installed_by_default returns false because
+ // extensions creation flags are ignored in case of default extensions with
+ // update URL(the flags aren't passed to OnExternalExtensionUpdateUrlFound).
+ // TODO(dpolukhin): remove this Chrome OS specific code as soon as creation
+ // flags are not ignored.
+ was_installed_by_default =
+ extensions::Manifest::IsExternalLocation(extension->location());
+#endif
+ // Note: Component extensions are protected from modification/uninstallation
+ // anyway, so there's no need to enforce them again for supervised users.
+ // Also, leave policy-installed extensions alone - they have their own
+ // management; in particular we don't want to override the force-install list.
+ if (extensions::Manifest::IsComponentLocation(extension->location()) ||
+ extensions::Manifest::IsPolicyLocation(extension->location()) ||
+ extension->is_theme() ||
+ extension->from_bookmark() ||
+ extension->is_shared_module() ||
+ was_installed_by_default) {
+ return ExtensionState::EXTENSION_ALLOWED;
+ }
+
+ if (extensions::util::WasInstalledByCustodian(extension->id(), profile_))
+ return ExtensionState::EXTENSION_FORCED;
+
+ return ExtensionState::EXTENSION_BLOCKED;
+}
+
std::string SupervisedUserService::GetDebugPolicyProviderName() const {
// Save the string space in official builds.
#ifdef NDEBUG

Powered by Google App Engine
This is Rietveld 408576698