summaryrefslogtreecommitdiffstats
path: root/mash/wm/non_client_frame_controller.h
blob: 506dd3612e6d3746e911b8c138e2a3e6c203ca31 (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// 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_NON_CLIENT_FRAME_CONTROLLER_H_
#define MASH_WM_NON_CLIENT_FRAME_CONTROLLER_H_

#include <stdint.h>

#include "base/macros.h"
#include "base/strings/string16.h"
#include "components/mus/public/cpp/window_observer.h"
#include "ui/views/widget/widget_delegate.h"

namespace gfx {
class Insets;
}

namespace mojo {
class Shell;
}

namespace mus {
class Window;
namespace mojom {
class WindowTreeHost;
}
}

namespace mash {
namespace wm {

// Provides the non-client frame for mus Windows.
class NonClientFrameController : public views::WidgetDelegateView,
                                 public mus::WindowObserver {
 public:
  // NonClientFrameController deletes itself when |window| is destroyed.
  NonClientFrameController(mojo::Shell* shell,
                           mus::Window* window,
                           mus::mojom::WindowTreeHost* window_tree_host);

  // Returns the preferred client area insets.
  static gfx::Insets GetPreferredClientAreaInsets();

  // Returns the width needed to display the standard set of buttons on the
  // title bar.
  static int GetMaxTitleBarButtonWidth();

  mus::Window* window() { return window_; }

 private:
  ~NonClientFrameController() override;

  // views::WidgetDelegateView:
  base::string16 GetWindowTitle() const override;
  views::View* GetContentsView() override;
  bool CanResize() const override;
  bool CanMaximize() const override;
  bool CanMinimize() const override;
  views::ClientView* CreateClientView(views::Widget* widget) override;

  // mus::WindowObserver:
  void OnWindowSharedPropertyChanged(
      mus::Window* window,
      const std::string& name,
      const std::vector<uint8_t>* old_data,
      const std::vector<uint8_t>* new_data) override;
  void OnWindowDestroyed(mus::Window* window) override;

  views::Widget* widget_;

  // WARNING: as widget delays destruction there is a portion of time when this
  // is null.
  mus::Window* window_;

  mus::mojom::WindowTreeHost* mus_window_tree_host_;

  DISALLOW_COPY_AND_ASSIGN(NonClientFrameController);
};

}  // namespace wm
}  // namespace mash

#endif  // MASH_WM_NON_CLIENT_FRAME_CONTROLLER_H_