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

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: fixed nit 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
« no previous file with comments | « no previous file | content/browser/browser_plugin/browser_plugin_host.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // A BrowserPluginHost object is used by both embedders and guests.
25 // The primary purpose of BrowserPluginHost is to allow an embedder
26 // to manage the lifetime of its guests. It cleans up its guests
27 // on navigation, crashes, and "hides" guests when it hides.
28 // For the guest, BrowserPluginHost keeps track of its embedder,
29 // its BrowserPlugin instance ID, and some initialization state
30 // such as initial size.
31 class BrowserPluginHost : public WebContentsObserver,
32 public NotificationObserver,
33 public WebContentsDelegate {
34 public:
35 // BrowserPluginHost is owned by a WebContentsImpl. Here it takes in its
36 // owner. The owner can be either a guest or embedder WebContents.
37 explicit BrowserPluginHost(WebContentsImpl* web_contents);
38
39 virtual ~BrowserPluginHost();
40
41 // TODO(fsamuel): Remove this once BrowserPluginHost_MapInstance
42 // is removed.
43 void OnPendingNavigation(RenderViewHost* dest_rvh);
44
45 void ConnectEmbedderToChannel(RenderViewHost* render_view_host,
46 const IPC::ChannelHandle& handle);
47
48 // This is called on the first navigation of the browser plugin. It creates
49 // a new WebContentsImpl for the guest, associates it with its embedder, sets
50 // its size and navigates it to the src URL.
51 void NavigateGuestFromEmbedder(RenderViewHost* render_view_host,
52 int container_instance_id,
53 long long frame_id,
54 const std::string& src,
55 const gfx::Size& size);
56
57 RenderProcessHost* embedder_render_process_host() const {
58 return embedder_render_process_host_;
59 }
60
61 private:
62 typedef std::map<WebContentsImpl*, int64> GuestMap;
63 typedef std::map<int, BrowserPluginHost*> ContainerInstanceMap;
64
65 // Get a guest BrowserPluginHost by its container ID specified
66 // in BrowserPlugin.
67 BrowserPluginHost* GetGuestByContainerID(int container_id);
68
69 // Associate a guest with its container instance ID.
70 void RegisterContainerInstance(
71 int container_id,
72 BrowserPluginHost* observer);
73
74 // An embedder BrowserPluginHost keeps track of
75 // its guests so that if it navigates away, its associated RenderView
76 // crashes or it is hidden, it takes appropriate action on the guest.
77 void AddGuest(WebContentsImpl* guest, int64 frame_id);
78
79 // This removes a guest from an embedder's guest list.
80 // TODO(fsamuel): Use this when deleting guest after they crash.
81 // ToT plugin crash handling seems to be broken in this case and so I can't
82 // test this scenario at the moment. Delete this comment once fixed.
83 void RemoveGuest(WebContentsImpl* guest);
84
85 void set_embedder_render_process_host(
86 RenderProcessHost* embedder_render_process_host) {
87 embedder_render_process_host_ = embedder_render_process_host;
88 }
89 int instance_id() const { return instance_id_; }
90 void set_instance_id(int instance_id) { instance_id_ = instance_id; }
91 const gfx::Size& initial_size() const { return initial_size_; }
92 void set_initial_size(const gfx::Size& size) { initial_size_ = size; }
93 RenderViewHost* pending_render_view_host() const {
94 return pending_render_view_host_;
95 }
96
97 void OnNavigateFromGuest(PP_Instance instance,
98 const std::string& src);
99
100 void DestroyGuests();
101
102 // TODO(fsamuel): Replace BrowserPluginHost_MapInstance with a message
103 // over the GuestToEmbedderChannel that tells the guest to size itself
104 // and begin compositing. Currently we use the guest's routing ID to look
105 // up the appropriate guest in
106 // BrowserPluginChannelManager::OnCompleteNavigation. In order to bypass the
107 // need to grab a routing ID from the browser process, we can instead pass the
108 // container instance ID to the guest on ViewMsg_New. The container instance
109 // ID and the embedder channel name can then be used together to uniquely
110 // identify a guest RenderViewImpl within a render process.
111 void OnMapInstance(int container_instance_id, PP_Instance instance);
112
113 // WebContentObserver implementation.
114 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
115 // Used to monitor frame navigation to cleanup guests when a frame navigates
116 // away from the browser plugin it's hosting.
117 virtual void DidCommitProvisionalLoadForFrame(
118 int64 frame_id,
119 bool is_main_frame,
120 const GURL& url,
121 PageTransition transition_type,
122 RenderViewHost* render_view_host) OVERRIDE;
123 virtual void RenderViewDeleted(RenderViewHost* render_view_host) OVERRIDE;
124 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE;
125 virtual void WebContentsDestroyed(WebContents* web_contents) OVERRIDE;
126
127 // NotificationObserver method override.
128 virtual void Observe(int type,
129 const NotificationSource& source,
130 const NotificationDetails& details) OVERRIDE;
131
132 // A scoped container for notification registries.
133 NotificationRegistrar registrar_;
134 RenderProcessHost* embedder_render_process_host_;
135 // An identifier that uniquely identifies a browser plugin container
136 // within an embedder.
137 int instance_id_;
138 gfx::Size initial_size_;
139 GuestMap guests_;
140 ContainerInstanceMap guests_by_container_id_;
141 // TODO(fsamuel): This should not be exposed outside of WebContentsImpl
142 // because this can change at any time. Remove this, along with
143 // OnPendingNavigation once BrowserPluginHost_MapInstance is modified
144 // to be sent over the GuestToEmbedderChannel directly instead of through
145 // the browser process.
146 RenderViewHost* pending_render_view_host_;
147 };
148
149 } // namespace content
150
151 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_HOST_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/browser_plugin/browser_plugin_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698