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

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

Issue 10868012: Browser Plugin: New Implementation (Browser Side) (Closed) Base URL: http://git.chromium.org/chromium/src.git@master-trial-obrowser
Patch Set: 1. Address comment 2. Fix browsertest target 3. Ignore input evt when guest is dead. Created 8 years, 3 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
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 // A BrowserPluginEmbedder has a list of guest it manages.
6 // In the beginning when a renderer sees one ore more guests (BrowserPlugin
awong 2012/09/07 20:51:03 ore -> or
lazyboy 2012/09/08 02:12:22 Done.
7 // instance(s)) and there is a request to navigate to them, the WebContents of
awong 2012/09/07 20:51:03 of -> for
lazyboy 2012/09/08 02:12:22 Done.
8 // that renderer creates a BrowserPluginEmbedder for it, which in turn manages
awong 2012/09/07 20:51:03 Do you mean "itself" (aka, the WebContents)? Brea
lazyboy 2012/09/08 02:12:22 Done.
9 // the guest(s). It routes any messages directed to a guest from the renderer
awong 2012/09/07 20:51:03 Same question about "It" :( Because the previous
lazyboy 2012/09/08 02:12:22 Done.
10 // (BrowserPlugin) to the appropriate guest (identified by the guest's
11 // |instance_id|). It is responsible for cleaning up the guests when the
12 // embedder frame navigates away to a different page.
13
14 #ifndef CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_EMBEDDER_H_
15 #define CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_EMBEDDER_H_
16
17 #include <map>
18 #include <string>
19
20 #include "base/compiler_specific.h"
21 #include "content/browser/browser_plugin/browser_plugin_host_factory.h"
22 #include "content/public/browser/notification_observer.h"
23 #include "content/public/browser/notification_registrar.h"
24 #include "content/public/browser/render_view_host_observer.h"
25 #include "content/public/browser/web_contents_delegate.h"
26 #include "content/public/browser/web_contents_observer.h"
27 #include "ipc/ipc_channel_handle.h"
28 #include "ipc/ipc_sync_message.h"
29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
30 #include "ui/surface/transport_dib.h"
31 #include "webkit/glue/webcursor.h"
32
33 namespace gfx {
34 class Size;
35 }
36
37 class WebContentsImpl;
38
39 struct BrowserPluginHostMsg_ResizeGuest_Params;
40 struct ViewHostMsg_UpdateRect_Params;
41
42 namespace content {
43
44 class BrowserPluginGuest;
45 class BrowserPluginHostFactory;
46
47 typedef std::map<WebContents*, int64> GuestWebContentsMap;
48 typedef std::map<int, BrowserPluginGuest*> ContainerInstanceMap;
49
50 // A browser plugin embedder provides functionality for WebContents to operate
51 // in the 'embedder' role. It manages list of guests inside the embedder.
52 // The embedder's WebContents manages the lifetime of the embedder. They are
53 // created when a renderer asks WebContents to navigate (for the first time) to
54 // some guest. It gets destroyed when either the WebContents goes away or there
55 // is a RenderViewHost swap in WebContents.
56 class CONTENT_EXPORT BrowserPluginEmbedder : public WebContentsObserver,
57 public NotificationObserver {
58 public:
59 virtual ~BrowserPluginEmbedder();
60
61 static BrowserPluginEmbedder* Create(WebContentsImpl* web_contents,
62 RenderViewHost* render_view_host);
63
64 // Navigates in a guest (new or existing).
65 void NavigateGuest(RenderViewHost* render_view_host,
66 int instance_id,
67 int64 frame_id,
68 const std::string& src,
69 const gfx::Size& size);
70
71 // Overrides factory for testing. Default (NULL) value indicates regular
72 // (non-test) environment.
73 static void set_factory_for_testing(BrowserPluginHostFactory* factory) {
74 factory_ = factory;
75 }
76
77 private:
78 friend class BrowserPluginEmbedderHelper;
79 friend class TestBrowserPluginEmbedder;
80
81 BrowserPluginEmbedder(WebContentsImpl* web_contents,
82 RenderViewHost* render_view_host);
83
84 // Returns a guest browser plugin delegate by its container ID specified
85 // in BrowserPlugin.
86 BrowserPluginGuest* GetGuestByInstanceID(int instance_id) const;
87 // Adds a new guest to the embedder (overridable in test).
88 virtual void AddGuest(int instance_id,
89 BrowserPluginGuest* guest,
90 int64 frame_id);
91 void DestroyGuestByInstanceID(int instance_id);
92 void DestroyGuests();
93
94 // Message handlers (direct/indirect via BrowserPluginEmbedderHelper).
95 // Routes update rect ack message to the appropriate guest.
96 void UpdateRectACK(int instance_id, int message_id, const gfx::Size& size);
97 void SetFocus(int instance_id, bool focused);
98 void ResizeGuest(int instance_id,
99 TransportDIB* damage_buffer,
100 int width,
101 int height,
102 bool resize_pending,
103 float scale_factor);
104 // Handles input events sent from the BrowserPlugin (embedder's renderer
105 // process) by passing them to appropriate guest's input handler.
106 void HandleInputEvent(int instance_id,
107 RenderViewHost* render_view_host,
108 const gfx::Rect& guest_rect,
109 const WebKit::WebInputEvent& event,
110 IPC::Message* reply_message);
111 void PluginDestroyed(int instance_id);
112
113 // WebContentsObserver implementation.
114 // Used to monitor frame navigation to clean up guests when a frame navigates
115 // away from the browser plugin it's hosting.
116 virtual void DidCommitProvisionalLoadForFrame(
117 int64 frame_id,
118 bool is_main_frame,
119 const GURL& url,
120 PageTransition transition_type,
121 RenderViewHost* render_view_host) OVERRIDE;
122 virtual void RenderViewDeleted(RenderViewHost* render_view_host) OVERRIDE;
123 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE;
124
125 // NotificationObserver method override.
126 virtual void Observe(int type,
127 const NotificationSource& source,
128 const NotificationDetails& details) OVERRIDE;
129
130 // Called when visiblity of web_contents changes, so the embedder will
131 // show/hide its guest.
132 void WebContentsVisibilityChanged(bool visible);
133
134 // Static factory instance (always NULL for non-test).
135 static BrowserPluginHostFactory* factory_;
136
137 // A scoped container for notification registries.
138 NotificationRegistrar registrar_;
139
140 // Contains guests' WebContents, mapping to their frame ids.
141 GuestWebContentsMap guest_web_contents_container_;
142 ContainerInstanceMap guests_by_instance_id_;
143 RenderViewHost* render_view_host_;
144
145 DISALLOW_COPY_AND_ASSIGN(BrowserPluginEmbedder);
146 };
147
148 } // namespace content
149
150 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_EMBEDDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698