OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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 COMPONENTS_FRAMELET_RENDERER_FRAMELET_CONTAINER_H_ |
| 6 #define COMPONENTS_FRAMELET_RENDERER_FRAMELET_CONTAINER_H_ |
| 7 |
| 8 #include "cc/layers/solid_color_layer.h" |
| 9 #include "cc/layers/ui_resource_layer.h" |
| 10 #include "cc/surfaces/surface_id.h" |
| 11 #include "components/guest_view/common/guest_view_constants.h" |
| 12 #include "components/guest_view/renderer/guest_view_container.h" |
| 13 #include "ipc/ipc_sender.h" |
| 14 #include "third_party/WebKit/public/platform/WebURLLoader.h" |
| 15 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h" |
| 16 #include "third_party/WebKit/public/web/WebFrameletClient.h" |
| 17 #include "ui/gfx/geometry/size.h" |
| 18 |
| 19 namespace blink { |
| 20 class WebLayer; |
| 21 } |
| 22 |
| 23 namespace cc { |
| 24 struct SurfaceSequence; |
| 25 } |
| 26 |
| 27 namespace gfx { |
| 28 class Image; |
| 29 } |
| 30 |
| 31 namespace framelet { |
| 32 |
| 33 enum class ResourceUsageLevel : int; |
| 34 |
| 35 enum class ResourceMonitoring { ENABLED, DISABLED }; |
| 36 |
| 37 class FrameletContainer : public guest_view::GuestViewContainer, |
| 38 public blink::WebFrameletClient { |
| 39 public: |
| 40 FrameletContainer(content::RenderFrame* render_frame, |
| 41 const GURL& url, |
| 42 IPC::Sender* thread_safe_sender); |
| 43 ~FrameletContainer() override; |
| 44 |
| 45 const GURL& url() const { return url_; } |
| 46 |
| 47 const gfx::Size& element_size() const { return element_size_; } |
| 48 |
| 49 bool focused() const { return focused_; } |
| 50 bool visible() const { return visible_; } |
| 51 |
| 52 blink::WebFocusType focus_type() const { return focus_type_; } |
| 53 |
| 54 bool has_guest() const { |
| 55 return guest_instance_id_ != guest_view::kInstanceIDNone; |
| 56 } |
| 57 |
| 58 int guest_instance_id() const { return guest_instance_id_; } |
| 59 |
| 60 void Attach(int guest_instance_id); |
| 61 void Detach(); |
| 62 |
| 63 // GuestViewContainer implementation. |
| 64 bool OnMessage(const IPC::Message& message) override; |
| 65 |
| 66 // WebFrameletClient implementation. |
| 67 void didAttach(blink::WebFramelet* framelet) override; |
| 68 void didDetach() override; |
| 69 void forwardInputEvent(const blink::WebInputEvent* input_event) override; |
| 70 void frameRectsChanged(const blink::WebRect& frame_rect) override; |
| 71 void updateFocus(bool focused, blink::WebFocusType focus_type) override; |
| 72 void updateVisibility(bool visible) override; |
| 73 |
| 74 private: |
| 75 void CreateFrameletIfReady(ResourceMonitoring resource_monitoring); |
| 76 void UpdateClickToPlayLayerPosition(); |
| 77 |
| 78 // TODO(fsamuel): This is likely to cause tear down issues. |
| 79 // We should not be holding a raw pointer to |sender|. |
| 80 static void SatisfyCallbackOnCompositorThread(IPC::Sender* sender, |
| 81 int host_routing_id, |
| 82 int element_instance_id, |
| 83 cc::SurfaceSequence sequence); |
| 84 static void RequireCallbackOnCompositorThread(IPC::Sender* sender, |
| 85 int host_routing_id, |
| 86 int element_instance_id, |
| 87 cc::SurfaceId id, |
| 88 cc::SurfaceSequence sequence); |
| 89 |
| 90 // Message handlers |
| 91 void OnReportMemoryUsage(int element_instance_id, |
| 92 const ResourceUsageLevel& memory_usage); |
| 93 void OnSetChildFrameSurface(int element_instance_id, |
| 94 const cc::SurfaceId& surface_id, |
| 95 const gfx::Size& frame_size, |
| 96 float scale_factor, |
| 97 const cc::SurfaceSequence& sequence); |
| 98 |
| 99 int guest_instance_id_; |
| 100 bool focused_; |
| 101 blink::WebFocusType focus_type_; |
| 102 bool visible_; |
| 103 bool killed_; |
| 104 gfx::Size element_size_; |
| 105 GURL url_; |
| 106 IPC::Sender* thread_safe_sender_; |
| 107 blink::WebFramelet* framelet_; |
| 108 |
| 109 scoped_ptr<blink::WebLayer> web_layer_; |
| 110 scoped_refptr<cc::SolidColorLayer> solid_layer_; |
| 111 |
| 112 const gfx::Image& click_to_play_image_; |
| 113 scoped_refptr<cc::UIResourceLayer> click_to_play_layer_; |
| 114 |
| 115 DISALLOW_COPY_AND_ASSIGN(FrameletContainer); |
| 116 }; |
| 117 |
| 118 } // namespace framelet |
| 119 |
| 120 #endif // COMPONENTS_FRAMELET_RENDERER_FRAMELET_CONTAINER_H_ |
OLD | NEW |