Commit f362fcb8 authored by Ryan Daum's avatar Ryan Daum Committed by Commit Bot

[chromecast] Always launch ui_devtools for dev devices

Have the ui_devtools server launch for all devices that are BUILD_ENG
or is_debug=true.

Bug: internal b/148931987
Test: manual
Change-Id: I55b58c51e0a4a080aae269e7d985975b3ae75e79
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2144616Reviewed-by: default avatarDaniel Nicoara <dnicoara@chromium.org>
Commit-Queue: Ryan Daum <rdaum@chromium.org>
Cr-Commit-Position: refs/heads/master@{#759785}
parent 977b1b28
......@@ -140,6 +140,8 @@
#if !defined(OS_FUCHSIA)
#include "base/bind_helpers.h"
#include "chromecast/base/cast_sys_info_util.h"
#include "chromecast/public/cast_sys_info.h"
#include "components/heap_profiling/client_connection_manager.h"
#include "components/heap_profiling/supervisor.h"
#endif // !defined(OS_FUCHSIA)
......@@ -586,10 +588,12 @@ void CastBrowserMainParts::PreMainMessageLoopRun() {
#if defined(USE_AURA)
#if !defined(OS_FUCHSIA)
// Start UI devtools if enabled.
// Start UI devtools if this is a dev device or explicitly enabled.
// Note that this must happen before the window tree host is created by the
// window manager.
if (::ui_devtools::UiDevToolsServer::IsUiDevToolsEnabled(
auto build_type = CreateSysInfo()->GetBuildType();
if (CAST_IS_DEBUG_BUILD() || build_type == CastSysInfo::BUILD_ENG ||
::ui_devtools::UiDevToolsServer::IsUiDevToolsEnabled(
::ui_devtools::switches::kEnableUiDevTools)) {
// Starts the UI Devtools server for browser Aura UI
ui_devtools_ = std::make_unique<CastUIDevTools>(
......
......@@ -4,8 +4,15 @@
#include "chromecast/browser/devtools/cast_ui_devtools.h"
#include "chromecast/base/chromecast_switches.h"
#include "components/ui_devtools/connector_delegate.h"
#include "components/ui_devtools/views/devtools_server_util.h"
#include "components/ui_devtools/css_agent.h"
#include "components/ui_devtools/devtools_server.h"
#include "components/ui_devtools/page_agent.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"
#include "components/ui_devtools/views/page_agent_views.h"
namespace chromecast {
namespace shell {
......@@ -17,8 +24,25 @@ CastUIDevTools::~CastUIDevTools() = default;
std::unique_ptr<ui_devtools::UiDevToolsServer> CastUIDevTools::CreateServer(
network::mojom::NetworkContext* network_context) const {
return ui_devtools::CreateUiDevToolsServerForViews(
network_context, nullptr /* connector_delegate */);
constexpr int kUiDevToolsDefaultPort = 9223;
int port = GetSwitchValueInt(ui_devtools::switches::kEnableUiDevTools,
kUiDevToolsDefaultPort);
auto server =
ui_devtools::UiDevToolsServer::CreateForViews(network_context, port);
DCHECK(server);
auto client = std::make_unique<ui_devtools::UiDevToolsClient>(
"UiDevToolsClient", server.get());
auto dom_agent_views = ui_devtools::DOMAgentViews::Create();
DCHECK(dom_agent_views);
auto* dom_agent_views_ptr = dom_agent_views.get();
client->AddAgent(
std::make_unique<ui_devtools::PageAgentViews>(dom_agent_views_ptr));
client->AddAgent(std::move(dom_agent_views));
client->AddAgent(
std::make_unique<ui_devtools::CSSAgent>(dom_agent_views_ptr));
client->AddAgent(ui_devtools::OverlayAgentViews::Create(dom_agent_views_ptr));
server->AttachClient(std::move(client));
return server;
}
} // namespace shell
......
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