|
@@ -22,6 +22,7 @@
|
|
|
#include "extensions/browser/api/scripting/scripting_utils.h"
|
|
|
#include "extensions/browser/extension_api_frame_id_map.h"
|
|
|
#include "extensions/browser/extension_file_task_runner.h"
|
|
|
+#include "extensions/browser/extension_registry.h"
|
|
|
#include "extensions/browser/extension_system.h"
|
|
|
#include "extensions/browser/extension_user_script_loader.h"
|
|
|
#include "extensions/browser/extension_util.h"
|
|
@@ -1061,6 +1062,17 @@ void ScriptingRegisterContentScriptsFunction::OnContentScriptFilesValidated(
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ // We cannot proceed if the extension is uninstalled or unloaded in the middle
|
|
|
+ // of validating its script files.
|
|
|
+ ExtensionRegistry* registry = ExtensionRegistry::Get(browser_context());
|
|
|
+ if (!extension() ||
|
|
|
+ !registry->enabled_extensions().Contains(extension_id())) {
|
|
|
+ // Note: a Respond() is not needed if the system is shutting down or if the
|
|
|
+ // extension is no longer enabled.
|
|
|
+ Release(); // Matches the `AddRef()` in `Run()`.
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
auto error = std::move(result.second);
|
|
|
auto scripts = std::move(result.first);
|
|
|
ExtensionUserScriptLoader* loader =
|
|
@@ -1306,6 +1318,17 @@ void ScriptingUpdateContentScriptsFunction::OnContentScriptFilesValidated(
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ // We cannot proceed if the extension is uninstalled or unloaded in the middle
|
|
|
+ // of validating its script files.
|
|
|
+ ExtensionRegistry* registry = ExtensionRegistry::Get(browser_context());
|
|
|
+ if (!extension() ||
|
|
|
+ !registry->enabled_extensions().Contains(extension_id())) {
|
|
|
+ // Note: a Respond() is not needed if the system is shutting down or if the
|
|
|
+ // extension is no longer enabled.
|
|
|
+ Release(); // Matches the `AddRef()` in `Run()`.
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
auto error = std::move(result.second);
|
|
|
auto scripts = std::move(result.first);
|
|
|
ExtensionUserScriptLoader* loader =
|