summaryrefslogtreecommitdiffstats
path: root/mash/wm/window_manager_impl.h
blob: e83fc0950e38fc6c5f94e67da2fd2a6c92b8261d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright 2015 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 MASH_WM_WINDOW_MANAGER_IMPL_H_
#define MASH_WM_WINDOW_MANAGER_IMPL_H_

#include "base/macros.h"
#include "components/mus/common/types.h"
#include "components/mus/public/cpp/window_manager_delegate.h"
#include "components/mus/public/cpp/window_observer.h"
#include "components/mus/public/interfaces/window_manager.mojom.h"

namespace mash {
namespace wm {

class WindowManagerApplication;

using WindowManagerErrorCodeCallback =
    const mojo::Callback<void(mus::mojom::WindowManagerErrorCode)>;

class WindowManagerImpl : public mus::mojom::WindowManager,
                          public mus::WindowObserver,
                          public mus::WindowManagerDelegate {
 public:
  explicit WindowManagerImpl(WindowManagerApplication* state);
  ~WindowManagerImpl() override;

 private:
  gfx::Rect CalculateDefaultBounds(mus::Window* window) const;
  gfx::Rect GetMaximizedWindowBounds() const;

  // mus::mojom::WindowManager:
  void OpenWindow(mus::mojom::WindowTreeClientPtr client,
                  mojo::Map<mojo::String, mojo::Array<uint8_t>>
                      transport_properties) override;
  void GetConfig(const GetConfigCallback& callback) override;

  // WindowManagerDelegate:
  bool OnWmSetBounds(mus::Window* window, gfx::Rect* bounds) override;
  bool OnWmSetProperty(mus::Window* window,
                       const std::string& name,
                       scoped_ptr<std::vector<uint8_t>>* new_data) override;

  mus::Window* GetContainerForChild(mus::Window* child);

  WindowManagerApplication* state_;

  DISALLOW_COPY_AND_ASSIGN(WindowManagerImpl);
};

}  // namespace wm
}  // namespace mash

#endif  // MASH_WM_WINDOW_MANAGER_IMPL_H_