Commit 6bd1e0fc authored by Antonio Gomes's avatar Antonio Gomes Committed by Santosh Mahto

Rework our "access policy" implementation

Patch introduces a ExternalWindowAccessPolicy class,
that allows us to run both chrome/mus and services_unittests
using the same "access policy" instance.

Previously, we were switching from a tweaked DefaultAccessPolicy
use (chrome/mus) to WindowManagerAccessPolicy use (unit tests).
Later we refactored out implementation to use the "manually
created display" mode, and sticked with WindowManagerAccessPolicy
altogether.

At this time, we switch from using our own: ExternalWindowAccessPolicy.
It inherits from WindowManagerAccessPolicy and reimplements the methods
relevant for us (namely, ::CanSetWindowBounds).

Issue #133
Issue #149

fixup! Rework our "access policy" implementation

Set the proper access policy from WindowServer::CreateTreeForWindowManager,
now that ExternalWindowTreeFactory uses it.

Issue #266
parent 5c8399fd
......@@ -53,6 +53,8 @@ static_library("lib") {
"event_targeter.cc",
"event_targeter.h",
"event_targeter_delegate.h",
"external_window_access_policy.cc",
"external_window_access_policy.h",
"external_window_tree_factory.cc",
"external_window_tree_factory.h",
"focus_controller.cc",
......
// Copyright 2017 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 "services/ui/ws/external_window_access_policy.h"
#include "services/ui/ws/access_policy_delegate.h"
#include "services/ui/ws/server_window.h"
namespace ui {
namespace ws {
ExternalWindowAccessPolicy::ExternalWindowAccessPolicy() {}
ExternalWindowAccessPolicy::~ExternalWindowAccessPolicy() {}
bool ExternalWindowAccessPolicy::CanSetWindowBounds(
const ServerWindow* window) const {
return WasCreatedByThisClient(window) ||
delegate_->HasRootForAccessPolicy(window);
}
bool ExternalWindowAccessPolicy::CanSetWindowProperties(
const ServerWindow* window) const {
return WasCreatedByThisClient(window) ||
delegate_->HasRootForAccessPolicy(window);
}
} // namespace ws
} // namespace ui
// Copyright 2017 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.
#ifndef SERVICES_UI_WS_EXTERNAL_WINDOW_ACCESS_POLICY_H_
#define SERVICES_UI_WS_EXTERNAL_WINDOW_ACCESS_POLICY_H_
#include <stdint.h>
#include "base/macros.h"
#include "services/ui/ws/window_manager_access_policy.h"
namespace ui {
namespace ws {
class AccessPolicyDelegate;
// AccessPolicy for all clients, except the window manager.
class ExternalWindowAccessPolicy : public WindowManagerAccessPolicy {
public:
ExternalWindowAccessPolicy();
~ExternalWindowAccessPolicy() override;
private:
// WindowManagerAccessPolicy:
bool CanSetWindowBounds(const ServerWindow* window) const override;
bool CanSetWindowProperties(const ServerWindow* window) const override;
DISALLOW_COPY_AND_ASSIGN(ExternalWindowAccessPolicy);
};
} // namespace ws
} // namespace ui
#endif // SERVICES_UI_WS_EXTERNAL_WINDOW_ACCESS_POLICY_H_
......@@ -5,8 +5,6 @@
#ifndef SERVICES_UI_WS_WINDOW_MANAGER_ACCESS_POLICY_H_
#define SERVICES_UI_WS_WINDOW_MANAGER_ACCESS_POLICY_H_
#include <stdint.h>
#include "base/macros.h"
#include "services/ui/ws/access_policy.h"
......@@ -71,12 +69,15 @@ class WindowManagerAccessPolicy : public AccessPolicy {
bool CanSetWindowManager() const override;
bool IsValidIdForNewWindow(const ClientWindowId& id) const override;
protected:
bool WasCreatedByThisClient(const ServerWindow* window) const;
AccessPolicyDelegate* delegate_ = nullptr;
private:
bool IsWindowKnown(const ServerWindow* window) const;
bool WasCreatedByThisClient(const ServerWindow* window) const;
ClientSpecificId client_id_ = 0u;
AccessPolicyDelegate* delegate_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(WindowManagerAccessPolicy);
};
......
......@@ -13,6 +13,7 @@
#include "services/ui/ws/display.h"
#include "services/ui/ws/display_creation_config.h"
#include "services/ui/ws/display_manager.h"
#include "services/ui/ws/external_window_access_policy.h"
#include "services/ui/ws/frame_generator.h"
#include "services/ui/ws/gpu_host.h"
#include "services/ui/ws/operation.h"
......@@ -176,8 +177,12 @@ WindowTree* WindowServer::CreateTreeForWindowManager(
delegate_->OnWillCreateTreeForWindowManager(
automatically_create_display_roots);
std::unique_ptr<AccessPolicy> access_policy = in_external_window_mode_
? base::WrapUnique(new ExternalWindowAccessPolicy)
: base::WrapUnique(new WindowManagerAccessPolicy);
std::unique_ptr<WindowTree> window_tree(new WindowTree(
this, user_id, nullptr, base::WrapUnique(new WindowManagerAccessPolicy)));
this, user_id, nullptr, std::move(access_policy)));
std::unique_ptr<WindowTreeBinding> window_tree_binding =
delegate_->CreateWindowTreeBinding(
WindowServerDelegate::BindingType::WINDOW_MANAGER, this,
......
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