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