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

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

Issue 10965048: [BrowserTag] Send dib info with NavigateGuest message, (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Mac fix renderer side content_browsertests; use mocked versions of transport dib for tests + clean … Created 8 years, 2 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // A BrowserPluginEmbedder has a list of guests it manages. 5 // A BrowserPluginEmbedder has a list of guests it manages.
6 // In the beginning when a renderer sees one or more guests (BrowserPlugin 6 // In the beginning when a renderer sees one or more guests (BrowserPlugin
7 // instance(s)) and there is a request to navigate to them, the WebContents for 7 // instance(s)) and there is a request to navigate to them, the WebContents for
8 // that renderer creates a BrowserPluginEmbedder for itself. The 8 // that renderer creates a BrowserPluginEmbedder for itself. The
9 // BrowserPluginEmbedder, in turn, manages a set of BrowserPluginGuests -- one 9 // BrowserPluginEmbedder, in turn, manages a set of BrowserPluginGuests -- one
10 // BrowserPluginGuest for each guest in the embedding WebContents. Note that 10 // BrowserPluginGuest for each guest in the embedding WebContents. Note that
11 // each of these BrowserPluginGuest objects has its own WebContents. 11 // each of these BrowserPluginGuest objects has its own WebContents.
12 // BrowserPluginEmbedder routes any messages directed to a guest from the 12 // BrowserPluginEmbedder routes any messages directed to a guest from the
13 // renderer (BrowserPlugin) to the appropriate guest (identified by the guest's 13 // renderer (BrowserPlugin) to the appropriate guest (identified by the guest's
14 // |instance_id|). 14 // |instance_id|).
15 // 15 //
16 // BrowserPluginEmbedder is responsible for cleaning up the guests when the 16 // BrowserPluginEmbedder is responsible for cleaning up the guests when the
17 // embedder frame navigates away to a different page or deletes the guests from 17 // embedder frame navigates away to a different page or deletes the guests from
18 // the existing page. 18 // the existing page.
19 19
20 #ifndef CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_EMBEDDER_H_ 20 #ifndef CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_EMBEDDER_H_
21 #define CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_EMBEDDER_H_ 21 #define CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_EMBEDDER_H_
22 22
23 #include <map> 23 #include <map>
24 24
25 #include "base/compiler_specific.h" 25 #include "base/compiler_specific.h"
26 #include "content/public/browser/notification_observer.h" 26 #include "content/public/browser/notification_observer.h"
27 #include "content/public/browser/notification_registrar.h" 27 #include "content/public/browser/notification_registrar.h"
28 #include "content/public/browser/web_contents_observer.h" 28 #include "content/public/browser/web_contents_observer.h"
29 #include "ui/surface/transport_dib.h"
29 30
30 class TransportDIB;
31 class WebContentsImpl; 31 class WebContentsImpl;
32 struct BrowserPluginHostMsg_ResizeGuest_Params;
32 33
33 namespace WebKit { 34 namespace WebKit {
34 class WebInputEvent; 35 class WebInputEvent;
35 } 36 }
36 37
37 namespace gfx { 38 namespace gfx {
38 class Rect; 39 class Rect;
39 class Size; 40 class Size;
40 } 41 }
41 42
(...skipping 13 matching lines...) Expand all
55 public NotificationObserver { 56 public NotificationObserver {
56 public: 57 public:
57 typedef std::map<int, WebContents*> ContainerInstanceMap; 58 typedef std::map<int, WebContents*> ContainerInstanceMap;
58 59
59 virtual ~BrowserPluginEmbedder(); 60 virtual ~BrowserPluginEmbedder();
60 61
61 static BrowserPluginEmbedder* Create(WebContentsImpl* web_contents, 62 static BrowserPluginEmbedder* Create(WebContentsImpl* web_contents,
62 RenderViewHost* render_view_host); 63 RenderViewHost* render_view_host);
63 64
64 // Navigates in a guest (new or existing). 65 // Navigates in a guest (new or existing).
65 void NavigateGuest(RenderViewHost* render_view_host, 66 void NavigateGuest(
66 int instance_id, 67 RenderViewHost* render_view_host,
67 const std::string& src, 68 int instance_id,
68 const gfx::Size& size); 69 const std::string& src,
70 const BrowserPluginHostMsg_ResizeGuest_Params& resize_params);
71
72 void ResizeGuest(RenderViewHost* render_view_host,
73 int instance_id,
74 const BrowserPluginHostMsg_ResizeGuest_Params& params);
75
69 void Stop(int instance_id); 76 void Stop(int instance_id);
70 void Reload(int instance_id); 77 void Reload(int instance_id);
71 78
72 // WebContentsObserver implementation. 79 // WebContentsObserver implementation.
73 virtual void RenderViewDeleted(RenderViewHost* render_view_host) OVERRIDE; 80 virtual void RenderViewDeleted(RenderViewHost* render_view_host) OVERRIDE;
74 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE; 81 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE;
75 82
76 // NotificationObserver method override. 83 // NotificationObserver method override.
77 virtual void Observe(int type, 84 virtual void Observe(int type,
78 const NotificationSource& source, 85 const NotificationSource& source,
79 const NotificationDetails& details) OVERRIDE; 86 const NotificationDetails& details) OVERRIDE;
80 87
81 // Message handlers (direct/indirect via BrowserPluginEmbedderHelper). 88 // Message handlers (direct/indirect via BrowserPluginEmbedderHelper).
82 // Routes update rect ack message to the appropriate guest. 89 // Routes update rect ack message to the appropriate guest.
83 void UpdateRectACK(int instance_id, int message_id, const gfx::Size& size); 90 void UpdateRectACK(int instance_id, int message_id, const gfx::Size& size);
84 void SetFocus(int instance_id, bool focused); 91 void SetFocus(int instance_id, bool focused);
85 void ResizeGuest(int instance_id,
86 TransportDIB* damage_buffer,
87 #if defined(OS_WIN)
88 int damage_buffer_size,
89 #endif
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 92 // Handles input events sent from the BrowserPlugin (embedder's renderer
95 // process) by passing them to appropriate guest's input handler. 93 // process) by passing them to appropriate guest's input handler.
96 void HandleInputEvent(int instance_id, 94 void HandleInputEvent(int instance_id,
97 RenderViewHost* render_view_host, 95 RenderViewHost* render_view_host,
98 const gfx::Rect& guest_rect, 96 const gfx::Rect& guest_rect,
99 const WebKit::WebInputEvent& event, 97 const WebKit::WebInputEvent& event,
100 IPC::Message* reply_message); 98 IPC::Message* reply_message);
101 void PluginDestroyed(int instance_id); 99 void PluginDestroyed(int instance_id);
102 100
103 // Overrides factory for testing. Default (NULL) value indicates regular 101 // Overrides factory for testing. Default (NULL) value indicates regular
104 // (non-test) environment. 102 // (non-test) environment.
105 static void set_factory_for_testing(BrowserPluginHostFactory* factory) { 103 static void set_factory_for_testing(BrowserPluginHostFactory* factory) {
106 factory_ = factory; 104 factory_ = factory;
107 } 105 }
108 106
109 private: 107 private:
110 friend class TestBrowserPluginEmbedder; 108 friend class TestBrowserPluginEmbedder;
111 109
112 BrowserPluginEmbedder(WebContentsImpl* web_contents, 110 BrowserPluginEmbedder(WebContentsImpl* web_contents,
113 RenderViewHost* render_view_host); 111 RenderViewHost* render_view_host);
114 112
115 // Returns a guest browser plugin delegate by its container ID specified 113 // Returns a guest browser plugin delegate by its container ID specified
116 // in BrowserPlugin. 114 // in BrowserPlugin.
117 BrowserPluginGuest* GetGuestByInstanceID(int instance_id) const; 115 BrowserPluginGuest* GetGuestByInstanceID(int instance_id) const;
118 // Adds a new guest web_contents to the embedder (overridable in test). 116 // Adds a new guest web_contents to the embedder (overridable in test).
119 virtual void AddGuest(int instance_id, WebContents* guest_web_contents); 117 virtual void AddGuest(int instance_id, WebContents* guest_web_contents);
120 void DestroyGuestByInstanceID(int instance_id); 118 void DestroyGuestByInstanceID(int instance_id);
121 void DestroyGuests(); 119 void DestroyGuests();
122 120
121 // Returns the transport DIB associated with the dib in resize |params|.
122 TransportDIB* GetDamageBuffer(
123 RenderViewHost* render_view_host,
124 const BrowserPluginHostMsg_ResizeGuest_Params& params);
125
123 // Called when visiblity of web_contents changes, so the embedder will 126 // Called when visiblity of web_contents changes, so the embedder will
124 // show/hide its guest. 127 // show/hide its guest.
125 void WebContentsVisibilityChanged(bool visible); 128 void WebContentsVisibilityChanged(bool visible);
126 129
127 // Static factory instance (always NULL for non-test). 130 // Static factory instance (always NULL for non-test).
128 static BrowserPluginHostFactory* factory_; 131 static BrowserPluginHostFactory* factory_;
129 132
130 // A scoped container for notification registries. 133 // A scoped container for notification registries.
131 NotificationRegistrar registrar_; 134 NotificationRegistrar registrar_;
132 135
133 // Contains guests' WebContents, mapping from their instance ids. 136 // Contains guests' WebContents, mapping from their instance ids.
134 ContainerInstanceMap guest_web_contents_by_instance_id_; 137 ContainerInstanceMap guest_web_contents_by_instance_id_;
135 RenderViewHost* render_view_host_; 138 RenderViewHost* render_view_host_;
136 139
137 DISALLOW_COPY_AND_ASSIGN(BrowserPluginEmbedder); 140 DISALLOW_COPY_AND_ASSIGN(BrowserPluginEmbedder);
138 }; 141 };
139 142
140 } // namespace content 143 } // namespace content
141 144
142 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_EMBEDDER_H_ 145 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_EMBEDDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698