From 98670c1e8709c9da41bedf10e3dab3ec32dd44bd Mon Sep 17 00:00:00 2001 From: James Cook Date: Fri, 18 Mar 2022 01:12:58 +0000 Subject: [PATCH] M100: chromeos: Remove manual extension reload from SelectFileDialogExtension This code was added in https://codereview.chromium.org/9360005 as a workaround for some misbehavior in the extensions system for crashed component extensions. The code is no longer necessary. Deleting it avoids a potential use-after-free (the ExtensionSystem might be deleted slightly before the profile that owns it). I manually tested after deleting the code: 1. Open file manager 2. Open a browser, then press Ctrl-O to create the open dialog 3. Kill the files process in task manager - The dialog closes 4. Press Ctrl-O again - The dialog opens again and functions normally (cherry picked from commit 214db6b05f61309e14eab393755ca3ab47857012) Bug: 1303253 Change-Id: Ibf94afcc2b2412704d8dcbe65b93a5595e6e55cc Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3514778 Reviewed-by: Bo Majewski Commit-Queue: James Cook Cr-Original-Commit-Position: refs/heads/main@{#979543} Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3531083 Auto-Submit: James Cook Cr-Commit-Position: refs/branch-heads/4896@{#654} Cr-Branched-From: 1f63ff4bc27570761b35ffbc7f938f6586f7bee8-refs/heads/main@{#972766} --- .../ui/views/select_file_dialog_extension.cc | 29 +------------------ 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/chrome/browser/ui/views/select_file_dialog_extension.cc b/chrome/browser/ui/views/select_file_dialog_extension.cc index 5f0d7d9045e88..6fd8ff4128efd 100644 --- a/chrome/browser/ui/views/select_file_dialog_extension.cc +++ b/chrome/browser/ui/views/select_file_dialog_extension.cc @@ -15,16 +15,12 @@ #include "ash/public/cpp/style/color_provider.h" #include "ash/public/cpp/style/scoped_light_mode_as_default.h" #include "ash/public/cpp/tablet_mode.h" -#include "base/bind.h" -#include "base/callback.h" #include "base/feature_list.h" #include "base/location.h" #include "base/logging.h" #include "base/memory/ref_counted.h" #include "base/no_destructor.h" #include "base/strings/stringprintf.h" -#include "base/task/single_thread_task_runner.h" -#include "base/threading/thread_task_runner_handle.h" #include "build/chromeos_buildflags.h" #include "chrome/browser/app_mode/app_mode_utils.h" #include "chrome/browser/apps/platform_apps/app_window_registry_util.h" @@ -51,7 +47,6 @@ #include "chromeos/ui/base/window_properties.h" #include "extensions/browser/app_window/app_window.h" #include "extensions/browser/app_window/native_app_window.h" -#include "extensions/browser/extension_system.h" #include "ui/aura/window.h" #include "ui/base/base_window.h" #include "ui/gfx/color_palette.h" @@ -322,29 +317,7 @@ void SelectFileDialogExtension::ExtensionDialogClosing( void SelectFileDialogExtension::ExtensionTerminated( ExtensionDialog* dialog) { - // The extension would have been unloaded because of the termination, - // reload it. - std::string extension_id = dialog->host()->extension()->id(); - // Reload the extension after a bit; the extension may not have been unloaded - // yet. We don't want to try to reload the extension only to have the Unload - // code execute after us and re-unload the extension. - // - // TODO(rkc): This is ugly. The ideal solution is that we shouldn't need to - // reload the extension at all - when we try to open the extension the next - // time, the extension subsystem would automatically reload it for us. At - // this time though this is broken because of some faulty wiring in - // extensions::ProcessManager::CreateViewHost. Once that is fixed, remove - // this. - if (profile_) { - base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, - base::BindOnce( - &extensions::ExtensionService::ReloadExtension, - base::Unretained(extensions::ExtensionSystem::Get(profile_) - ->extension_service()), - extension_id)); - } - + // The extension crashed (or the process was killed). Close the dialog. dialog->GetWidget()->Close(); }