summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/modules/picture_in_picture/picture_in_picture_window.h
blob: bb53a2fb62774e9aad166336f819da0a70a444db (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
// 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 THIRD_PARTY_BLINK_RENDERER_MODULES_PICTURE_IN_PICTURE_PICTURE_IN_PICTURE_WINDOW_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_PICTURE_IN_PICTURE_PICTURE_IN_PICTURE_WINDOW_H_

#include "third_party/blink/renderer/bindings/core/v8/active_script_wrappable.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/modules/event_target_modules.h"
#include "third_party/blink/renderer/platform/heap/handle.h"
#include "ui/gfx/geometry/size.h"

namespace blink {

// The PictureInPictureWindow is meant to be used only by
// PictureInPictureController and is fundamentally just a simple proxy to get
// information such as dimensions about the current Picture-in-Picture window.
class PictureInPictureWindow
    : public EventTargetWithInlineData,
      public ActiveScriptWrappable<PictureInPictureWindow>,
      public ExecutionContextClient {
  USING_GARBAGE_COLLECTED_MIXIN(PictureInPictureWindow);
  DEFINE_WRAPPERTYPEINFO();

 public:
  PictureInPictureWindow(ExecutionContext*, const gfx::Size& size);

  int width() const { return size_.width(); }
  int height() const { return size_.height(); }
  Document* document() const { return nullptr; }

  // Called when Picture-in-Picture window state is closed.
  void OnClose();

  // Called when the Picture-in-Picture window is resized.
  void OnResize(const gfx::Size&);

  DEFINE_ATTRIBUTE_EVENT_LISTENER(resize, kResize)

  // EventTarget overrides.
  const AtomicString& InterfaceName() const override;
  ExecutionContext* GetExecutionContext() const override {
    return ExecutionContextClient::GetExecutionContext();
  }

  // ActiveScriptWrappable overrides.
  bool HasPendingActivity() const override;

  void Trace(Visitor*) override;

 protected:
  // EventTarget overrides.
  void AddedEventListener(const AtomicString& event_type,
                          RegisteredEventListener&) override;

 private:
  // The Picture-in-Picture window size in pixels.
  gfx::Size size_;

  DISALLOW_IMPLICIT_CONSTRUCTORS(PictureInPictureWindow);
};

}  // namespace blink

#endif  // THIRD_PARTY_BLINK_RENDERER_MODULES_PICTURE_IN_PICTURE_PICTURE_IN_PICTURE_WINDOW_H_