Commit 209557db authored by Mike Wasserman's avatar Mike Wasserman Committed by Commit Bot

mash cleanup: Remove ui_devtools support

Remove Ash's separate registration of root windows for SPM.
Remove UAF and root window determination workarounds for SPM.

Bug: 958471
Test: No ui_devtools regressions
Change-Id: I55fe07b83731c3832e803078eb75526972534958
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1631904Reviewed-by: default avatarLeonard Grey <lgrey@chromium.org>
Commit-Queue: Michael Wasserman <msw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#664356}
parent 5f8d4482
......@@ -50,8 +50,6 @@
#include "components/session_manager/core/session_manager.h"
#include "components/session_manager/core/session_manager_observer.h"
#include "components/startup_metric_utils/browser/startup_metric_utils.h"
#include "components/ui_devtools/switches.h"
#include "components/ui_devtools/views/devtools_server_util.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_observer.h"
......@@ -128,18 +126,6 @@ void ChromeBrowserMainExtraPartsAsh::PreProfileInit() {
ash_shell_init_ = std::make_unique<AshShellInit>();
if (ui_devtools::UiDevToolsServer::IsUiDevToolsEnabled(
ui_devtools::switches::kEnableUiDevTools)) {
// Register Ash's root windows with UI DevTools; warn in multi-process Mash.
// TODO(crbug.com/896977): Refine ui_devtools support for Ash and mojo apps.
if (features::IsSingleProcessMash()) {
ui_devtools::RegisterAdditionalRootWindowsAndEnv(
ash::Shell::Get()->GetAllRootWindows());
} else if (features::IsMultiProcessMash()) {
LOG(WARNING) << "Chrome cannot access Ash and mojo app UIs in Mash.";
}
}
screen_orientation_delegate_ =
std::make_unique<ScreenOrientationDelegateChromeos>();
......
......@@ -82,8 +82,7 @@ void ChromeBrowserMainExtraPartsViews::PreCreateThreads() {
void ChromeBrowserMainExtraPartsViews::PreProfileInit() {
if (ui_devtools::UiDevToolsServer::IsUiDevToolsEnabled(
ui_devtools::switches::kEnableUiDevTools)) {
// Starts the UI Devtools server for the browser UI. On Aura platforms,
// ChromeBrowserMainExtraPartsAsh wires up Ash UI for SingleProcessMash.
// Starts the UI Devtools server for browser UI (and Ash UI on Chrome OS).
devtools_server_ = ui_devtools::CreateUiDevToolsServerForViews(
g_browser_process->system_network_context_manager()->GetContext());
}
......@@ -133,13 +132,4 @@ void ChromeBrowserMainExtraPartsViews::PostMainMessageLoopRun() {
// down explicitly here to avoid a case where such an event arrives during
// shutdown.
relaunch_notification_controller_.reset();
#if defined(USE_AURA)
// Explicitly release |devtools_server_| to avoid use-after-free under
// single process mash, where |devtools_server_| indirectly accesses
// the Env of ash::Shell during destruction and ash::Shell as part of
// ChromeBrowserMainExtraPartsAsh is released before
// ChromeBrowserMainExtraPartsViews.
devtools_server_.reset();
#endif
}
......@@ -6,19 +6,12 @@
#include <memory>
#include "base/command_line.h"
#include "build/build_config.h"
#include "components/ui_devtools/css_agent.h"
#include "components/ui_devtools/devtools_server.h"
#include "components/ui_devtools/switches.h"
#include "components/ui_devtools/views/dom_agent_views.h"
#include "components/ui_devtools/views/overlay_agent_views.h"
#if defined(USE_AURA)
#include "components/ui_devtools/views/dom_agent_aura.h"
#include "components/ui_devtools/views/overlay_agent_aura.h"
#endif
namespace ui_devtools {
std::unique_ptr<UiDevToolsServer> CreateUiDevToolsServerForViews(
......@@ -39,12 +32,4 @@ std::unique_ptr<UiDevToolsServer> CreateUiDevToolsServerForViews(
return server;
}
#if defined(USE_AURA)
void RegisterAdditionalRootWindowsAndEnv(std::vector<aura::Window*> roots) {
DCHECK(!roots.empty());
for (auto* root : roots)
DOMAgentAura::GetInstance()->RegisterRootWindow(root);
}
#endif
} // namespace ui_devtools
......@@ -6,23 +6,15 @@
#define COMPONENTS_UI_DEVTOOLS_VIEWS_DEVTOOLS_SERVER_UTIL_H_
#include <memory>
#include <vector>
#include "components/ui_devtools/devtools_server.h"
namespace aura {
class Window;
}
namespace ui_devtools {
// A factory helper to construct a UiDevToolsServer for Views.
std::unique_ptr<UiDevToolsServer> CreateUiDevToolsServerForViews(
network::mojom::NetworkContext* network_context);
// Register additional root windows and wire up their Aura Env.
void RegisterAdditionalRootWindowsAndEnv(std::vector<aura::Window*> roots);
} // namespace ui_devtools
#endif // COMPONENTS_UI_DEVTOOLS_VIEWS_DEVTOOLS_SERVER_UTIL_H_
......@@ -25,6 +25,7 @@ DOMAgentAura::DOMAgentAura() {
dom_agent_aura_ = this;
aura::Env::GetInstance()->AddObserver(this);
}
DOMAgentAura::~DOMAgentAura() {
for (aura::Window* window : roots_)
window->RemoveObserver(this);
......@@ -32,13 +33,9 @@ DOMAgentAura::~DOMAgentAura() {
dom_agent_aura_ = nullptr;
}
void DOMAgentAura::RegisterRootWindow(aura::Window* root) {
roots_.push_back(root);
root->AddObserver(this);
}
void DOMAgentAura::OnHostInitialized(aura::WindowTreeHost* host) {
RegisterRootWindow(host->window());
roots_.push_back(host->window());
host->window()->AddObserver(this);
}
void DOMAgentAura::OnWindowDestroying(aura::Window* window) {
......
......@@ -24,7 +24,6 @@ class DOMAgentAura : public DOMAgentViews,
~DOMAgentAura() override;
static DOMAgentAura* GetInstance() { return dom_agent_aura_; }
void RegisterRootWindow(aura::Window* root);
// DOMAgent
std::vector<UIElement*> CreateChildrenForRoot() override;
......
......@@ -4,6 +4,7 @@
#include "components/ui_devtools/views/overlay_agent_aura.h"
#include "components/ui_devtools/dom_agent.h"
#include "components/ui_devtools/views/window_element.h"
#include "ui/aura/env.h"
#include "ui/views/view.h"
......
......@@ -7,19 +7,14 @@
#include "components/ui_devtools/views/overlay_agent_views.h"
#include "components/ui_devtools/dom_agent.h"
namespace aura {
class Env;
}
namespace ui_devtools {
class DOMAgent;
class OverlayAgentAura : public OverlayAgentViews {
public:
OverlayAgentAura(DOMAgent* dom_agent);
~OverlayAgentAura() override;
void RegisterEnv(aura::Env* env);
int FindElementIdTargetedByPoint(ui::LocatedEvent* event) const override;
static OverlayAgentAura* GetInstance() { return overlay_agent_aura_; }
......
......@@ -12,8 +12,6 @@
#include "third_party/skia/include/core/SkColor.h"
#include "third_party/skia/include/effects/SkDashPathEffect.h"
#include "ui/compositor/paint_recorder.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
#include "ui/events/event.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/geometry/rect_conversions.h"
......@@ -719,14 +717,6 @@ bool OverlayAgentViews::UpdateHighlight(
#else
gfx::NativeWindow root = window_and_bounds.first->GetRootWindow();
root_layer = root->layer();
#if defined(OS_CHROMEOS)
// Get the screen's display-root window; otherwise, if the window belongs to
// a window service client, |root| will only be a client-root window.
aura::Window* window = display::Screen::GetScreen()->GetWindowAtScreenPoint(
root->GetBoundsInScreen().origin());
if (window) // May be null in unit tests.
root = window->GetRootWindow();
#endif // OS_CHROMEOS
layer_for_highlighting_screen_offset_ =
root->GetBoundsInScreen().OffsetFromOrigin();
#endif // defined(OS_MACOSX)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment