summaryrefslogtreecommitdiff
path: root/chromium/components/exo/fullscreen_shell_surface.h
blob: 15bedf9c384e0bff2745ebb81056e1584409f0ea (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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// Copyright 2018 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 COMPONENTS_EXO_FULLSCREEN_SHELL_SURFACE_H_
#define COMPONENTS_EXO_FULLSCREEN_SHELL_SURFACE_H_

#include "components/exo/surface_observer.h"
#include "components/exo/surface_tree_host.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/accessibility/ax_tree_id.h"
#include "ui/aura/window_observer.h"
#include "ui/views/widget/widget_delegate.h"

namespace exo {
class Surface;

// This class implements a toplevel fullscreen surface for which position
// and state are managed by the shell.
class FullscreenShellSurface : public SurfaceTreeHost,
                               public SurfaceObserver,
                               public aura::WindowObserver,
                               public views::WidgetDelegate {
 public:
  FullscreenShellSurface();
  ~FullscreenShellSurface() override;

  // Set the callback to run when the user wants the shell surface to be closed.
  // The receiver can chose to not close the window on this signal.
  void set_close_callback(const base::RepeatingClosure& close_callback) {
    close_callback_ = close_callback;
  }

  // Set the callback to run when the surface is destroyed.
  void set_surface_destroyed_callback(
      base::OnceClosure surface_destroyed_callback) {
    surface_destroyed_callback_ = std::move(surface_destroyed_callback);
  }

  // Set the application ID for the surface
  void SetApplicationId(const char* startup_id);

  // Set the startup ID for the surface.
  void SetStartupId(const char* startup_id);

  // Set the Surface in use. Will replace root_surface_ if a surface is
  // currently set. Will remove root_surface_ if |surface| is nullptr.
  void SetSurface(Surface* surface);

  void Maximize();
  void Minimize();
  void Close();

  // SurfaceDelegate:
  void OnSurfaceCommit() override;
  bool IsInputEnabled(Surface* surface) const override;
  void OnSetFrame(SurfaceFrameType type) override;
  void OnSetFrameColors(SkColor active_color, SkColor inactive_color) override;
  void OnSetStartupId(const char* startup_id) override;
  void OnSetApplicationId(const char* application_id) override;

  // SurfaceObserver:
  void OnSurfaceDestroying(Surface* surface) override;

  // views::WidgetDelegate:
  bool CanResize() const override;
  bool CanMaximize() const override;
  bool CanMinimize() const override;
  bool ShouldShowWindowTitle() const override;
  void WindowClosing() override;
  views::Widget* GetWidget() override;
  const views::Widget* GetWidget() const override;
  views::View* GetContentsView() override;
  bool WidgetHasHitTestMask() const override;
  void GetWidgetHitTestMask(SkPath* mask) const override;

  // aura::WindowObserver:
  void OnWindowDestroying(aura::Window* window) override;

  void SetChildAxTreeId(ui::AXTreeID child_ax_tree_id);
  void SetEnabled(bool enabled);
  void GetAccessibleNodeData(ui::AXNodeData* node_data);

 private:
  class FullscreenShellView;
  // Keep the bounds in sync with the root surface bounds.
  void UpdateHostWindowBounds() override;

  void CreateFullscreenShellSurfaceWidget(ui::WindowShowState show_state);
  void CommitWidget();
  bool OnPreWidgetCommit();

  views::Widget* widget_ = nullptr;
  aura::Window* parent_ = nullptr;
  base::Optional<std::string> application_id_;
  base::Optional<std::string> startup_id_;
  base::RepeatingClosure close_callback_;
  base::OnceClosure surface_destroyed_callback_;
  FullscreenShellView* contents_view_ = nullptr;

  DISALLOW_COPY_AND_ASSIGN(FullscreenShellSurface);
};

}  // namespace exo

#endif  // COMPONENTS_EXO_FULLSCREEN_SHELL_SURFACE_H