Commit e4cf3208 authored by dpolukhin's avatar dpolukhin Committed by Commit bot

Don't install OEM default apps for enterprise users

Enterprise admins would liked to control apps that will be installed for their users.
To allow admins to don't track and block OEM apps one by one disable OEM apps installation.

BUG=486862
TEST=manual

Review URL: https://codereview.chromium.org/1144033003

Cr-Commit-Position: refs/heads/master@{#330917}
parent cc27e9d5
......@@ -342,6 +342,7 @@ class MockProviderVisitor
: ids_found_(0),
fake_base_path_(fake_base_path),
expected_creation_flags_(expected_creation_flags) {
profile_.reset(new TestingProfile);
}
int Visit(const std::string& json_data) {
......
......@@ -43,6 +43,8 @@
#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
#include "chrome/browser/chromeos/policy/device_local_account.h"
#include "chrome/browser/chromeos/policy/device_local_account_policy_service.h"
#include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h"
#include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chromeos.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "components/user_manager/user.h"
#else
......@@ -229,19 +231,18 @@ void ExternalProviderImpl::SetPrefs(base::DictionaryValue* prefs) {
continue;
}
}
bool was_installed_by_oem = false;
if (extension->GetBoolean(kWasInstalledByOem, &was_installed_by_oem) &&
was_installed_by_oem) {
creation_flags |= Extension::WAS_INSTALLED_BY_OEM;
}
if (!HandleInstalledByOem(extension, extension_id, &unsupported_extensions,
&creation_flags))
continue;
bool may_be_untrusted = false;
if (extension->GetBoolean(kMayBeUntrusted, &may_be_untrusted) &&
may_be_untrusted) {
creation_flags |= Extension::MAY_BE_UNTRUSTED;
}
if (!ExternalProviderImpl::HandleMinProfileVersion(extension, extension_id,
&unsupported_extensions))
if (!HandleMinProfileVersion(extension, extension_id,
&unsupported_extensions))
continue;
std::string install_parameter;
......@@ -393,6 +394,29 @@ bool ExternalProviderImpl::HandleMinProfileVersion(
return true;
}
bool ExternalProviderImpl::HandleInstalledByOem(
const base::DictionaryValue* extension,
const std::string& extension_id,
std::set<std::string>* unsupported_extensions,
int* creation_flags) {
bool was_installed_by_oem = false;
if (extension->GetBoolean(kWasInstalledByOem, &was_installed_by_oem) &&
was_installed_by_oem) {
#if defined(OS_CHROMEOS)
policy::UserCloudPolicyManagerChromeOS* policy_manager =
policy::UserCloudPolicyManagerFactoryChromeOS::GetForProfile(profile_);
if (policy_manager && policy_manager->core()->store()->is_managed()) {
unsupported_extensions->insert(extension_id);
VLOG(1) << "Skip installing (or uninstall) external extension "
<< extension_id << " installed by OEM for managed user";
return false;
}
#endif
*creation_flags |= Extension::WAS_INSTALLED_BY_OEM;
}
return true;
}
// static
void ExternalProviderImpl::CreateExternalProviders(
VisitorInterface* service,
......
......@@ -89,6 +89,11 @@ class ExternalProviderImpl : public ExternalProviderInterface {
const std::string& extension_id,
std::set<std::string>* unsupported_extensions);
bool HandleInstalledByOem(const base::DictionaryValue* extension,
const std::string& extension_id,
std::set<std::string>* unsupported_extensions,
int* creation_flags);
// Location for external extensions that are provided by this provider from
// local crx files.
const Manifest::Location crx_location_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment