Commit 84738a38 authored by Evan Stade's avatar Evan Stade Committed by Commit Bot

Fix DemoSessionMetricsRecorderTest.BrowserWindows for Mash

In Mash, ShelfWindowWatcher tags unidentified windows with a
default App ID rather than leaving the App ID blank. Update the
test to reflect that.

Bug: 880595
Change-Id: I844c4729b69c956fffd6a3acae1932f13e700158
Reviewed-on: https://chromium-review.googlesource.com/1208727
Commit-Queue: Evan Stade <estade@chromium.org>
Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Reviewed-by: default avatarMichael Giuffrida <michaelpg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#589174}
parent 9d597d7e
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "ash/public/cpp/app_types.h" #include "ash/public/cpp/app_types.h"
#include "ash/public/cpp/window_properties.h" #include "ash/public/cpp/window_properties.h"
#include "ash/shelf/shelf_window_watcher.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "base/time/time.h" #include "base/time/time.h"
...@@ -17,6 +18,7 @@ ...@@ -17,6 +18,7 @@
#include "ui/aura/client/aura_constants.h" #include "ui/aura/client/aura_constants.h"
#include "ui/aura/client/window_types.h" #include "ui/aura/client/window_types.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/base/ui_base_features.h"
#include "ui/base/user_activity/user_activity_detector.h" #include "ui/base/user_activity/user_activity_detector.h"
#include "ui/wm/public/activation_client.h" #include "ui/wm/public/activation_client.h"
...@@ -104,10 +106,18 @@ DemoModeApp GetAppFromWindow(const aura::Window* window) { ...@@ -104,10 +106,18 @@ DemoModeApp GetAppFromWindow(const aura::Window* window) {
if (app_id == extension_misc::kChromeAppId) if (app_id == extension_misc::kChromeAppId)
return DemoModeApp::kBrowser; return DemoModeApp::kBrowser;
// If the window is the "browser" type, having an app ID other than auto is_default = [](const std::string& app_id) {
// kChromeAppId indicates a hosted/bookmark app. if (!features::IsUsingWindowService())
return app_id.empty();
return base::StartsWith(app_id, ShelfWindowWatcher::kDefaultShelfIdPrefix,
base::CompareCase::SENSITIVE);
};
// If the window is the "browser" type, having an app ID other than the
// default indicates a hosted/bookmark app.
if (app_type == ash::AppType::CHROME_APP || if (app_type == ash::AppType::CHROME_APP ||
(app_type == ash::AppType::BROWSER && app_id.size())) { (app_type == ash::AppType::BROWSER && !is_default(app_id))) {
return GetAppFromAppId(app_id); return GetAppFromAppId(app_id);
} }
......
...@@ -43,11 +43,11 @@ ShelfItemType GetShelfItemType(aura::Window* window) { ...@@ -43,11 +43,11 @@ ShelfItemType GetShelfItemType(aura::Window* window) {
// Mash sets and returns an initial default shelf id for unidentified windows. // Mash sets and returns an initial default shelf id for unidentified windows.
// TODO(msw): Extend this Mash behavior to all Ash configs. // TODO(msw): Extend this Mash behavior to all Ash configs.
ShelfID GetShelfID(aura::Window* window) { ShelfID GetShelfID(aura::Window* window) {
if ((features::IsMultiProcessMash() || features::IsSingleProcessMash()) && if (features::IsUsingWindowService() && !window->GetProperty(kShelfIDKey) &&
!window->GetProperty(kShelfIDKey) &&
!wm::GetWindowState(window)->ignored_by_shelf()) { !wm::GetWindowState(window)->ignored_by_shelf()) {
static int id = 0; static int id = 0;
const ash::ShelfID shelf_id("ShelfWindowWatcher" + std::to_string(id++)); const ash::ShelfID shelf_id(ShelfWindowWatcher::kDefaultShelfIdPrefix +
std::to_string(id++));
window->SetProperty(kShelfIDKey, new std::string(shelf_id.Serialize())); window->SetProperty(kShelfIDKey, new std::string(shelf_id.Serialize()));
return shelf_id; return shelf_id;
} }
...@@ -90,6 +90,9 @@ ShelfWindowWatcher::ContainerWindowObserver::ContainerWindowObserver( ...@@ -90,6 +90,9 @@ ShelfWindowWatcher::ContainerWindowObserver::ContainerWindowObserver(
ShelfWindowWatcher::ContainerWindowObserver::~ContainerWindowObserver() = ShelfWindowWatcher::ContainerWindowObserver::~ContainerWindowObserver() =
default; default;
// static
const char ShelfWindowWatcher::kDefaultShelfIdPrefix[] = "ShelfWindowWatcher";
void ShelfWindowWatcher::ContainerWindowObserver::OnWindowHierarchyChanged( void ShelfWindowWatcher::ContainerWindowObserver::OnWindowHierarchyChanged(
const HierarchyChangeParams& params) { const HierarchyChangeParams& params) {
if (!params.old_parent && params.new_parent && if (!params.old_parent && params.new_parent &&
......
...@@ -29,6 +29,8 @@ class ShelfWindowWatcher : public ::wm::ActivationChangeObserver, ...@@ -29,6 +29,8 @@ class ShelfWindowWatcher : public ::wm::ActivationChangeObserver,
explicit ShelfWindowWatcher(ShelfModel* model); explicit ShelfWindowWatcher(ShelfModel* model);
~ShelfWindowWatcher() override; ~ShelfWindowWatcher() override;
static const char kDefaultShelfIdPrefix[];
private: private:
// Observes for windows being added to a root window's default container. // Observes for windows being added to a root window's default container.
class ContainerWindowObserver : public aura::WindowObserver { class ContainerWindowObserver : public aura::WindowObserver {
......
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