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..2a16f0776c1f7054eebad4d88229fd0b30eb3095 |
--- /dev/null |
+++ b/components/framelet/browser/framelet_guest.h |
@@ -0,0 +1,92 @@ |
+// 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/framelet/common/framelet.mojom.h" |
+#include "components/guest_view/browser/guest_view.h" |
+#include "mojo/public/cpp/bindings/binding.h" |
+ |
+namespace blink { |
+class WebInputEvent; |
+} |
+ |
+namespace cc { |
+struct SurfaceId; |
+struct SurfaceSequence; |
+} |
+ |
+namespace framelet { |
+ |
+class FrameletGuest : public guest_view::GuestView<FrameletGuest>, |
+ public FrameletMemoryTrackerClient, |
+ public ResourceUsageReporterClient<int>, |
+ public mojom::Framelet { |
+ public: |
+ static const char Type[]; |
+ |
+ static guest_view::GuestViewBase* Create( |
+ content::WebContents* owner_web_contents); |
+ |
+ void Bind(mojo::InterfaceRequest<mojom::Framelet> request); |
+ |
+ private: |
+ explicit FrameletGuest(content::WebContents* owner_web_contents); |
+ ~FrameletGuest() override; |
+ |
+ // mojom::Framelet implementation. |
+ void Attach(mojom::FrameletClientPtr client, |
+ mojo::Map<mojo::String, mojom::ValuePtr> params) override; |
+ void Destroy() override; |
+ void ForwardInput(mojo::Array<uint8_t> event) override; |
+ void Resize(mojo::SizePtr new_size) override; |
+ void SetFocus(bool focused, mojom::FocusType focus_type) override; |
+ void SetVisible(bool visible) 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; |
+ 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; |
+ const char* GetAPINamespace() const final; |
+ int GetTaskPrefix() const final; |
+ void WillDestroy() final; |
+ |
+ bool monitor_resources_; |
+ scoped_ptr<ResourceUsageReporter<int>> resource_usage_reporter_; |
+ |
+ mojom::FrameletClientPtr client_; |
+ mojo::Binding<mojom::Framelet> binding_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(FrameletGuest); |
+}; |
+ |
+} // namespace framelet |
+ |
+#endif // COMPONENTS_FRAMELET_BROWSER_FRAMELET_GUEST_H_ |