Chromium Code Reviews| Index: chrome/browser/extensions/external_provider_impl.cc |
| diff --git a/chrome/browser/extensions/external_provider_impl.cc b/chrome/browser/extensions/external_provider_impl.cc |
| index 20a72b8817afc6c855be53483aef696d18df44df..d199bcf5c4de71d66e106bdae7805fd1d7d021bc 100644 |
| --- a/chrome/browser/extensions/external_provider_impl.cc |
| +++ b/chrome/browser/extensions/external_provider_impl.cc |
| @@ -34,9 +34,13 @@ |
| #include "ui/base/l10n/l10n_util.h" |
| #if defined(OS_CHROMEOS) |
| +#include "chrome/browser/chromeos/extensions/device_local_account_external_policy_loader.h" |
| #include "chrome/browser/chromeos/extensions/external_pref_cache_loader.h" |
| +#include "chrome/browser/chromeos/login/user.h" |
| #include "chrome/browser/chromeos/login/user_manager.h" |
| #include "chrome/browser/chromeos/policy/app_pack_updater.h" |
| +#include "chrome/browser/chromeos/policy/device_local_account.h" |
| +#include "chrome/browser/chromeos/policy/device_local_account_policy_service.h" |
| #include "chrome/browser/policy/browser_policy_connector.h" |
| #else |
| #include "chrome/browser/extensions/default_apps.h" |
| @@ -61,12 +65,13 @@ const char ExternalProviderImpl::kKeepIfPresent[] = "keep_if_present"; |
| const char ExternalProviderImpl::kRequirePermissionsConsent[] = |
| "require_permissions_consent"; |
| -ExternalProviderImpl::ExternalProviderImpl(VisitorInterface* service, |
| - ExternalLoader* loader, |
| - Profile* profile, |
| - Manifest::Location crx_location, |
| - Manifest::Location download_location, |
| - int creation_flags) |
| +ExternalProviderImpl::ExternalProviderImpl( |
| + VisitorInterface* service, |
| + const scoped_refptr<ExternalLoader>& loader, |
| + Profile* profile, |
| + Manifest::Location crx_location, |
| + Manifest::Location download_location, |
| + int creation_flags) |
| : crx_location_(crx_location), |
| download_location_(download_location), |
| service_(service), |
| @@ -346,16 +351,40 @@ void ExternalProviderImpl::CreateExternalProviders( |
| VisitorInterface* service, |
| Profile* profile, |
| ProviderCollection* provider_list) { |
| + scoped_refptr<ExternalLoader> external_loader; |
| + extensions::Manifest::Location crx_location = Manifest::INVALID_LOCATION; |
| +#if defined(OS_CHROMEOS) |
| + const chromeos::User* user = chromeos::UserManager::Get()->GetActiveUser(); |
|
Joao da Silva
2013/10/17 14:57:54
Use GetUserByProfile() instead.
When a new user i
bartfab (slow)
2013/10/18 12:58:39
Done.
|
| + if (user && policy::IsDeviceLocalAccountUser(user->email(), NULL)) { |
|
Matt Perry
2013/10/16 21:19:29
I don't know what a device-local account is, but a
bartfab (slow)
2013/10/17 09:16:45
A device-local account is the mechanism shared by
|
| + policy::DeviceLocalAccountPolicyBroker* broker = |
| + g_browser_process->browser_policy_connector()-> |
| + GetDeviceLocalAccountPolicyService()-> |
| + GetBrokerForUser(user->email()); |
| + if (broker) { |
| + external_loader = broker->extension_loader(); |
| + crx_location = Manifest::EXTERNAL_POLICY; |
| + } else { |
| + NOTREACHED(); |
| + } |
| + } else { |
| + external_loader = new ExternalPolicyLoader(profile); |
| + } |
| +#else |
| + external_loader = new ExternalPolicyLoader(profile); |
| +#endif |
| + |
| // Policies are mandatory so they can't be skipped with command line flag. |
| - provider_list->push_back( |
| - linked_ptr<ExternalProviderInterface>( |
| - new ExternalProviderImpl( |
| - service, |
| - new ExternalPolicyLoader(profile), |
| - profile, |
| - Manifest::INVALID_LOCATION, |
| - Manifest::EXTERNAL_POLICY_DOWNLOAD, |
| - Extension::NO_FLAGS))); |
| + if (external_loader) { |
| + provider_list->push_back( |
| + linked_ptr<ExternalProviderInterface>( |
| + new ExternalProviderImpl( |
| + service, |
| + external_loader, |
| + profile, |
| + crx_location, |
| + Manifest::EXTERNAL_POLICY_DOWNLOAD, |
| + Extension::NO_FLAGS))); |
| + } |
| // In tests don't install extensions from default external sources. |
| // It would only slowdown tests and make them flaky. |