Chromium Code Reviews| Index: chrome/browser/extensions/extension_service.cc |
| diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc |
| index 9f425f57445b17dc110c3530babf849ffaea4c11..cb4055313b79f34936de373150aea29cd68dc561 100644 |
| --- a/chrome/browser/extensions/extension_service.cc |
| +++ b/chrome/browser/extensions/extension_service.cc |
| @@ -15,6 +15,7 @@ |
| #include "base/metrics/histogram_macros.h" |
| #include "base/single_thread_task_runner.h" |
| #include "base/strings/string_number_conversions.h" |
| +#include "base/strings/string_tokenizer.h" |
| #include "base/strings/stringprintf.h" |
| #include "base/strings/utf_string_conversions.h" |
| #include "base/threading/sequenced_worker_pool.h" |
| @@ -300,6 +301,7 @@ ExtensionService::ExtensionService(Profile* profile, |
| bool extensions_enabled, |
| extensions::OneShotEvent* ready) |
| : extensions::Blacklist::Observer(blacklist), |
| + command_line_(command_line), |
| profile_(profile), |
| system_(extensions::ExtensionSystem::Get(profile)), |
| extension_prefs_(extension_prefs), |
| @@ -416,6 +418,27 @@ const Extension* ExtensionService::GetExtensionById( |
| return registry_->GetExtensionById(id, include_mask); |
| } |
| +void ExtensionService::LoadExtensionsFromCommandLineFlag( |
|
Devlin
2016/08/30 14:15:39
nit: function definition order in the .cc file sho
|
| + const char* switch_name) { |
| + if (command_line_->HasSwitch(switch_name)) { |
| + base::CommandLine::StringType path_list = |
| + command_line_->GetSwitchValueNative(switch_name); |
| + base::StringTokenizerT<base::CommandLine::StringType, |
| + base::CommandLine::StringType::const_iterator> |
| + t(path_list, FILE_PATH_LITERAL(",")); |
| + while (t.GetNext()) { |
| + std::string extension_id; |
| + extensions::UnpackedInstaller::Create(this)->LoadFromCommandLine( |
| + base::FilePath(t.token()), &extension_id, false /*only-allow-apps*/); |
| + // Extension id is added to whitelist after its extension is loaded |
| + // because code is executed asynchronously ... |
|
catmullings
2016/08/29 22:28:01
Devlin, I didn't quite understand the asynchronous
Devlin
2016/08/30 14:15:39
So, if this code were to be executed synchronously
|
| + if (switch_name == switches::kDisableExtensionsExcept) { |
| + disable_flag_exempted_extensions_.insert(extension_id); |
| + } |
|
Devlin
2016/08/30 14:15:39
nit: We don't have a strong stylistic rule for bra
|
| + } |
| + } |
| +} |
| + |
| void ExtensionService::Init() { |
| CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| TRACE_EVENT0("browser,startup", "ExtensionService::Init"); |
| @@ -427,7 +450,10 @@ void ExtensionService::Init() { |
| // LoadAllExtensions() calls OnLoadedInstalledExtensions(). |
| component_loader_->LoadAll(); |
| extensions::InstalledLoader(this).LoadAllExtensions(); |
| - |
| + LoadExtensionsFromCommandLineFlag(switches::kDisableExtensionsExcept); |
| + if (extensions_enabled_) { |
|
Devlin
2016/08/30 14:15:39
ditto re single line ifs
|
| + LoadExtensionsFromCommandLineFlag(switches::kLoadExtension); |
| + } |
| EnabledReloadableExtensions(); |
| MaybeFinishShutdownDelayed(); |
| SetReadyAndNotifyListeners(); |
| @@ -1422,10 +1448,10 @@ void ExtensionService::AddExtension(const Extension* extension) { |
| // TODO(jstritar): We may be able to get rid of this branch by overriding the |
| // default extension state to DISABLED when the --disable-extensions flag |
| // is set (http://crbug.com/29067). |
| - if (!extensions_enabled() && |
| - !extension->is_theme() && |
| + if (!extensions_enabled() && !extension->is_theme() && |
| extension->location() != Manifest::COMPONENT && |
| - !Manifest::IsExternalLocation(extension->location())) { |
| + !Manifest::IsExternalLocation(extension->location()) && |
| + disable_flag_exempted_extensions_.count(extension->id()) == 0) { |
| return; |
| } |