security_delegate.cc 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // Copyright 2021 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "components/exo/security_delegate.h"
  5. #include <memory>
  6. #include <string>
  7. #include "ash/public/cpp/app_types_util.h"
  8. #include "components/exo/shell_surface_util.h"
  9. namespace exo {
  10. namespace {
  11. class DefaultSecurityDelegate : public SecurityDelegate {
  12. public:
  13. ~DefaultSecurityDelegate() override = default;
  14. // SecurityDelegate:
  15. std::string GetSecurityContext() const override { return ""; }
  16. bool CanLockPointer(aura::Window* toplevel) const override {
  17. // TODO(b/200896773): Move this out from exo's default security delegate
  18. // define in client's security delegates.
  19. return ash::IsArcWindow(toplevel) || ash::IsLacrosWindow(toplevel);
  20. }
  21. };
  22. } // namespace
  23. SecurityDelegate::~SecurityDelegate() = default;
  24. // static
  25. std::unique_ptr<SecurityDelegate>
  26. SecurityDelegate::GetDefaultSecurityDelegate() {
  27. return std::make_unique<DefaultSecurityDelegate>();
  28. }
  29. bool SecurityDelegate::CanSelfActivate(aura::Window* window) const {
  30. // TODO(b/233691818): The default should be "false", and clients should
  31. // override that if they need to self-activate.
  32. //
  33. // Unfortunately, several clients don't have their own SecurityDelegate yet,
  34. // so we will continue to use the old exo::Permissions stuff until they do.
  35. return HasPermissionToActivate(window);
  36. }
  37. bool SecurityDelegate::CanLockPointer(aura::Window* window) const {
  38. return false;
  39. }
  40. } // namespace exo