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

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: Sync @tott, correct rebase, bring back two lost comments from previous rounds 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
« no previous file with comments | « no previous file | content/browser/browser_plugin/browser_plugin_embedder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 Go(int instance_id, int relative_index); 76 void Go(int instance_id, int relative_index);
70 void Stop(int instance_id); 77 void Stop(int instance_id);
71 void Reload(int instance_id); 78 void Reload(int instance_id);
72 79
73 // WebContentsObserver implementation. 80 // WebContentsObserver implementation.
74 virtual void RenderViewDeleted(RenderViewHost* render_view_host) OVERRIDE; 81 virtual void RenderViewDeleted(RenderViewHost* render_view_host) OVERRIDE;
75 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE; 82 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE;
76 83
77 // NotificationObserver method override. 84 // NotificationObserver method override.
78 virtual void Observe(int type, 85 virtual void Observe(int type,
79 const NotificationSource& source, 86 const NotificationSource& source,
80 const NotificationDetails& details) OVERRIDE; 87 const NotificationDetails& details) OVERRIDE;
81 88
82 // Message handlers (direct/indirect via BrowserPluginEmbedderHelper). 89 // Message handlers (direct/indirect via BrowserPluginEmbedderHelper).
83 // Routes update rect ack message to the appropriate guest. 90 // Routes update rect ack message to the appropriate guest.
84 void UpdateRectACK(int instance_id, int message_id, const gfx::Size& size); 91 void UpdateRectACK(int instance_id, int message_id, const gfx::Size& size);
85 void SetFocus(int instance_id, bool focused); 92 void SetFocus(int instance_id, bool focused);
86 void ResizeGuest(int instance_id,
87 TransportDIB* damage_buffer,
88 #if defined(OS_WIN)
89 int damage_buffer_size,
90 #endif
91 int width,
92 int height,
93 bool resize_pending,
94 float scale_factor);
95 // Handles input events sent from the BrowserPlugin (embedder's renderer 93 // Handles input events sent from the BrowserPlugin (embedder's renderer
96 // process) by passing them to appropriate guest's input handler. 94 // process) by passing them to appropriate guest's input handler.
97 void HandleInputEvent(int instance_id, 95 void HandleInputEvent(int instance_id,
98 RenderViewHost* render_view_host, 96 RenderViewHost* render_view_host,
99 const gfx::Rect& guest_rect, 97 const gfx::Rect& guest_rect,
100 const WebKit::WebInputEvent& event, 98 const WebKit::WebInputEvent& event,
101 IPC::Message* reply_message); 99 IPC::Message* reply_message);
102 void PluginDestroyed(int instance_id); 100 void PluginDestroyed(int instance_id);
103 101
104 // Overrides factory for testing. Default (NULL) value indicates regular 102 // Overrides factory for testing. Default (NULL) value indicates regular
105 // (non-test) environment. 103 // (non-test) environment.
106 static void set_factory_for_testing(BrowserPluginHostFactory* factory) { 104 static void set_factory_for_testing(BrowserPluginHostFactory* factory) {
107 factory_ = factory; 105 factory_ = factory;
108 } 106 }
109 107
110 private: 108 private:
111 friend class TestBrowserPluginEmbedder; 109 friend class TestBrowserPluginEmbedder;
112 110
113 BrowserPluginEmbedder(WebContentsImpl* web_contents, 111 BrowserPluginEmbedder(WebContentsImpl* web_contents,
114 RenderViewHost* render_view_host); 112 RenderViewHost* render_view_host);
115 113
116 // Returns a guest browser plugin delegate by its container ID specified 114 // Returns a guest browser plugin delegate by its container ID specified
117 // in BrowserPlugin. 115 // in BrowserPlugin.
118 BrowserPluginGuest* GetGuestByInstanceID(int instance_id) const; 116 BrowserPluginGuest* GetGuestByInstanceID(int instance_id) const;
119 // Adds a new guest web_contents to the embedder (overridable in test). 117 // Adds a new guest web_contents to the embedder (overridable in test).
120 virtual void AddGuest(int instance_id, WebContents* guest_web_contents); 118 virtual void AddGuest(int instance_id, WebContents* guest_web_contents);
121 void DestroyGuestByInstanceID(int instance_id); 119 void DestroyGuestByInstanceID(int instance_id);
122 void DestroyGuests(); 120 void DestroyGuests();
123 121
122 // Returns the transport DIB associated with the dib in resize |params|.
123 TransportDIB* GetDamageBuffer(
124 RenderViewHost* render_view_host,
125 const BrowserPluginHostMsg_ResizeGuest_Params& params);
126
124 // Called when visiblity of web_contents changes, so the embedder will 127 // Called when visiblity of web_contents changes, so the embedder will
125 // show/hide its guest. 128 // show/hide its guest.
126 void WebContentsVisibilityChanged(bool visible); 129 void WebContentsVisibilityChanged(bool visible);
127 130
128 // Static factory instance (always NULL for non-test). 131 // Static factory instance (always NULL for non-test).
129 static BrowserPluginHostFactory* factory_; 132 static BrowserPluginHostFactory* factory_;
130 133
131 // A scoped container for notification registries. 134 // A scoped container for notification registries.
132 NotificationRegistrar registrar_; 135 NotificationRegistrar registrar_;
133 136
134 // Contains guests' WebContents, mapping from their instance ids. 137 // Contains guests' WebContents, mapping from their instance ids.
135 ContainerInstanceMap guest_web_contents_by_instance_id_; 138 ContainerInstanceMap guest_web_contents_by_instance_id_;
136 RenderViewHost* render_view_host_; 139 RenderViewHost* render_view_host_;
137 140
138 DISALLOW_COPY_AND_ASSIGN(BrowserPluginEmbedder); 141 DISALLOW_COPY_AND_ASSIGN(BrowserPluginEmbedder);
139 }; 142 };
140 143
141 } // namespace content 144 } // namespace content
142 145
143 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_EMBEDDER_H_ 146 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_EMBEDDER_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/browser_plugin/browser_plugin_embedder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698