Skip to content

Commit

Permalink
M100: chromeos: Remove manual extension reload from SelectFileDialogE…
Browse files Browse the repository at this point in the history
…xtension

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 214db6b)

Bug: 1303253
Change-Id: Ibf94afcc2b2412704d8dcbe65b93a5595e6e55cc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3514778
Reviewed-by: Bo Majewski <majewski@chromium.org>
Commit-Queue: James Cook <jamescook@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#979543}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3531083
Auto-Submit: James Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/branch-heads/4896@{#654}
Cr-Branched-From: 1f63ff4-refs/heads/main@{#972766}
  • Loading branch information
James Cook authored and Chromium LUCI CQ committed Mar 18, 2022
1 parent 4078d50 commit 98670c1
Showing 1 changed file with 1 addition and 28 deletions.
29 changes: 1 addition & 28 deletions chrome/browser/ui/views/select_file_dialog_extension.cc
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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();
}

Expand Down

0 comments on commit 98670c1

Please sign in to comment.