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_delegate.h" | |
15 #include "content/public/browser/web_contents_observer.h" | |
16 #include "googleurl/src/gurl.h" | |
17 #include "ppapi/c/pp_instance.h" | |
18 #include "ui/gfx/size.h" | |
19 | |
20 class WebContentsImpl; | |
21 | |
22 namespace content { | |
23 | |
24 // The primary purpose of BrowserPluginHost is to allow an embedder | |
25 // to manage the lifetime of its guests. It cleans up its guests | |
26 // on navigation, crashes, and "hides" guests when it hides. | |
27 // For the guest, BrowserPluginHost keeps track of its embedder, | |
28 // its BrowserPlugin instance ID, and some initialization state | |
29 // such as initial size and URL. | |
30 class BrowserPluginHost: public WebContentsObserver, | |
31 public NotificationObserver, | |
32 public WebContentsDelegate { | |
33 public: | |
34 BrowserPluginHost(WebContentsImpl* web_contents); | |
Charlie Reis
2012/05/18 20:35:24
Please add a comment saying which web_contents thi
Fady Samuel
2012/05/21 14:30:17
Both. I added a comment to say that WebContentsImp
| |
35 | |
36 virtual ~BrowserPluginHost(); | |
37 | |
38 // Get a guest BrowserPluginHost by its container ID specified | |
39 // in BrowserPlugin. | |
40 BrowserPluginHost* GetGuestByContainerID(int container_id); | |
41 | |
42 // Associate a guest with its container instance ID. | |
43 void RegisterContainerInstance( | |
44 int container_id, | |
45 BrowserPluginHost* observer); | |
46 | |
47 // An embedder BrowserPluginHost keeps track of | |
48 // its guests so that if it navigates away, its associated RenderView | |
49 // crashes or it is hidden, it takes appropriate action on the guest. | |
50 void AddGuest(WebContentsImpl* guest, int64 frame_id); | |
51 | |
52 // This removes a guest from an embedder's guest list. | |
53 // TODO(fsamuel): Use this when deleting guest after they crash. | |
54 // ToT plugin crash handling seems to be broken in this case and so I can't | |
55 // test this scenario at the moment. Delete this comment once fixed. | |
56 void RemoveGuest(WebContentsImpl* guest); | |
57 | |
58 WebContentsImpl* embedder() const { return embedder_; } | |
59 void set_embedder(WebContentsImpl* embedder) { embedder_ = embedder; } | |
60 int instance_id() const { return instance_id_; } | |
61 void set_instance_id(int instance_id) { instance_id_ = instance_id; } | |
62 const GURL& url() const { return url_; } | |
63 void set_url(const GURL& url) { url_ = url; } | |
Charlie Reis
2012/05/18 20:35:24
Please remove url_, since this isn't used in the p
Fady Samuel
2012/05/21 14:30:17
Done.
Fady Samuel
2012/05/21 14:30:17
Done.
| |
64 const gfx::Size& initial_size() const { return initial_size_; } | |
65 void set_initial_size(const gfx::Size& size) { initial_size_ = size; } | |
66 RenderViewHost* pending_render_view_host() const { | |
67 return pending_render_view_host_; | |
68 } | |
69 | |
70 void OnCrossProcessNavigation(RenderViewHost* dest_rvh); | |
Charlie Reis
2012/05/18 20:35:24
Add TODO to remove, referencing OnMapInstance. Al
Fady Samuel
2012/05/21 14:30:17
Done.
| |
71 | |
72 void NavigateGuestFromEmbedder(RenderViewHost* render_view_host, | |
73 int container_instance_id, | |
74 long long frame_id, | |
75 const std::string& src, | |
76 const gfx::Size& size); | |
77 | |
78 void OnMapInstance(int container_instance_id, PP_Instance instance); | |
79 | |
80 // WebContentObserver implementation. | |
81 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | |
82 virtual void DidCommitProvisionalLoadForFrame( | |
Charlie Reis
2012/05/18 20:35:24
Add TODO to remove, referencing OnMapInstance.
Fady Samuel
2012/05/21 14:30:17
Unrelated. We discussed this offline. This is used
| |
83 int64 frame_id, | |
84 bool is_main_frame, | |
85 const GURL& url, | |
86 PageTransition transition_type, | |
87 RenderViewHost* render_view_host) OVERRIDE; | |
88 virtual void RenderViewDeleted(RenderViewHost* render_view_host) OVERRIDE; | |
89 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE; | |
90 virtual void WebContentsDestroyed(WebContents* web_contents) OVERRIDE; | |
91 | |
92 private: | |
93 typedef std::map<WebContentsImpl*, int64> GuestMap; | |
94 typedef std::map<int, BrowserPluginHost*> ContainerInstanceMap; | |
95 | |
96 void OnNavigateFromGuest(PP_Instance instance, | |
97 const std::string& src); | |
98 | |
99 void OnConnectToChannel(const IPC::ChannelHandle& handle); | |
100 | |
101 void DestroyGuests(); | |
102 | |
103 // NotificationObserver method override. | |
104 virtual void Observe(int type, | |
105 const NotificationSource& source, | |
106 const NotificationDetails& details) OVERRIDE; | |
107 | |
108 // A scoped container for notification registries. | |
109 NotificationRegistrar registrar_; | |
110 WebContentsImpl* embedder_; | |
111 // An identifier that uniquely identifies a browser plugin container | |
112 // within an embedder. | |
113 int instance_id_; | |
114 GURL url_; | |
115 gfx::Size initial_size_; | |
116 GuestMap guests_; | |
117 ContainerInstanceMap guests_by_container_id_; | |
118 RenderViewHost* pending_render_view_host_; | |
Charlie Reis
2012/05/18 20:35:24
Add TODO to remove, referencing OnMapInstance. We
Fady Samuel
2012/05/21 14:30:17
Done.
| |
119 }; | |
120 | |
121 } // namespace content | |
122 | |
123 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_HOST_H_ | |
OLD | NEW |