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

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: Rewrite test to *not* use NOTIFICATION_* 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.
42 class CONTENT_EXPORT BrowserPluginEmbedder : public WebContentsObserver,
43 public NotificationObserver {
44 public:
45 BrowserPluginEmbedder(WebContentsImpl* web_contents,
46 RenderViewHost* render_view_host);
47 virtual ~BrowserPluginEmbedder();
48
49 static BrowserPluginEmbedder* CreateInstance(
50 WebContentsImpl* web_contents,
51 RenderViewHost* render_view_host);
52
53 // Navigates in a guest (new or existing).
54 void NavigateGuest(RenderViewHost* render_view_host,
55 int instance_id,
56 int64 frame_id,
57 const std::string& src,
58 const gfx::Size& size);
59
60 // Overrides factory for testing. Default (NULL) value indicates regular
61 // (non-test) environment.
62 static void set_factory_for_testing(BrowserPluginHostFactory* factory) {
63 factory_ = factory;
64 }
65
66 private:
67 friend class BrowserPluginEmbedderHelper;
68 // For testing.
69 friend class TestBrowserPluginEmbedder;
70
71 // Returns a guest browser plugin delegate by its container ID specified
72 // in BrowserPlugin.
73 BrowserPluginGuest* GetGuestByInstanceID(int instance_id) const;
74 // Adds a new guest to the embedder (overridable in test).
75 virtual void AddGuest(int instance_id,
76 BrowserPluginGuest* guest,
77 int64 frame_id);
78 void DestroyGuestByInstanceID(int instance_id);
79 void DestroyGuests();
80
81 // Message handlers (direct/indirect via BrowserPluginEmbedderHelper).
82 // Routes update rect ack message to the appropriate guest.
83 void UpdateRectACK(int instance_id, int message_id, const gfx::Size& size);
84 void SetFocus(int instance_id, bool focused);
85 void ResizeGuest(int instance_id,
86 TransportDIB* damage_buffer,
87 int width,
88 int height,
89 bool resize_pending,
90 float scale_factor);
91 // Handles input events sent from the BrowserPlugin (embedder's renderer
92 // process) by passing them to appropriate guest's input handler.
93 void HandleInputEvent(int instance_id,
94 RenderViewHost* render_view_host,
95 const gfx::Rect& guest_rect,
96 const WebKit::WebInputEvent& event,
97 IPC::Message* reply_message);
98 void PluginDestroyed(int instance_id);
99
100 // WebContentsObserver implementation.
101 // Used to monitor frame navigation to clean up guests when a frame navigates
102 // away from the browser plugin it's hosting.
103 virtual void DidCommitProvisionalLoadForFrame(
104 int64 frame_id,
105 bool is_main_frame,
106 const GURL& url,
107 PageTransition transition_type,
108 RenderViewHost* render_view_host) OVERRIDE;
109 virtual void RenderViewDeleted(RenderViewHost* render_view_host) OVERRIDE;
110 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE;
111
112 // NotificationObserver method override.
113 virtual void Observe(int type,
114 const NotificationSource& source,
115 const NotificationDetails& details) OVERRIDE;
116
117 // Called when visiblity of web_contents changes, so the embedder will
118 // show/hide its guest.
119 void WebContentsVisiblitlyChanged(bool visible);
120
121 // Static factory instance (always NULL for non-test).
122 static BrowserPluginHostFactory* factory_;
123
124 // A scoped container for notification registries.
125 NotificationRegistrar registrar_;
126
127 // Contains guests' WebContents, mapping to their frame ids.
128 GuestWebContentsMap guest_web_contents_container_;
129 ContainerInstanceMap guests_by_instance_id_;
130
131 DISALLOW_COPY_AND_ASSIGN(BrowserPluginEmbedder);
132 };
133
134 } // namespace content
135
136 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_EMBEDDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698