2 * Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
6 * by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 #ifndef ANBOX_APPLICATION_MANAGER_H_
19 #define ANBOX_APPLICATION_MANAGER_H_
21 #include "anbox/android/intent.h"
22 #include "anbox/do_not_copy_or_move.h"
23 #include "anbox/graphics/rect.h"
24 #include "anbox/wm/stack.h"
28 #include <core/property.h>
31 namespace application {
32 class Manager : public DoNotCopyOrMove {
34 virtual void launch(const android::Intent &intent,
35 const graphics::Rect &launch_bounds = graphics::Rect::Invalid,
36 const wm::Stack::Id &stack = wm::Stack::Id::Default) = 0;
38 virtual core::Property<bool>& ready() = 0;
41 class RestrictedManager : public Manager {
44 const std::shared_ptr<Manager> &other,
45 const wm::Stack::Id &launch_stack = wm::Stack::Id::Invalid) :
47 launch_stack_(launch_stack) {}
49 virtual ~RestrictedManager() {}
51 void launch(const android::Intent &intent,
52 const graphics::Rect &launch_bounds = graphics::Rect::Invalid,
53 const wm::Stack::Id &stack = wm::Stack::Id::Default) override {
54 auto selected_stack = stack;
55 // If we have a static launch stack set use that one instead of
56 // the one the caller gave us.
57 if (launch_stack_ != wm::Stack::Id::Invalid)
58 selected_stack = launch_stack_;
59 other_->launch(intent, launch_bounds, selected_stack);
62 core::Property<bool>& ready() override { return other_->ready(); }
65 std::shared_ptr<Manager> other_;
66 wm::Stack::Id launch_stack_;
68 } // namespace application