Index: components/framelet/browser/framelet_guest.h |
diff --git a/components/framelet/browser/framelet_guest.h b/components/framelet/browser/framelet_guest.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..001e73e0e99ec153468ab13ef17bd2173e012a34 |
--- /dev/null |
+++ b/components/framelet/browser/framelet_guest.h |
@@ -0,0 +1,84 @@ |
+// Copyright 2015 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_FRAMELET_BROWSER_FRAMELET_GUEST_H_ |
+#define COMPONENTS_FRAMELET_BROWSER_FRAMELET_GUEST_H_ |
+ |
+#include "components/framelet/browser/framelet_memory_tracker_client.h" |
+#include "components/framelet/browser/resource_usage_reporter.h" |
+#include "components/framelet/browser/resource_usage_reporter_client.h" |
+#include "components/guest_view/browser/guest_view.h" |
+ |
+namespace blink { |
+class WebInputEvent; |
+} |
+ |
+namespace framelet { |
+ |
+class FrameletGuest : public guest_view::GuestView<FrameletGuest>, |
+ public FrameletMemoryTrackerClient, |
+ public ResourceUsageReporterClient<int> { |
+ public: |
+ static const char Type[]; |
+ |
+ static guest_view::GuestViewBase* Create( |
+ content::WebContents* owner_web_contents); |
+ |
+ void AttachToEmbedderFrame(int element_instance_id, |
+ int embedder_local_render_frame_id, |
+ const base::DictionaryValue& params); |
+ |
+ private: |
+ explicit FrameletGuest(content::WebContents* owner_web_contents); |
+ ~FrameletGuest() override; |
+ |
+ // FrameletMemoryTrackerClient implementation. |
+ void ReportHeapSize(int heap_size) override; |
+ |
+ // ResourceUsageReporterClient implementation. |
+ void OnResourceUsageLevelChanged( |
+ const ResourceUsageLevel& usage_level) override; |
+ scoped_ptr<ResourceUsageRange<int>> GetRangeForUsageLevel( |
+ const ResourceUsageLevel& usage_level) const override; |
+ |
+ // BrowserPluginGuestDelegate implementation. |
+ bool SetChildFrameSurface(const cc::SurfaceId& surface_id, |
+ const gfx::Size& frame_size, |
+ float scale_factor, |
+ const cc::SurfaceSequence& sequence) override; |
+ |
+ // content::WebContentsDelegate implementation. |
+ bool HandleContextMenu(const content::ContextMenuParams& params) override; |
+ |
+ // GuestViewBase implementation. |
+ bool CanRunInDetachedState() const final; |
+ const char* GetAPINamespace() const final; |
+ int GetTaskPrefix() const final; |
+ void CreateWebContents( |
+ const base::DictionaryValue& create_params, |
+ const guest_view::GuestViewBase::WebContentsCreatedCallback& callback) |
+ final; |
+ void DidAttachToEmbedder() final; |
+ void DidInitialize(const base::DictionaryValue& create_params) final; |
+ bool OnMessageReceivedFromEmbedder(const IPC::Message& message) final; |
+ void WillDestroy() final; |
+ |
+ // Message handlers. |
+ void OnDestroyFramelet(int element_instance_id); |
+ void OnForwardInputEvent(int element_instance_id, |
+ const blink::WebInputEvent* event); |
+ void OnResizeFramelet(int element_instance_id, const gfx::Size& new_size); |
+ void OnSetContainerVisible(int element_instance_id, bool visible); |
+ void OnSetFocus(int element_instance_id, |
+ bool focused, |
+ blink::WebFocusType focus_type); |
+ |
+ bool monitor_resources_; |
+ scoped_ptr<ResourceUsageReporter<int>> resource_usage_reporter_; |
+ DISALLOW_COPY_AND_ASSIGN(FrameletGuest); |
+}; |
+ |
+} // namespace framelet |
+ |
+#endif // COMPONENTS_FRAMELET_BROWSER_FRAMELET_GUEST_H_ |