1 // Copyright 2020 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef CONTENT_PUBLIC_TEST_FAKE_FRAME_WIDGET_H_
6 #define CONTENT_PUBLIC_TEST_FAKE_FRAME_WIDGET_H_
7 
8 #include "base/i18n/rtl.h"
9 #include "build/build_config.h"
10 #include "mojo/public/cpp/bindings/associated_receiver.h"
11 #include "mojo/public/cpp/bindings/pending_associated_receiver.h"
12 #include "third_party/blink/public/mojom/frame/viewport_intersection_state.mojom.h"
13 #include "third_party/blink/public/mojom/page/drag.mojom.h"
14 #include "third_party/blink/public/mojom/page/widget.mojom.h"
15 #include "ui/base/ui_base_types.h"
16 
17 #if defined(OS_MAC)
18 #include "ui/base/mojom/attributed_string.mojom.h"
19 #endif
20 
21 namespace content {
22 
23 class FakeFrameWidget : public blink::mojom::FrameWidget {
24  public:
25   explicit FakeFrameWidget(
26       mojo::PendingAssociatedReceiver<blink::mojom::FrameWidget> frame_widget);
27   ~FakeFrameWidget() override;
28 
29   FakeFrameWidget(const FakeFrameWidget&) = delete;
30   void operator=(const FakeFrameWidget&) = delete;
31 
32   base::i18n::TextDirection GetTextDirection() const;
33   const blink::mojom::ViewportIntersectionStatePtr& GetIntersectionState()
34       const;
35 
36   base::Optional<bool> GetActive() const;
37 
38  private:
DragTargetDragEnter(blink::mojom::DragDataPtr drag_data,const gfx::PointF & point_in_viewport,const gfx::PointF & screen_point,blink::DragOperationsMask operations_allowed,uint32_t key_modifiers,base::OnceCallback<void (blink::DragOperation)> callback)39   void DragTargetDragEnter(
40       blink::mojom::DragDataPtr drag_data,
41       const gfx::PointF& point_in_viewport,
42       const gfx::PointF& screen_point,
43       blink::DragOperationsMask operations_allowed,
44       uint32_t key_modifiers,
45       base::OnceCallback<void(blink::DragOperation)> callback) override {}
DragTargetDragOver(const gfx::PointF & point_in_viewport,const gfx::PointF & screen_point,blink::DragOperationsMask operations_allowed,uint32_t modifiers,DragTargetDragOverCallback callback)46   void DragTargetDragOver(const gfx::PointF& point_in_viewport,
47                           const gfx::PointF& screen_point,
48                           blink::DragOperationsMask operations_allowed,
49                           uint32_t modifiers,
50                           DragTargetDragOverCallback callback) override {}
DragTargetDragLeave(const gfx::PointF & point_in_viewport,const gfx::PointF & screen_point)51   void DragTargetDragLeave(const gfx::PointF& point_in_viewport,
52                            const gfx::PointF& screen_point) override {}
DragTargetDrop(blink::mojom::DragDataPtr drag_data,const gfx::PointF & point_in_viewport,const gfx::PointF & screen_point,uint32_t key_modifiers)53   void DragTargetDrop(blink::mojom::DragDataPtr drag_data,
54                       const gfx::PointF& point_in_viewport,
55                       const gfx::PointF& screen_point,
56                       uint32_t key_modifiers) override {}
DragSourceEndedAt(const gfx::PointF & client_point,const gfx::PointF & screen_point,blink::DragOperation operation)57   void DragSourceEndedAt(const gfx::PointF& client_point,
58                          const gfx::PointF& screen_point,
59                          blink::DragOperation operation) override {}
DragSourceSystemDragEnded()60   void DragSourceSystemDragEnded() override {}
SetBackgroundOpaque(bool value)61   void SetBackgroundOpaque(bool value) override {}
62   void SetTextDirection(base::i18n::TextDirection direction) override;
63   void SetActive(bool active) override;
SetInheritedEffectiveTouchActionForSubFrame(const cc::TouchAction touch_action)64   void SetInheritedEffectiveTouchActionForSubFrame(
65       const cc::TouchAction touch_action) override {}
UpdateRenderThrottlingStatusForSubFrame(bool is_throttled,bool subtree_throttled)66   void UpdateRenderThrottlingStatusForSubFrame(
67       bool is_throttled,
68       bool subtree_throttled) override {}
SetIsInertForSubFrame(bool inert)69   void SetIsInertForSubFrame(bool inert) override {}
70 #if defined(OS_MAC)
71   void GetStringAtPoint(const gfx::Point& point_in_local_root,
72                         GetStringAtPointCallback callback) override;
73 #endif
ShowContextMenu(ui::MenuSourceType source_type,const gfx::Point & location)74   void ShowContextMenu(ui::MenuSourceType source_type,
75                        const gfx::Point& location) override {}
EnableDeviceEmulation(const blink::DeviceEmulationParams & parameters)76   void EnableDeviceEmulation(
77       const blink::DeviceEmulationParams& parameters) override {}
DisableDeviceEmulation()78   void DisableDeviceEmulation() override {}
BindWidgetCompositor(mojo::PendingReceiver<blink::mojom::WidgetCompositor> receiver)79   void BindWidgetCompositor(
80       mojo::PendingReceiver<blink::mojom::WidgetCompositor> receiver) override {
81   }
BindInputTargetClient(mojo::PendingReceiver<viz::mojom::InputTargetClient> receiver)82   void BindInputTargetClient(
83       mojo::PendingReceiver<viz::mojom::InputTargetClient> receiver) override {}
84   void SetViewportIntersection(
85       blink::mojom::ViewportIntersectionStatePtr intersection_state) override;
86 
87   mojo::AssociatedReceiver<blink::mojom::FrameWidget> receiver_;
88   base::i18n::TextDirection text_direction_ =
89       base::i18n::TextDirection::UNKNOWN_DIRECTION;
90   base::Optional<bool> active_;
91   blink::mojom::ViewportIntersectionStatePtr intersection_state_;
92 };
93 
94 }  // namespace content
95 
96 #endif  // CONTENT_PUBLIC_TEST_FAKE_FRAME_WIDGET_H_
97