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

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

Powered by Google App Engine
This is Rietveld 408576698