blob: 2db6715ff9278d419dc1a0835d2362eed47ab7f7 [file] [log] [blame]
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <memory>
#include "base/callback_forward.h"
#include "base/component_export.h"
#include "base/macros.h"
#include "services/ws/public/mojom/window_tree.mojom.h"
namespace aura {
class Window;
namespace ws {
class WindowService;
class WindowTree;
class WindowTreeBinding;
// Embedding is created any time a client calls Embed() or EmbedUsingToken()
// (Embedding is not created for top-levels). Embedding has two distinct
// configurations:
// . The Embedding does not own the embedded WindowTree. This happens if
// ScheduleEmbedForExistingClient() was used.
// . In all other cases Embedding owns the embedded WindowTree.
// Embedding is owned by the Window associated with the embedding.
Embedding(WindowTree* embedding_tree,
aura::Window* window,
bool embedding_tree_intercepts_events);
void Init(WindowService* window_service,
mojom::WindowTreeClientPtr window_tree_client_ptr,
mojom::WindowTreeClient* window_tree_client,
base::OnceClosure connection_lost_callback);
// Initializes the Embedding as the result of
// ScheduleEmbedForExistingClient().
void InitForEmbedInExistingTree(WindowTree* embedded_tree);
WindowTree* embedding_tree() { return embedding_tree_; }
bool embedding_tree_intercepts_events() const {
return embedding_tree_intercepts_events_;
// Used during destruction to ensure the |embedded_tree_| is not notified.
void clear_embedded_tree() { embedded_tree_ = nullptr; }
WindowTree* embedded_tree() { return embedded_tree_; }
aura::Window* window() { return window_; }
WindowTreeBinding* binding() { return binding_.get(); }
// The client that initiated the embedding. This is null if the embedding
// was completed locally (by way of ScheduleEmbedForExistingClient()).
WindowTree* embedding_tree_;
// The window the embedding is in.
aura::Window* window_;
// If true, all events that would normally target the embedded tree are
// instead sent to the tree that created the embedding. For example, consider
// the Window hierarchy A1->B1->C2 where tree 1 created A1 and B1, tree 1
// embedded tree 2 in window B1, and tree 2 created C2. If an event occurs
// that would normally target C2, then the event is instead sent to tree 1.
// Embedded trees can always observe pointer events, regardless of this value.
const bool embedding_tree_intercepts_events_;
// |binding_| is created if the Embedding owns the embedded WindowTree.
std::unique_ptr<WindowTreeBinding> binding_;
// The embedded WindowTree. If |binding_| is non-null, this comes from the
// WindowTreeBinding. If |binding_| is null, this is the value supplied to
// InitForEmbedInExistingTree().
WindowTree* embedded_tree_ = nullptr;
} // namespace ws