Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(578)

Side by Side Diff: content/browser/browser_plugin/browser_plugin_host.h

Issue 10377170: Browser Plugin: browser process side changes (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Updated according to jam@ Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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
11 #include "content/public/browser/notification_observer.h"
12 #include "content/public/browser/notification_registrar.h"
13 #include "content/public/browser/web_contents_delegate.h"
14 #include "content/public/browser/web_contents_observer.h"
15 #include "ppapi/c/pp_instance.h"
16 #include "ui/gfx/size.h"
17
18 class WebContentsImpl;
19
20 namespace content {
21
22 class RenderProcessHost;
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.
Charlie Reis 2012/05/21 18:20:44 It's taken me a few readings of the code to unders
Fady Samuel 2012/05/21 19:22:17 Added a sentence. In a completely general implemen
Charlie Reis 2012/05/21 19:49:25 Ah, of course.
30 class BrowserPluginHost : public WebContentsObserver,
31 public NotificationObserver,
32 public WebContentsDelegate {
33 public:
34 // BrowserPluginHost is owned by a WebContentsImpl. Here it takes in its
35 // owner. The owner can be either a guest or embedder WebContents.
36 explicit BrowserPluginHost(WebContentsImpl* web_contents);
37
38 virtual ~BrowserPluginHost();
39
40 // TODO(fsamuel): Remove this once BrowserPluginHost_MapInstance
41 // is removed.
42 void OnPendingNavigation(RenderViewHost* dest_rvh);
43
44 void ConnectEmbedderToChannel(RenderViewHost* render_view_host,
45 const IPC::ChannelHandle& handle);
46
47 void NavigateGuestFromEmbedder(RenderViewHost* render_view_host,
Charlie Reis 2012/05/21 18:20:44 Please add a comment to this explaining what it's
Fady Samuel 2012/05/21 19:22:17 Done.
48 int container_instance_id,
49 long long frame_id,
50 const std::string& src,
51 const gfx::Size& size);
52
53 RenderProcessHost* embedder_render_process_host() const {
54 return embedder_render_process_host_;
55 }
56
57 private:
58 typedef std::map<WebContentsImpl*, int64> GuestMap;
59 typedef std::map<int, BrowserPluginHost*> ContainerInstanceMap;
60
61 // Get a guest BrowserPluginHost by its container ID specified
62 // in BrowserPlugin.
63 BrowserPluginHost* GetGuestByContainerID(int container_id);
64
65 // Associate a guest with its container instance ID.
66 void RegisterContainerInstance(
67 int container_id,
68 BrowserPluginHost* observer);
69
70 // An embedder BrowserPluginHost keeps track of
71 // its guests so that if it navigates away, its associated RenderView
72 // crashes or it is hidden, it takes appropriate action on the guest.
73 void AddGuest(WebContentsImpl* guest, int64 frame_id);
74
75 // This removes a guest from an embedder's guest list.
76 // TODO(fsamuel): Use this when deleting guest after they crash.
77 // ToT plugin crash handling seems to be broken in this case and so I can't
78 // test this scenario at the moment. Delete this comment once fixed.
79 void RemoveGuest(WebContentsImpl* guest);
80
81 void set_embedder_render_process_host(
82 RenderProcessHost* embedder_render_process_host) {
83 embedder_render_process_host_ = embedder_render_process_host;
84 }
85 int instance_id() const { return instance_id_; }
86 void set_instance_id(int instance_id) { instance_id_ = instance_id; }
87 const gfx::Size& initial_size() const { return initial_size_; }
88 void set_initial_size(const gfx::Size& size) { initial_size_ = size; }
89 RenderViewHost* pending_render_view_host() const {
90 return pending_render_view_host_;
91 }
92
93 void OnNavigateFromGuest(PP_Instance instance,
94 const std::string& src);
95
96 void DestroyGuests();
97
98 // TODO(fsamuel): Replace BrowserPluginHost_MapInstance with a message
99 // over the GuestToEmbedderChannel that tells the guest to size itself
100 // and begin compositing. Currently we use the guest's routing ID to look
101 // up the appropriate guest in
102 // BrowserPluginChannelManager::OnCompleteNavigation. In order to bypass the
103 // need to grab a routing ID from the browser process, we can instead pass the
104 // container instance ID to the guest on ViewMsg_New. The container instance
105 // ID and the embedder channel name can then be used together to uniquely
106 // identify a guest RenderViewImpl within a render process.
107 void OnMapInstance(int container_instance_id, PP_Instance instance);
108
109 // WebContentObserver implementation.
110 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
111 // Used to monitor frame navigation to cleanup guests when a frame navigates
112 // away from the browser plugin it's hosting.
113 virtual void DidCommitProvisionalLoadForFrame(
114 int64 frame_id,
115 bool is_main_frame,
116 const GURL& url,
117 PageTransition transition_type,
118 RenderViewHost* render_view_host) OVERRIDE;
119 virtual void RenderViewDeleted(RenderViewHost* render_view_host) OVERRIDE;
120 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE;
121 virtual void WebContentsDestroyed(WebContents* web_contents) OVERRIDE;
122
123 // NotificationObserver method override.
124 virtual void Observe(int type,
125 const NotificationSource& source,
126 const NotificationDetails& details) OVERRIDE;
127
128 // A scoped container for notification registries.
129 NotificationRegistrar registrar_;
130 RenderProcessHost* embedder_render_process_host_;
131 // An identifier that uniquely identifies a browser plugin container
132 // within an embedder.
133 int instance_id_;
134 gfx::Size initial_size_;
135 GuestMap guests_;
136 ContainerInstanceMap guests_by_container_id_;
137 // TODO(fsamuel): This should not be exposed outside of WebContentsImpl
138 // because this can change at any time. Remove this, along with
139 // OnPendingNavigation once BrowserPluginHost_MapInstance is modified
140 // to be sent over the GuestToEmbedderChannel directly instead of through
141 // the browser process.
142 RenderViewHost* pending_render_view_host_;
143 };
144
145 } // namespace content
146
147 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698