Chromium Code Reviews| Index: chrome/browser/profile_resetter/profile_resetter.cc |
| diff --git a/chrome/browser/profile_resetter/profile_resetter.cc b/chrome/browser/profile_resetter/profile_resetter.cc |
| index d3e4360baf4398268c9f92efacd6aeddda1a95c9..c911eb5cdf8edf7eb4af740dc577caf0f7a69539 100644 |
| --- a/chrome/browser/profile_resetter/profile_resetter.cc |
| +++ b/chrome/browser/profile_resetter/profile_resetter.cc |
| @@ -7,6 +7,7 @@ |
| #include <stddef.h> |
| #include <string> |
| +#include <vector> |
| #include "base/macros.h" |
| #include "base/synchronization/cancellation_flag.h" |
| @@ -37,8 +38,10 @@ |
| #include "components/search_engines/template_url_prepopulate_data.h" |
| #include "components/search_engines/template_url_service.h" |
| #include "content/public/browser/browser_thread.h" |
| +#include "extensions/browser/extension_registry.h" |
| #include "extensions/browser/extension_system.h" |
| #include "extensions/browser/management_policy.h" |
| +#include "extensions/common/manifest.h" |
| #if defined(OS_WIN) |
| #include "base/base_paths.h" |
| @@ -271,6 +274,25 @@ void ProfileResetter::ResetExtensions() { |
| DCHECK(extension_service); |
| extension_service->DisableUserExtensions(brandcode_extensions); |
| + // Reenable all disabled external component extensions. |
| + // BrandcodedDefaultSettings does not contain information about component |
| + // extensions, so fetch them from the existing registry. This may be not very |
| + // robust, as the profile resetter may be invoked when the registry is in some |
| + // iffy state. However, we can't enable an extension which is not in the |
| + // registry anyway. |
| + extensions::ExtensionRegistry* extension_registry = |
| + extensions::ExtensionRegistry::Get(profile_); |
| + DCHECK(extension_registry); |
| + std::vector<std::string> extension_ids_to_reenable; |
|
lazyboy
2017/01/24 03:30:01
nit: new codes shoudl use ExtensionId instead of s
mtomasz
2017/01/26 08:47:06
Done.
|
| + for (const auto& extension : extension_registry->disabled_extensions()) { |
| + if (extension->location() == extensions::Manifest::EXTERNAL_COMPONENT) { |
|
lazyboy
2017/01/24 03:30:01
nit: no {}
mtomasz
2017/01/26 08:47:06
Done.
|
| + extension_ids_to_reenable.push_back(extension->id()); |
| + } |
| + } |
| + for (const auto& extension_id : extension_ids_to_reenable) { |
| + extension_service->EnableExtension(extension_id); |
| + } |
| + |
| MarkAsDone(EXTENSIONS); |
| } |