Index: content/browser/browser_plugin/browser_plugin_host.h |
diff --git a/content/browser/browser_plugin/browser_plugin_host.h b/content/browser/browser_plugin/browser_plugin_host.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..c864059169bf464037e2067bc42230abb6706662 |
--- /dev/null |
+++ b/content/browser/browser_plugin/browser_plugin_host.h |
@@ -0,0 +1,114 @@ |
+// Copyright (c) 2012 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 CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_HOST_H__ |
+#define CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_HOST_H__ |
+#pragma once |
+ |
+#include <map> |
+#include <set> |
+ |
+#include "content/public/browser/notification_registrar.h" |
+#include "content/public/browser/notification_observer.h" |
+#include "content/public/browser/web_contents_observer.h" |
+#include "googleurl/src/gurl.h" |
+#include "ppapi/c/pp_instance.h" |
+#include "ui/gfx/size.h" |
+ |
+class WebContentsImpl; |
+ |
+namespace content { |
+ |
+class BrowserPluginHost: public WebContentsObserver, |
+ public NotificationObserver { |
+ public: |
+ BrowserPluginHost(WebContentsImpl* web_contents); |
+ |
+ virtual ~BrowserPluginHost(); |
+ |
+ BrowserPluginHost* GetGuestByContainerID(int container_id); |
+ |
+ void RegisterContainerInstance( |
+ int container_id, |
+ BrowserPluginHost* observer); |
+ |
+ // An embedder BrowserPluginHost keeps track of |
+ // its guests so that if it navigates away, its associated RenderView |
+ // crashes or it is hidden, it takes appropriate action on the guest. |
+ void AddGuest(WebContentsImpl* guest, int64 frame_id); |
+ |
+ void RemoveGuest(WebContentsImpl* guest); |
+ |
+ WebContentsImpl* embedder() const { return embedder_; } |
+ |
+ void set_embedder(WebContentsImpl* embedder) { embedder_ = embedder; } |
+ |
+ int instance_id() const { return instance_id_; } |
+ |
+ void set_instance_id(int instance_id) { instance_id_ = instance_id; } |
+ |
+ void set_url(const GURL& url) { url_ = url; } |
+ |
+ const GURL& url() const { return url_; } |
+ |
+ void set_initial_size(const gfx::Size& size) { initial_size_ = size; } |
+ |
+ const gfx::Size& initial_size() const { return initial_size_; } |
+ |
+ // WebContentObserver implementation. |
+ |
+ virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
+ |
+ virtual void DidCommitProvisionalLoadForFrame( |
+ int64 frame_id, |
+ bool is_main_frame, |
+ const GURL& url, |
+ PageTransition transition_type) OVERRIDE; |
+ |
+ virtual void RenderViewDeleted(RenderViewHost* render_view_host) OVERRIDE; |
+ |
+ virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE; |
+ |
+ virtual void WebContentsDestroyed(WebContents* web_contents) OVERRIDE; |
+ |
+ private: |
+ typedef std::map<WebContentsImpl*, int64> GuestMap; |
+ typedef std::map<int, BrowserPluginHost*> ContainerInstanceMap; |
+ |
+ void OnNavigateFromEmbedder(int32 instance_id, |
+ long long frame_id, |
+ const std::string& src, |
+ const gfx::Size& size); |
+ |
+ void OnNavigateFromGuest(PP_Instance instance, |
+ const std::string& src); |
+ |
+ void OnMapInstance(int routing_id, PP_Instance instance); |
+ |
+ void OnResizeGuest(int width, int height); |
+ |
+ void OnConnectToChannel(const IPC::ChannelHandle& handle); |
+ |
+ void DestroyGuests(); |
+ |
+ // NotificationObserver method override. |
+ virtual void Observe(int type, |
+ const NotificationSource& source, |
+ const NotificationDetails& details) OVERRIDE; |
+ |
+ // A scoped container for notification registries. |
+ NotificationRegistrar registrar_; |
+ WebContentsImpl* embedder_; |
+ // An identifier that uniquely identifies a browser plugin container |
+ // within an embedder. |
+ int instance_id_; |
+ GURL url_; |
+ gfx::Size initial_size_; |
+ GuestMap guests_; |
+ ContainerInstanceMap guests_by_container_id_; |
+}; |
+ |
+} // namespace content |
+ |
+#endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_HOST_H_ |