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_BROWSER_FRAMELET_GUEST_H_ |
| 6 #define COMPONENTS_FRAMELET_BROWSER_FRAMELET_GUEST_H_ |
| 7 |
| 8 #include "components/framelet/browser/framelet_memory_tracker_client.h" |
| 9 #include "components/framelet/browser/resource_usage_reporter.h" |
| 10 #include "components/framelet/browser/resource_usage_reporter_client.h" |
| 11 #include "components/guest_view/browser/guest_view.h" |
| 12 |
| 13 namespace blink { |
| 14 class WebInputEvent; |
| 15 } |
| 16 |
| 17 namespace framelet { |
| 18 |
| 19 class FrameletGuest : public guest_view::GuestView<FrameletGuest>, |
| 20 public FrameletMemoryTrackerClient, |
| 21 public ResourceUsageReporterClient<int> { |
| 22 public: |
| 23 static const char Type[]; |
| 24 |
| 25 static guest_view::GuestViewBase* Create( |
| 26 content::WebContents* owner_web_contents); |
| 27 |
| 28 void AttachToEmbedderFrame(int element_instance_id, |
| 29 int embedder_local_render_frame_id, |
| 30 const base::DictionaryValue& params); |
| 31 |
| 32 private: |
| 33 explicit FrameletGuest(content::WebContents* owner_web_contents); |
| 34 ~FrameletGuest() override; |
| 35 |
| 36 // FrameletMemoryTrackerClient implementation. |
| 37 void ReportHeapSize(int heap_size) override; |
| 38 |
| 39 // ResourceUsageReporterClient implementation. |
| 40 void OnResourceUsageLevelChanged( |
| 41 const ResourceUsageLevel& usage_level) override; |
| 42 scoped_ptr<ResourceUsageRange<int>> GetRangeForUsageLevel( |
| 43 const ResourceUsageLevel& usage_level) const override; |
| 44 |
| 45 // BrowserPluginGuestDelegate implementation. |
| 46 bool SetChildFrameSurface(const cc::SurfaceId& surface_id, |
| 47 const gfx::Size& frame_size, |
| 48 float scale_factor, |
| 49 const cc::SurfaceSequence& sequence) override; |
| 50 |
| 51 // content::WebContentsDelegate implementation. |
| 52 bool HandleContextMenu(const content::ContextMenuParams& params) override; |
| 53 |
| 54 // GuestViewBase implementation. |
| 55 bool CanRunInDetachedState() const final; |
| 56 const char* GetAPINamespace() const final; |
| 57 int GetTaskPrefix() const final; |
| 58 void CreateWebContents( |
| 59 const base::DictionaryValue& create_params, |
| 60 const guest_view::GuestViewBase::WebContentsCreatedCallback& callback) |
| 61 final; |
| 62 void DidAttachToEmbedder() final; |
| 63 void DidInitialize(const base::DictionaryValue& create_params) final; |
| 64 bool OnMessageReceivedFromEmbedder(const IPC::Message& message) final; |
| 65 void WillDestroy() final; |
| 66 |
| 67 // Message handlers. |
| 68 void OnDestroyFramelet(int element_instance_id); |
| 69 void OnForwardInputEvent(int element_instance_id, |
| 70 const blink::WebInputEvent* event); |
| 71 void OnResizeFramelet(int element_instance_id, const gfx::Size& new_size); |
| 72 void OnSetContainerVisible(int element_instance_id, bool visible); |
| 73 void OnSetFocus(int element_instance_id, |
| 74 bool focused, |
| 75 blink::WebFocusType focus_type); |
| 76 |
| 77 bool monitor_resources_; |
| 78 scoped_ptr<ResourceUsageReporter<int>> resource_usage_reporter_; |
| 79 DISALLOW_COPY_AND_ASSIGN(FrameletGuest); |
| 80 }; |
| 81 |
| 82 } // namespace framelet |
| 83 |
| 84 #endif // COMPONENTS_FRAMELET_BROWSER_FRAMELET_GUEST_H_ |
OLD | NEW |