Commit 302fc7f0 authored by Hidehiko Abe's avatar Hidehiko Abe Committed by Commit Bot

Lacros: set LACROS AppType to the Lacros windows.

This CL introduces new AppType, called LACROS, and annotate it
to the Lacros windows.

      Ran tast run ${DUTIP} lacros*

Bug: 1090663
Test: Ran locally, and made sure AppType is annotated.
Change-Id: I56c38ed03a655de8870fad298b962656f2b6156f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2449830
Commit-Queue: Hidehiko Abe <hidehiko@chromium.org>
Reviewed-by: default avatarJun Mukai <mukai@chromium.org>
Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/master@{#815431}
parent 529be939
......@@ -25,7 +25,11 @@ int GetDestination(views::Widget* target) {
aura::Window* window = target->GetNativeWindow();
DCHECK(window);
return window->GetProperty(aura::client::kAppType);
int app_type = window->GetProperty(aura::client::kAppType);
// Use "BROWSER" for Lacros Chrome's pointer metrics.
if (app_type == static_cast<int>(AppType::LACROS))
return static_cast<int>(AppType::BROWSER);
return app_type;
}
DownEventMetric2 FindCombination(int destination,
......
......@@ -18,11 +18,10 @@ enum class AppType {
ARC_APP,
CROSTINI_APP,
SYSTEM_APP,
APP_TYPE_LAST = SYSTEM_APP,
// TODO(crbug.com/1090663): Migrate this into BROWSER.
LACROS,
};
const int kAppCount = static_cast<int>(AppType::APP_TYPE_LAST) + 1;
} // namespace ash
#endif // ASH_PUBLIC_CPP_APP_TYPES_H_
......@@ -365,6 +365,8 @@ api::autotest_private::AppWindowType GetAppWindowType(ash::AppType type) {
return api::autotest_private::AppWindowType::APP_WINDOW_TYPE_EXTENSIONAPP;
case ash::AppType::BROWSER:
return api::autotest_private::AppWindowType::APP_WINDOW_TYPE_BROWSER;
case ash::AppType::LACROS:
return api::autotest_private::AppWindowType::APP_WINDOW_TYPE_LACROS;
case ash::AppType::NON_APP:
return api::autotest_private::AppWindowType::APP_WINDOW_TYPE_NONE;
// TODO(oshima): Investigate if we want to have "extension" type.
......
......@@ -351,7 +351,8 @@ namespace autotestPrivate {
ArcApp,
CrostiniApp,
SystemApp,
ExtensionApp
ExtensionApp,
Lacros
};
// A mapping of HotseatState in ash/public/cpp/shelf_types.h.
......
......@@ -127,6 +127,7 @@ static_library("exo") {
"//ash/keyboard/ui",
"//ash/public/cpp",
"//chromeos/constants",
"//chromeos/crosapi/cpp",
"//ui/events/ozone/layout",
]
sources += [
......
......@@ -3,6 +3,7 @@ include_rules = [
"+cc",
"+chromeos/audio/chromeos_sounds.h",
"+chromeos/constants/chromeos_features.h",
"+chromeos/crosapi/cpp/crosapi_constants.h",
"+components/viz/common",
"+components/viz/host",
"+device/gamepad",
......
......@@ -26,6 +26,7 @@
#include "base/trace_event/trace_event.h"
#include "base/trace_event/traced_value.h"
#include "cc/trees/layer_tree_frame_sink.h"
#include "chromeos/crosapi/cpp/crosapi_constants.h"
#include "components/exo/shell_surface_util.h"
#include "components/exo/surface.h"
#include "components/exo/wm_helper.h"
......@@ -66,6 +67,11 @@ void SetSkipImeProcessingToDescendentSurfaces(aura::Window* window) {
SetSkipImeProcessingToDescendentSurfaces(child);
}
// Returns true, if the given ID represents Lacros.
bool IsLacrosAppId(base::StringPiece app_id) {
return base::StartsWith(app_id, crosapi::kLacrosAppIdPrefix);
}
// The accelerator keys used to close ShellSurfaces.
const struct {
ui::KeyboardCode keycode;
......@@ -409,8 +415,11 @@ void ShellSurfaceBase::SetApplicationId(const char* application_id) {
else
application_id_.reset();
if (widget_ && widget_->GetNativeWindow())
if (widget_ && widget_->GetNativeWindow()) {
SetShellApplicationId(widget_->GetNativeWindow(), application_id_);
if (application_id_.has_value() && IsLacrosAppId(*application_id_))
SetLacrosAppType(widget_->GetNativeWindow());
}
}
void ShellSurfaceBase::SetStartupId(const char* startup_id) {
......@@ -944,6 +953,8 @@ void ShellSurfaceBase::CreateShellSurfaceWidget(
aura::EventTargetingPolicy::kTargetAndDescendants);
InstallCustomWindowTargeter();
SetShellApplicationId(window, application_id_);
if (application_id_.has_value() && IsLacrosAppId(*application_id_))
SetLacrosAppType(window);
SetShellStartupId(window, startup_id_);
SetShellMainSurface(window, root_surface());
......
......@@ -97,6 +97,11 @@ void SetArcAppType(aura::Window* window) {
static_cast<int>(ash::AppType::ARC_APP));
}
void SetLacrosAppType(aura::Window* window) {
window->SetProperty(aura::client::kAppType,
static_cast<int>(ash::AppType::LACROS));
}
void SetShellStartupId(aura::Window* window,
const base::Optional<std::string>& id) {
TRACE_EVENT1("exo", "SetStartupId", "startup_id", id ? *id : "null");
......
......@@ -37,6 +37,9 @@ const std::string* GetShellApplicationId(const aura::Window* window);
// Sets ARC app type for the provided |window|.
void SetArcAppType(aura::Window* window);
// Sets Lacros app type for the provided |window|.
void SetLacrosAppType(aura::Window* window);
// Sets the startup ID for the window. The startup ID identifies the
// application using startup notification protocol.
void SetShellStartupId(aura::Window* window,
......
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