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

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: Fix incorrect sync+rebase. 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 #ifndef CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_EMBEDDER_H_
6 #define CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_EMBEDDER_H_
7
8 #include <string>
9
10 #include "base/compiler_specific.h"
11 #include "content/browser/browser_plugin/browser_plugin_host_factory.h"
12 #include "content/public/browser/notification_observer.h"
13 #include "content/public/browser/notification_registrar.h"
14 #include "content/public/browser/render_view_host_observer.h"
15 #include "content/public/browser/web_contents_delegate.h"
16 #include "content/public/browser/web_contents_observer.h"
17 #include "ipc/ipc_channel_handle.h"
18 #include "ipc/ipc_sync_message.h"
19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
20 #include "ui/surface/transport_dib.h"
21 #include "webkit/glue/webcursor.h"
22
23 namespace gfx {
24 class Size;
25 }
26
27 class WebContentsImpl;
28
29 struct BrowserPluginHostMsg_ResizeGuest_Params;
30 struct ViewHostMsg_UpdateRect_Params;
31
32 namespace content {
33
34 class BrowserPluginGuest;
35 class BrowserPluginHostFactory;
36
37 typedef std::map<WebContents*, int64> GuestWebContentsMap;
38 typedef std::map<int, BrowserPluginGuest*> ContainerInstanceMap;
39
40 // A browser plugin embedder provides functionality for WebContents to operate
41 // in the 'embedder' role, manages list of guests inside the embedder.
awong 2012/08/31 18:08:08 role, manages -> role. It manages
lazyboy 2012/08/31 18:49:18 Done.
42 class CONTENT_EXPORT BrowserPluginEmbedder : public WebContentsObserver,
43 public NotificationObserver {
44 public:
45 BrowserPluginEmbedder(WebContentsImpl* web_contents,
awong 2012/08/31 18:08:08 If we have a factory method, why do we have a publ
lazyboy 2012/08/31 18:49:18 Done.
46 RenderViewHost* render_view_host);
47 virtual ~BrowserPluginEmbedder();
48
49 static BrowserPluginEmbedder* Create(WebContentsImpl* web_contents,
50 RenderViewHost* render_view_host);
51
52 // Navigates in a guest (new or existing).
53 void NavigateGuest(RenderViewHost* render_view_host,
54 int instance_id,
55 int64 frame_id,
56 const std::string& src,
57 const gfx::Size& size);
58
59 // Overrides factory for testing. Default (NULL) value indicates regular
60 // (non-test) environment.
61 static void set_factory_for_testing(BrowserPluginHostFactory* factory) {
62 factory_ = factory;
63 }
64
65 // Returns true if this Embedder is associated with the RenderViewHost.
66 bool IsForRenderViewHost(RenderViewHost* rvh);
67
68 private:
69 friend class BrowserPluginEmbedderHelper;
70 // For testing.
awong 2012/08/31 18:08:08 For testing. is obvious from the class name :)
lazyboy 2012/08/31 18:49:18 Removed comment.
71 friend class TestBrowserPluginEmbedder;
72
73 // Returns a guest browser plugin delegate by its container ID specified
74 // in BrowserPlugin.
75 BrowserPluginGuest* GetGuestByInstanceID(int instance_id) const;
76 // Adds a new guest to the embedder (overridable in test).
77 virtual void AddGuest(int instance_id,
78 BrowserPluginGuest* guest,
79 int64 frame_id);
80 void DestroyGuestByInstanceID(int instance_id);
81 void DestroyGuests();
82
83 // Message handlers (direct/indirect via BrowserPluginEmbedderHelper).
84 // Routes update rect ack message to the appropriate guest.
85 void UpdateRectACK(int instance_id, int message_id, const gfx::Size& size);
86 void SetFocus(int instance_id, bool focused);
87 void ResizeGuest(int instance_id,
88 TransportDIB* damage_buffer,
89 int width,
90 int height,
91 bool resize_pending,
92 float scale_factor);
93 // Handles input events sent from the BrowserPlugin (embedder's renderer
94 // process) by passing them to appropriate guest's input handler.
95 void HandleInputEvent(int instance_id,
96 RenderViewHost* render_view_host,
97 const gfx::Rect& guest_rect,
98 const WebKit::WebInputEvent& event,
99 IPC::Message* reply_message);
100 void PluginDestroyed(int instance_id);
101
102 // WebContentsObserver implementation.
103 // Used to monitor frame navigation to clean up guests when a frame navigates
104 // away from the browser plugin it's hosting.
105 virtual void DidCommitProvisionalLoadForFrame(
106 int64 frame_id,
107 bool is_main_frame,
108 const GURL& url,
109 PageTransition transition_type,
110 RenderViewHost* render_view_host) OVERRIDE;
111 virtual void RenderViewDeleted(RenderViewHost* render_view_host) OVERRIDE;
112 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE;
113
114 // NotificationObserver method override.
115 virtual void Observe(int type,
116 const NotificationSource& source,
117 const NotificationDetails& details) OVERRIDE;
118
119 // Called when visiblity of web_contents changes, so the embedder will
120 // show/hide its guest.
121 void WebContentsVisibilityChanged(bool visible);
122
123 // Static factory instance (always NULL for non-test).
124 static BrowserPluginHostFactory* factory_;
125
126 // A scoped container for notification registries.
127 NotificationRegistrar registrar_;
128
129 // Contains guests' WebContents, mapping to their frame ids.
130 GuestWebContentsMap guest_web_contents_container_;
131 ContainerInstanceMap guests_by_instance_id_;
132 RenderViewHost* render_view_host_;
133
134 DISALLOW_COPY_AND_ASSIGN(BrowserPluginEmbedder);
135 };
136
137 } // namespace content
138
139 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_EMBEDDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698