OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 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 CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_HOST_H__ |
| 6 #define CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_HOST_H__ |
| 7 #pragma once |
| 8 |
| 9 #include <map> |
| 10 #include <set> |
| 11 |
| 12 #include "content/public/browser/notification_registrar.h" |
| 13 #include "content/public/browser/notification_observer.h" |
| 14 #include "content/public/browser/web_contents_observer.h" |
| 15 #include "googleurl/src/gurl.h" |
| 16 #include "ppapi/c/pp_instance.h" |
| 17 #include "ui/gfx/size.h" |
| 18 |
| 19 class WebContentsImpl; |
| 20 |
| 21 namespace content { |
| 22 |
| 23 class BrowserPluginHost: public WebContentsObserver, |
| 24 public NotificationObserver { |
| 25 public: |
| 26 BrowserPluginHost(WebContentsImpl* web_contents); |
| 27 |
| 28 virtual ~BrowserPluginHost(); |
| 29 |
| 30 BrowserPluginHost* GetGuestByContainerID(int container_id); |
| 31 |
| 32 void RegisterContainerInstance( |
| 33 int container_id, |
| 34 BrowserPluginHost* observer); |
| 35 |
| 36 // An embedder BrowserPluginHost keeps track of |
| 37 // its guests so that if it navigates away, its associated RenderView |
| 38 // crashes or it is hidden, it takes appropriate action on the guest. |
| 39 void AddGuest(WebContentsImpl* guest, int64 frame_id); |
| 40 |
| 41 void RemoveGuest(WebContentsImpl* guest); |
| 42 |
| 43 WebContentsImpl* embedder() const { return embedder_; } |
| 44 |
| 45 void set_embedder(WebContentsImpl* embedder) { embedder_ = embedder; } |
| 46 |
| 47 int instance_id() const { return instance_id_; } |
| 48 |
| 49 void set_instance_id(int instance_id) { instance_id_ = instance_id; } |
| 50 |
| 51 void set_url(const GURL& url) { url_ = url; } |
| 52 |
| 53 const GURL& url() const { return url_; } |
| 54 |
| 55 void set_initial_size(const gfx::Size& size) { initial_size_ = size; } |
| 56 |
| 57 const gfx::Size& initial_size() const { return initial_size_; } |
| 58 |
| 59 // WebContentObserver implementation. |
| 60 |
| 61 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 62 |
| 63 virtual void DidCommitProvisionalLoadForFrame( |
| 64 int64 frame_id, |
| 65 bool is_main_frame, |
| 66 const GURL& url, |
| 67 PageTransition transition_type) OVERRIDE; |
| 68 |
| 69 virtual void RenderViewDeleted(RenderViewHost* render_view_host) OVERRIDE; |
| 70 |
| 71 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE; |
| 72 |
| 73 virtual void WebContentsDestroyed(WebContents* web_contents) OVERRIDE; |
| 74 |
| 75 private: |
| 76 typedef std::map<WebContentsImpl*, int64> GuestMap; |
| 77 typedef std::map<int, BrowserPluginHost*> ContainerInstanceMap; |
| 78 |
| 79 void OnNavigateFromEmbedder(int32 instance_id, |
| 80 long long frame_id, |
| 81 const std::string& src, |
| 82 const gfx::Size& size); |
| 83 |
| 84 void OnNavigateFromGuest(PP_Instance instance, |
| 85 const std::string& src); |
| 86 |
| 87 void OnMapInstance(int routing_id, PP_Instance instance); |
| 88 |
| 89 void OnResizeGuest(int width, int height); |
| 90 |
| 91 void OnConnectToChannel(const IPC::ChannelHandle& handle); |
| 92 |
| 93 void DestroyGuests(); |
| 94 |
| 95 // NotificationObserver method override. |
| 96 virtual void Observe(int type, |
| 97 const NotificationSource& source, |
| 98 const NotificationDetails& details) OVERRIDE; |
| 99 |
| 100 // A scoped container for notification registries. |
| 101 NotificationRegistrar registrar_; |
| 102 WebContentsImpl* embedder_; |
| 103 // An identifier that uniquely identifies a browser plugin container |
| 104 // within an embedder. |
| 105 int instance_id_; |
| 106 GURL url_; |
| 107 gfx::Size initial_size_; |
| 108 GuestMap guests_; |
| 109 ContainerInstanceMap guests_by_container_id_; |
| 110 }; |
| 111 |
| 112 } // namespace content |
| 113 |
| 114 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_HOST_H_ |
OLD | NEW |